Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting enabled precompiles list to EVM (backport #27) #32

Merged
Merged
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ issues:
- 'func `updateSomeNodes` is unused'
- 'func `mapResolver.clear` is unused'
- 'File is not `goimports`-ed'
- 'G601: Implicit memory aliasing in for loop.'
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-alpine
FROM golang:1.21-alpine

RUN apk add bash make curl

Expand Down
98 changes: 50 additions & 48 deletions build/checksums.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,53 @@ e3d536e7873639f85353e892444f83b14cb6670603961f215986ae8e28e8e07a go1.18.5.linux
73753620602d4b4469770040c53db55e5dd6af2ad07ecc18f71f164c3224eaad go1.18.5.windows-amd64.zip
4d154626affff12ef73ea1017af0e5b52dbc839ef92f6f9e76cf4f71278a5744 go1.18.5.windows-arm64.zip

05dce78aeca810543f98aa6658b1017dc15c7a1fffc317daaaadc0b6e5095bdf golangci-lint-1.51.0-windows-386.zip
0df660139382a970da8cc06a7b86e659f8769dfda024ca2a1fd56d5b5191b21d golangci-lint-1.51.0-linux-mips64.rpm
0e61e018d5cada36f69d6c7d8f246a7dd8e35b6860037df5af9c95414cbe4827 golangci-lint-1.51.0-freebsd-armv6.tar.gz
0f526d03195fe58d1f51f505e60603af5bc53187dacac7a1cdb57b55c1a63665 golangci-lint-1.51.0-linux-loong64.rpm
0fc8ff42742dc4ffedf21e4600153fef568a0463634c14692f5e20186273c958 golangci-lint-1.51.0-linux-ppc64le.deb
22687e90476d200fb3d8b654b5830110f9e5457bf32feb1627225ae217d88b97 golangci-lint-1.51.0-linux-armv6.rpm
2493c1b84e9c49ff346c3a45d3dc0c96cfe8a4ae4ef2e679a240febe169a7a6b golangci-lint-1.51.0-linux-arm64.deb
2ca3dbaeaa03d9de0fafcbfe0aef7802a74c0d41128cbcdb6b5bcb1a32aed591 golangci-lint-1.51.0-linux-mips64le.rpm
2f54d1c5d6ba92f6f8ae18d640123732e7071396f00a6f611136394faa5862c4 golangci-lint-1.51.0-linux-armv7.tar.gz
306f3ac103f5e78434cd3b61f54b37699cccddbd60a65557d770446ea591384b golangci-lint-1.51.0-linux-mips64.tar.gz
3490390a60dfce004e49c8544d88888c0456dbbe1ad99a8ae7ef44174d0e35e7 golangci-lint-1.51.0-linux-386.rpm
38c25ae0ba5bfebd3ec42e9230547bd6461b179e47d7ba4d86950623bf28862a golangci-lint-1.51.0-linux-amd64.tar.gz
3987091b239b9870e9be0436206d8f03cec8a7a90c5b2144ddc8f9e7eaba733f golangci-lint-1.51.0-linux-386.tar.gz
426aa1ce111ab4efb5d83e67ea3a41622d4433baaf9d8e77ec6221dc1cb315d3 golangci-lint-1.51.0-linux-armv6.tar.gz
4e26d00a808b171272c411636630251656ae45540304c827aea98abaa3f24338 golangci-lint-1.51.0-linux-s390x.deb
593a27ee6f9e5d086abe0e6e37295bdbbb97c7b70e8e5ab1ff2b111385d75ecd golangci-lint-1.51.0-linux-amd64.deb
5d0159885e8ef3f314417e06db6ead336cb46907d4897d20a08635b3c36161ea golangci-lint-1.51.0-linux-riscv64.rpm
5e8173ab78c41e35903634c4e98971e2346488ea6b3dd1d58f2d3991f34d61f7 golangci-lint-1.51.0-windows-amd64.zip
5f20d3da89189818d80367f020d9b7361b607496269119ed5eb5b443465e974f golangci-lint-1.51.0-linux-s390x.tar.gz
62384a3a8e1d4c73a7ec43b2646da5656e4e8fc36652bf7100239a71fc11b44d golangci-lint-1.51.0-linux-loong64.tar.gz
62fed3649ba37fae77a685d624fe84adace34a86b727dd2ee237bdc29f5f2c17 golangci-lint-1.51.0-linux-amd64.rpm
65f4e9cc197af021abe841e4231dc1ca27dc05bdd9931532d2180e527a499619 golangci-lint-1.51.0-windows-armv6.zip
6bd74840486969d20ec7c1f7f62c7cbc13b16d2abe15956559c787af796b5876 golangci-lint-1.51.0-darwin-amd64.tar.gz
6ca62b5001751b9c80282dcd91aee9ea1a78f5fc5c86569efe99ffeb4de78051 golangci-lint-1.51.0-windows-armv7.zip
71afbc9c2e01d7fe609ce0ae7dbd9e18fc3a4fe8e24f80ab73f8a2da345133d2 golangci-lint-1.51.0-darwin-arm64.tar.gz
73f2c68f02cadeefdb4d235d1b219783ac149c38d70cbe691052d3b2665d7ff7 golangci-lint-1.51.0-netbsd-armv7.tar.gz
784ed8c10dc573f12e18dd91b6b279b06547ea672e2c26a2d9ce8abd5337347e golangci-lint-1.51.0-linux-loong64.deb
7b410ab76e6e4f2f2e6e93fdf16024cf42fcf7ff483e7674022783f6417ee596 golangci-lint-1.51.0-linux-386.deb
7b9bbd9dd271ef5f4d28b6c105e961ecfa1e3092a0d88a30bd0545f2e9c9a345 golangci-lint-1.51.0-linux-armv6.deb
8487d4441434626694608a10c1a5ad1d906cec8df761a875015d5ea15e6b15e9 golangci-lint-1.51.0-linux-arm64.tar.gz
884380ab0802d98ff34d488f30d6e1d6eedb0561ec8afc411de5e74cf1768db7 golangci-lint-1.51.0-freebsd-armv7.tar.gz
89e729542e94be38083b001be9310761cf24963a02a6027d267c645310b99730 golangci-lint-1.51.0-freebsd-386.tar.gz
934e739d348cad3064babee77c23d7f9fa699998346ac42f517a0708bbc76360 golangci-lint-1.51.0-linux-armv7.rpm
9573385a3965f6683c38cea4371d61e4fd49f76db900e4046153a4d1c29b87d1 golangci-lint-1.51.0-linux-ppc64le.tar.gz
9958f135deb31c53a336460eb2cf2dd2d9167794c22feb7f64f57c1b67fb36cc golangci-lint-1.51.0-linux-mips64le.deb
a6357781e29e106b2ebb3c41906f21f25a93cfe7e0b97a7b6fab4521060b133c golangci-lint-1.51.0-linux-mips64le.tar.gz
ad68e9723cf83e368124e5142ce1340106879493da7a595b0f11d0cceedade20 golangci-lint-1.51.0-linux-arm64.rpm
aff668f88bffb1cf56fe8d1f46f824c4f3daa79c51724fa3ef04b18c0520a6fc golangci-lint-1.51.0-linux-riscv64.deb
b2d30526e549159ad0e5db6f129ca85e89b60265cd4e76a8218e521776a109d8 golangci-lint-1.51.0-netbsd-armv6.tar.gz
b531640ad3aa7084823c630ca098626c937cbfa2190a7294e0f1207c0b053232 golangci-lint-1.51.0-windows-arm64.zip
cbecc370c1e65812cfee3eec9b17674933edc300e686c2eb4d1b613f371a279b golangci-lint-1.51.0-netbsd-amd64.tar.gz
d0a9ed6cdb29b549d68b8ecca8b71628f476f6f65ae938a873256d0d2958e4b0 golangci-lint-1.51.0-linux-riscv64.tar.gz
d0dbf2b269a2657a8112619ed0722c95212c4f05388dae420b5223462fb14e28 golangci-lint-1.51.0-freebsd-amd64.tar.gz
e6e90deccd80dbe03db06eff6cc70c140be3423e87f3e014f471fa3b5a8a2684 golangci-lint-1.51.0-netbsd-386.tar.gz
e885f3ad3f16084a01e29f35d4d97eee3d25217655dc31f545f035e1bd678000 golangci-lint-1.51.0-linux-armv7.deb
eda2c9b4f81cc37a4ebd24f6374e82b9eb9fea3859e19489e2229ff1ad212ee9 golangci-lint-1.51.0-linux-mips64.deb
fa375c169a00989f37432b24aa52628eb563707a246b697edac0c5734d81fbd4 golangci-lint-1.51.0-linux-ppc64le.rpm
fd7b5ce75c02826ffee7671df119c23d65799aa74533d25c6832d6fbba567801 golangci-lint-1.51.0-linux-s390x.rpm
83157f5378d259d51c88e310e88513bd80bd42e497974a1bbe51b82931f229c7 golangci-lint-1.57.2-darwin-amd64.tar.gz
0d6f10544fc0b5bd94b9eeb20d89646b9c19b52a98dca1ca62f94c08ac641b98 golangci-lint-1.57.2-darwin-arm64.tar.gz
4b8e83d91e05b968c33d861cd4c917533d648560e84fe30464a1e7a8aac93e49 golangci-lint-1.57.2-freebsd-386.tar.gz
eff30d840518a24f429565d7a52ebf1ac2c0c4c1680968d581b2c7116c1dc835 golangci-lint-1.57.2-freebsd-amd64.tar.gz
6ee437fc8913aafef9b8f09dd5766037ecdd13cd75cf581a0e38b61dabe82bc7 golangci-lint-1.57.2-freebsd-armv6.tar.gz
045359345ec63b81ab269391731d22739dbc6fba0fcf4adce7a214538f33118f golangci-lint-1.57.2-freebsd-armv7.tar.gz
4885b856a380717ae79edf00aa81fbbc337948fddc33bc80dada49ed5e4d85db golangci-lint-1.57.2-illumos-amd64.tar.gz
4b874eca42cd186735aae9a3f4af1b476997819ab2abec16aec0d8a52aa258da golangci-lint-1.57.2-linux-386.deb
43ca7476fa18dbadc8cb7d4827a81a96cf5799e8ad0b60d734d23367e3f84a9d golangci-lint-1.57.2-linux-386.rpm
51694b9b9da783f70fb4060403cd476f7e77509bbbfeda222994a0ec3c43a8f8 golangci-lint-1.57.2-linux-386.tar.gz
a7b811e93c4fe6be45f862806ec121b38dbe36b81f877a6bd3f728baabce1c06 golangci-lint-1.57.2-linux-amd64.deb
4639fc82a8baad59efffbc1e7f4048b7e5e2d580d70017a0c39aaddd0c669a13 golangci-lint-1.57.2-linux-amd64.rpm
391483daa5d58d037832ba2fac709fdb5df0c67471c0d7698d1f67cbfa5f10f0 golangci-lint-1.57.2-linux-amd64.tar.gz
80deed46f7354eec109808a48fbde7232578baf52530fcf2e2f708a0daca1bd0 golangci-lint-1.57.2-linux-arm64.deb
36d61363268a3ceeae7467e34887b36813467d426123962b4e6655f502c02fe6 golangci-lint-1.57.2-linux-arm64.rpm
9e079e19b3d81e357d2acc90518c6a86a533e26a74af1e5eadf8dfcd640b66ee golangci-lint-1.57.2-linux-arm64.tar.gz
c71a28a34084826d556ada999b759f1c7016da1d293f9db3e6e6d0ed00004aea golangci-lint-1.57.2-linux-armv6.deb
ee6a61d8fd49fcf0f75263640dbfeee4b3ff0bb39e1247ba2ae3601ae8006f6c golangci-lint-1.57.2-linux-armv6.rpm
0a22ab5885803dda31f285581cdf281efe773da0be9b7ea316be416e30c012dc golangci-lint-1.57.2-linux-armv6.tar.gz
62942bf5d9acb4ad9e461be606e8ce433d0b58b2bbc61d55d6c434d927513557 golangci-lint-1.57.2-linux-armv7.deb
f2498cf873f8e92e4469516696549490b99c92649eba634d3e693ed75252e85f golangci-lint-1.57.2-linux-armv7.rpm
c1d99d122e4ec1c087f6eab1f8776b6406e284882977c57b806470207c1b85f6 golangci-lint-1.57.2-linux-armv7.tar.gz
ac21b7903ac421f7ebb62a71a110d77874ab813878bcda5ce34f2d8642aed90a golangci-lint-1.57.2-linux-loong64.deb
5dba8379a25c183c5e3524af9d5cd4a684ee305bb7173fe337f048604ed88888 golangci-lint-1.57.2-linux-loong64.rpm
bc2b63bf57ab5398e84352df24e3088791f974d53fcd9fb683955146430de3cc golangci-lint-1.57.2-linux-loong64.tar.gz
66973457d9b0b3251d76b455b3f2d64895f655d4d602ed66c285227509768b37 golangci-lint-1.57.2-linux-mips64.deb
6b3a0b987c1d207de2689bdb86cb21e74e7ddffff954a9882141018609c2431c golangci-lint-1.57.2-linux-mips64.rpm
12a386657b3eace4d6a2bae1bd0ca1c58e0098bdd0e621296b37fcfb9b4c91bb golangci-lint-1.57.2-linux-mips64.tar.gz
2dbcd6918abf2da190ec5f3fcbfde81a42f4685f0e1f7a6758abfad3010d7646 golangci-lint-1.57.2-linux-mips64le.deb
9489933a329ce30a54b230cc6d90d7b9b409c6f2905af99747bed7c9115edb8c golangci-lint-1.57.2-linux-mips64le.rpm
d813cc9d5688f8170f8695d6468cf5b4995b401ee8270834d5fc333f5e2cce05 golangci-lint-1.57.2-linux-mips64le.tar.gz
da8f59eb18eb478f9b782d2a844674d827fc31b92df0cae581d99b69d5a26226 golangci-lint-1.57.2-linux-ppc64le.deb
b371a14c364978bfb71b86c1a3e5e951dbb5b4ab9ee14a184fadb024a59cd490 golangci-lint-1.57.2-linux-ppc64le.rpm
36084ebd725fb046e1c956f823b2c57b49781f41df0592501cfb5eb5d315b6c5 golangci-lint-1.57.2-linux-ppc64le.tar.gz
73936770432d10f7a5aefa86049382bc554f07cae035e79d515d754c77bdd3d5 golangci-lint-1.57.2-linux-riscv64.deb
4f4407bb197e1fd6db04187aaf2671faf94dc1764822248fefbedf025691705c golangci-lint-1.57.2-linux-riscv64.rpm
240b6b406d21d24a3041927aa39094c8d2fc2c7c6723e295b7f2d9d59c6e245b golangci-lint-1.57.2-linux-riscv64.tar.gz
486887715432f177fb1b795f9656e3338a18400a3b63f9e0c0ca9aae7ce91182 golangci-lint-1.57.2-linux-s390x.deb
8af126c8319d59dc3892a67df5ae10a51afef8fe5724906e8e340122384355a6 golangci-lint-1.57.2-linux-s390x.rpm
aede4a55e49f46d50c1ea6d21a093834faea33e80ab9c641833b29f53a030695 golangci-lint-1.57.2-linux-s390x.tar.gz
b47561dd99d8fc5aadffc629196f753a37f7eb33fa88d1f869e576cfe0c78b6f golangci-lint-1.57.2-netbsd-386.tar.gz
f19bb6886f7e47539f4d06844e4ba9be8af4ae3aff7b7118e7f0ac0b7c0fb34b golangci-lint-1.57.2-netbsd-amd64.tar.gz
65d3c14d46d205f3d1b2159b153ae93ee4a455a490605eda0935fb2ec8929f1a golangci-lint-1.57.2-netbsd-armv6.tar.gz
f975b1910afae5166598254319c2eb6231143a7cb63816df1bc193bdac3451a2 golangci-lint-1.57.2-netbsd-armv7.tar.gz
621326544b0fec6d4a7569bc504850dc7bf33b011ecef34ae6c292a5b24acd02 golangci-lint-1.57.2-source.tar.gz
95321b1ec07db22e29538d0b18d36a376ca7d834c4826351db2b73436d27f7c1 golangci-lint-1.57.2-windows-386.zip
10c1ab7eb4a99f8b292a8f910bc78a50e9547a4ffe7444fcddc68f722adf6612 golangci-lint-1.57.2-windows-amd64.zip
f88ac03faa185da6547beab8a91983db2767e2e154323518f592f7e24772ca9e golangci-lint-1.57.2-windows-arm64.zip
1c2c738d241be1091cebf119d38758d51d56b5a02bbe410979545e51dc39cf70 golangci-lint-1.57.2-windows-armv6.zip
88acd5987fb883ac56c46a78d804595ab5fb26be9b0b253bfb397d7838df3f78 golangci-lint-1.57.2-windows-armv7.zip
2 changes: 1 addition & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func doLint(cmdline []string) {

// downloadLinter downloads and unpacks golangci-lint.
func downloadLinter(cachedir string) string {
const version = "1.51.0"
const version = "1.57.2"

csdb := build.MustLoadChecksums("build/checksums.txt")
arch := runtime.GOARCH
Expand Down
81 changes: 0 additions & 81 deletions contracts/test/sum3.ts

This file was deleted.

32 changes: 24 additions & 8 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package vm

import (
"math/big"
"slices"
"sync/atomic"
"time"

Expand Down Expand Up @@ -56,13 +57,16 @@ func (evm *EVM) precompile(addr common.Address) (contract.StatefulPrecompiledCon
precompiles = PrecompiledContractsHomestead
}

// Check the existing precompiles first
// Check the native stateless precompiles first
p, ok := precompiles[addr]
if ok {
return p, true
}

// Otherwise, check for the additionally configured precompiles.
// Otherwise, check for the additionally configured stateful precompiles
if !evm.isStatefulPrecompileEnabled(addr) {
return nil, false
}
module, ok := modules.GetPrecompileModuleByAddress(addr)
if !ok {
return nil, false
Expand All @@ -71,6 +75,11 @@ func (evm *EVM) precompile(addr common.Address) (contract.StatefulPrecompiledCon
return module.Contract, true
}

// isStatefulPrecompileEnabled checks if stateful precompile is enabled at current block height
func (evm *EVM) isStatefulPrecompileEnabled(addr common.Address) bool {
return slices.Contains(evm.enabledPrecompiles, addr)
}

// BlockContext provides the EVM with auxiliary information. Once provided
// it shouldn't be modified.
type BlockContext struct {
Expand Down Expand Up @@ -135,18 +144,25 @@ type EVM struct {
// available gas is calculated in gasCall* according to the 63/64 rule and later
// applied in opCall*.
callGasTemp uint64

enabledPrecompiles []common.Address
}

// NewEVM returns a new EVM. The returned EVM is not thread safe and should
// only ever be used *once*.
func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig *params.ChainConfig, config Config) *EVM {
return NewEVMWithEnabledPrecompiles(blockCtx, txCtx, statedb, chainConfig, config, nil)
}

func NewEVMWithEnabledPrecompiles(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig *params.ChainConfig, config Config, enabledPrecompiles []common.Address) *EVM {
evm := &EVM{
Context: blockCtx,
TxContext: txCtx,
StateDB: statedb,
Config: config,
chainConfig: chainConfig,
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil),
Context: blockCtx,
TxContext: txCtx,
StateDB: statedb,
Config: config,
chainConfig: chainConfig,
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil),
enabledPrecompiles: enabledPrecompiles,
}
evm.interpreter = NewEVMInterpreter(evm, config)
return evm
Expand Down
Loading
Loading