From ec76f252f39f30171c059605843c76ce4afdfb0b Mon Sep 17 00:00:00 2001 From: katsumata <12413150+winor30@users.noreply.github.com> Date: Tue, 27 May 2025 00:36:12 +0900 Subject: [PATCH] vm: use PrecompiledContracts type alias for consistency Replace raw map[common.Address]PrecompiledContract type declarations with PrecompiledContracts type alias in variable declarations and struct fields for improved code consistency and readability. Signed-off-by: katsumata <12413150+winor30@users.noreply.github.com> --- core/vm/contracts.go | 6 +++--- core/vm/contracts_test.go | 2 +- core/vm/evm.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 0daa8f1645..6501b75440 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -144,7 +144,7 @@ var PrecompiledContractsVerkle = PrecompiledContractsPrague // PrecompiledContractsFjord contains the default set of pre-compiled Ethereum // contracts used in the Fjord release. -var PrecompiledContractsFjord = map[common.Address]PrecompiledContract{ +var PrecompiledContractsFjord = PrecompiledContracts{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, @@ -160,7 +160,7 @@ var PrecompiledContractsFjord = map[common.Address]PrecompiledContract{ // PrecompiledContractsGranite contains the default set of pre-compiled Ethereum // contracts used in the Granite release. -var PrecompiledContractsGranite = map[common.Address]PrecompiledContract{ +var PrecompiledContractsGranite = PrecompiledContracts{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, @@ -174,7 +174,7 @@ var PrecompiledContractsGranite = map[common.Address]PrecompiledContract{ common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{}, } -var PrecompiledContractsIsthmus = map[common.Address]PrecompiledContract{ +var PrecompiledContractsIsthmus = PrecompiledContracts{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, diff --git a/core/vm/contracts_test.go b/core/vm/contracts_test.go index cd7803526c..777ca7cb02 100644 --- a/core/vm/contracts_test.go +++ b/core/vm/contracts_test.go @@ -46,7 +46,7 @@ type precompiledFailureTest struct { // allPrecompiles does not map to the actual set of precompiles, as it also contains // repriced versions of precompiles at certain slots -var allPrecompiles = map[common.Address]PrecompiledContract{ +var allPrecompiles = PrecompiledContracts{ common.BytesToAddress([]byte{1}): &ecrecover{}, common.BytesToAddress([]byte{2}): &sha256hash{}, common.BytesToAddress([]byte{3}): &ripemd160hash{}, diff --git a/core/vm/evm.go b/core/vm/evm.go index 73ce5b811e..347ed53ca4 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -128,7 +128,7 @@ type EVM struct { callGasTemp uint64 // precompiles holds the precompiled contracts for the current epoch - precompiles map[common.Address]PrecompiledContract + precompiles PrecompiledContracts // jumpDests is the aggregated result of JUMPDEST analysis made through // the life cycle of EVM.