diff --git a/core/state_transition.go b/core/state_transition.go index 6f9b9a1a29d..d79c356cf6a 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -505,6 +505,13 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype } else { st.state.AddBalance(coinbase, amount, tracing.BalanceIncreaseRewardTransactionFee) } + if !msg.IsFree() && rules.IsLondon { + burntContractAddress := st.evm.ChainConfig().GetBurntContract(st.evm.Context.BlockNumber) + if burntContractAddress != nil { + burnAmount := new(uint256.Int).Mul(new(uint256.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee) + st.state.AddBalance(*burntContractAddress, burnAmount, tracing.BalanceChangeUnspecified) + } + } result := &evmtypes.ExecutionResult{ UsedGas: st.gasUsed(), diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 02b52a7807f..9f20d092b3b 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -169,6 +169,19 @@ var PrecompiledContractsCancun = map[libcommon.Address]PrecompiledContract{ libcommon.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{}, libcommon.BytesToAddress([]byte{0x09}): &blake2F{}, libcommon.BytesToAddress([]byte{0x0a}): &pointEvaluation{}, +} + +var PrecompiledContractsCancunForBsc = map[libcommon.Address]PrecompiledContract{ + libcommon.BytesToAddress([]byte{0x01}): &ecrecover{}, + libcommon.BytesToAddress([]byte{0x02}): &sha256hash{}, + libcommon.BytesToAddress([]byte{0x03}): &ripemd160hash{}, + libcommon.BytesToAddress([]byte{0x04}): &dataCopy{}, + libcommon.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true}, + libcommon.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{}, + libcommon.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{}, + libcommon.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{}, + libcommon.BytesToAddress([]byte{0x09}): &blake2F{}, + libcommon.BytesToAddress([]byte{0x0a}): &pointEvaluation{}, libcommon.BytesToAddress([]byte{100}): &tmHeaderValidate{}, libcommon.BytesToAddress([]byte{101}): &iavlMerkleProofValidatePlato{}, @@ -340,6 +353,7 @@ var ( PrecompiledAddressesPrague []libcommon.Address PrecompiledAddressesNapoli []libcommon.Address PrecompiledAddressesCancun []libcommon.Address + PrecompiledAddressesCancunForBSC []libcommon.Address PrecompiledAddressesBerlin []libcommon.Address PrecompiledAddressesIstanbul []libcommon.Address PrecompiledAddressesIstanbulForBSC []libcommon.Address @@ -387,11 +401,14 @@ func init() { for k := range PrecompiledContractsCancun { PrecompiledAddressesCancun = append(PrecompiledAddressesCancun, k) } + for k := range PrecompiledContractsCancunForBsc { + PrecompiledAddressesCancunForBSC = append(PrecompiledAddressesCancunForBSC, k) + } for k := range PrecompiledContractsHaber { PrecompiledAddressesHaber = append(PrecompiledAddressesHaber, k) } for k := range PrecompiledContractsNapoli { - PrecompiledAddressesPrague = append(PrecompiledAddressesNapoli, k) + PrecompiledAddressesNapoli = append(PrecompiledAddressesNapoli, k) } for k := range PrecompiledContractsPrague { PrecompiledAddressesPrague = append(PrecompiledAddressesPrague, k) @@ -408,6 +425,9 @@ func ActivePrecompiles(rules *chain.Rules) []libcommon.Address { case rules.IsHaber: return PrecompiledAddressesHaber case rules.IsCancun: + if rules.IsParlia { + return PrecompiledAddressesCancunForBSC + } return PrecompiledAddressesCancun case rules.IsFeynman: return PrecompiledAddressesFeynman diff --git a/core/vm/evm.go b/core/vm/evm.go index 92ade30771f..7d6c7e8303b 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -47,7 +47,11 @@ func (evm *EVM) precompile(addr libcommon.Address) (PrecompiledContract, bool) { case evm.chainRules.IsHaber: precompiles = PrecompiledContractsHaber case evm.chainRules.IsCancun: - precompiles = PrecompiledContractsCancun + if evm.chainRules.IsParlia { + precompiles = PrecompiledContractsCancunForBsc + } else { + precompiles = PrecompiledContractsCancun + } case evm.chainRules.IsFeynman: precompiles = PrecompiledContractsFeynman case evm.chainRules.IsHertz: diff --git a/erigon-lib/chain/chain_config.go b/erigon-lib/chain/chain_config.go index cc92bfefd0d..b406bf24445 100644 --- a/erigon-lib/chain/chain_config.go +++ b/erigon-lib/chain/chain_config.go @@ -802,7 +802,7 @@ func (c *Config) Rules(num uint64, time uint64) *Rules { IsBohr: c.IsBohr(num, time), IsOsaka: c.IsOsaka(time), IsAura: c.Aura != nil, - IsParlia: true, + IsParlia: c.Parlia != nil, } }