Skip to content

Commit

Permalink
Fix precompile overrides
Browse files Browse the repository at this point in the history
The overrides always have to be applied first. With the old code, only
exiting precompiles could be overridden.
  • Loading branch information
karlb committed Sep 13, 2024
1 parent c19ca14 commit ca15b5f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,24 @@ func (evm *EVM) precompile(addr common.Address) (CeloPrecompiledContract, bool)
precompiles = PrecompiledContractsHomestead
}
p, ok := precompiles[addr]
if evm.Config.PrecompileOverrides != nil {
override := evm.Config.PrecompileOverrides(evm.chainRules, p, addr)
p = override
ok = override != nil
}

var cp CeloPrecompiledContract
if !ok {
if ok {
cp = &wrap{p}
} else {
var celoPrecompiles map[common.Address]CeloPrecompiledContract
switch {
case evm.chainRules.IsCel2:
celoPrecompiles = PrecompiledCeloContractsCel2
}
cp, ok = celoPrecompiles[addr]
} else {
if evm.Config.PrecompileOverrides != nil {
override := evm.Config.PrecompileOverrides(evm.chainRules, p, addr)
return &wrap{override}, override != nil
} else {
cp = &wrap{p}
}
}

return cp, ok
}

Expand Down

0 comments on commit ca15b5f

Please sign in to comment.