Skip to content

Commit

Permalink
Cache PrecompiledAddressesArbOS30 and update precompile in evm.go
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed Apr 19, 2024
1 parent 96743fd commit 6d749bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@ func init() {
func ActivePrecompiles(rules params.Rules) []common.Address {
switch {
case rules.IsArbitrum:
var ret []common.Address
if rules.ArbOSVersion >= 30 {
ret = append(ret, PrecompiledAddressesP256Verify...)
return PrecompiledAddressesArbOS30
}
return append(ret, PrecompiledAddressesArbitrum...)
return PrecompiledAddressesArbitrum
case rules.IsCancun:
return PrecompiledAddressesCancun
case rules.IsBerlin:
Expand Down
2 changes: 2 additions & 0 deletions core/vm/contracts_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import "github.com/ethereum/go-ethereum/common"
var (
PrecompiledContractsArbitrum = make(map[common.Address]PrecompiledContract)
PrecompiledAddressesArbitrum []common.Address
PrecompiledContractsArbOS30 = make(map[common.Address]PrecompiledContract)
PrecompiledAddressesArbOS30 []common.Address
)
4 changes: 4 additions & 0 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) {
var precompiles map[common.Address]PrecompiledContract
switch {
case evm.chainRules.IsArbitrum:
if evm.chainRules.ArbOSVersion >= 30 {
precompiles = PrecompiledContractsArbOS30
break
}
precompiles = PrecompiledContractsArbitrum
case evm.chainRules.IsCancun:
precompiles = PrecompiledContractsCancun
Expand Down

0 comments on commit 6d749bf

Please sign in to comment.