Skip to content

Commit 198db42

Browse files
authored
Merge branch 'master' into powerslider/1779-delete-customrawdb-package
2 parents b6d83ca + ac598a8 commit 198db42

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

params/hooks_libevm.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ package params
55

66
import (
77
"fmt"
8+
"maps"
89
"math/big"
10+
"slices"
911

1012
"github.com/ava-labs/avalanchego/snow"
1113
"github.com/ava-labs/avalanchego/utils/set"
@@ -29,6 +31,9 @@ import (
2931
// (August 2nd, 2025, 04:00 UTC)
3032
const invalidateDelegateUnix = 1754107200
3133

34+
// P256VerifyAddress is the address of the p256 signature verification precompile
35+
var P256VerifyAddress = common.BytesToAddress([]byte{0x1, 0x00})
36+
3237
type RulesExtra extras.Rules
3338

3439
func GetRulesExtra(r Rules) *extras.Rules {
@@ -56,20 +61,36 @@ func (RulesExtra) CanExecuteTransaction(common.Address, *common.Address, libevm.
5661
return nil
5762
}
5863

59-
func (RulesExtra) ActivePrecompiles(existing []common.Address) []common.Address {
60-
return existing
61-
}
62-
6364
// MinimumGasConsumption is a no-op.
6465
func (RulesExtra) MinimumGasConsumption(x uint64) uint64 {
6566
return (ethparams.NOOPHooks{}).MinimumGasConsumption(x)
6667
}
6768

69+
var PrecompiledContractsGranite = map[common.Address]vm.PrecompiledContract{
70+
P256VerifyAddress: &vm.P256Verify{},
71+
}
72+
73+
func (r RulesExtra) ActivePrecompiles(existing []common.Address) []common.Address {
74+
var addresses []common.Address
75+
addresses = slices.AppendSeq(addresses, maps.Keys(r.currentPrecompiles()))
76+
addresses = append(addresses, existing...)
77+
return addresses
78+
}
79+
80+
func (r RulesExtra) currentPrecompiles() map[common.Address]vm.PrecompiledContract {
81+
switch {
82+
case r.IsGranite:
83+
return PrecompiledContractsGranite
84+
}
85+
return nil
86+
}
87+
6888
// precompileOverrideBuiltin specifies precompiles that were activated prior to the
6989
// dynamic precompile activation registry.
7090
// These were only active historically and are not active in the current network.
71-
func (RulesExtra) precompileOverrideBuiltin(common.Address) (libevm.PrecompiledContract, bool) {
72-
return nil, false
91+
func (r RulesExtra) precompileOverrideBuiltin(addr common.Address) (libevm.PrecompiledContract, bool) {
92+
precompile, ok := r.currentPrecompiles()[addr]
93+
return precompile, ok
7394
}
7495

7596
func makePrecompile(contract contract.StatefulPrecompiledContract) libevm.PrecompiledContract {
@@ -109,6 +130,7 @@ func (r RulesExtra) PrecompileOverride(addr common.Address) (libevm.PrecompiledC
109130
if p, ok := r.precompileOverrideBuiltin(addr); ok {
110131
return p, true
111132
}
133+
112134
if _, ok := r.Precompiles[addr]; !ok {
113135
return nil, false
114136
}

0 commit comments

Comments
 (0)