diff --git a/core/vm/contracts.go b/core/vm/contracts.go index d9147aaf22a9..628d73a437ee 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -110,7 +110,22 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{18}): &bls12381MapG2{}, } +var PrecompiledContractsDanksharding = map[common.Address]PrecompiledContract{ + common.BytesToAddress([]byte{1}): &ecrecover{}, + common.BytesToAddress([]byte{2}): &sha256hash{}, + common.BytesToAddress([]byte{3}): &ripemd160hash{}, + common.BytesToAddress([]byte{4}): &dataCopy{}, + common.BytesToAddress([]byte{5}): &bigModExp{eip2565: true}, + common.BytesToAddress([]byte{6}): &bn256AddIstanbul{}, + common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{}, + common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{}, + common.BytesToAddress([]byte{9}): &blake2F{}, + common.BytesToAddress([]byte{20}): &pointEvaluation{}, +} + + var ( + PrecompiledAddressesDanksharding []common.Address PrecompiledAddressesBerlin []common.Address PrecompiledAddressesIstanbul []common.Address PrecompiledAddressesByzantium []common.Address @@ -130,11 +145,16 @@ func init() { for k := range PrecompiledContractsBerlin { PrecompiledAddressesBerlin = append(PrecompiledAddressesBerlin, k) } + for k := range PrecompiledContractsDanksharding { + PrecompiledAddressesDanksharding = append(PrecompiledAddressesDanksharding , k) + } } // ActivePrecompiles returns the precompiles enabled with the current configuration. func ActivePrecompiles(rules params.Rules) []common.Address { switch { + case rules.IsSharding: + return PrecompiledAddressesDanksharding case rules.IsBerlin: return PrecompiledAddressesBerlin case rules.IsIstanbul: diff --git a/core/vm/evm.go b/core/vm/evm.go index fcf5d75dbde3..3141582d23be 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -44,6 +44,8 @@ type ( func (evm *EVM) precompile(addr common.Address) (PrecompiledContract, bool) { var precompiles map[common.Address]PrecompiledContract switch { + case evm.chainRules.IsSharding: + precompiles = PrecompiledContractsDanksharding case evm.chainRules.IsBerlin: precompiles = PrecompiledContractsBerlin case evm.chainRules.IsIstanbul: