Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix integration test #518

Merged
merged 9 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
22 changes: 21 additions & 1 deletion core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down
Loading