@feelyourprotocol/evm 8141.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/README.md +690 -0
- package/dist/cjs/binaryTreeAccessWitness.d.ts +61 -0
- package/dist/cjs/binaryTreeAccessWitness.d.ts.map +1 -0
- package/dist/cjs/binaryTreeAccessWitness.js +314 -0
- package/dist/cjs/binaryTreeAccessWitness.js.map +1 -0
- package/dist/cjs/chunkCache.d.ts +13 -0
- package/dist/cjs/chunkCache.d.ts.map +1 -0
- package/dist/cjs/chunkCache.js +30 -0
- package/dist/cjs/chunkCache.js.map +1 -0
- package/dist/cjs/constructors.d.ts +11 -0
- package/dist/cjs/constructors.d.ts.map +1 -0
- package/dist/cjs/constructors.js +30 -0
- package/dist/cjs/constructors.js.map +1 -0
- package/dist/cjs/eip7708.d.ts +24 -0
- package/dist/cjs/eip7708.d.ts.map +1 -0
- package/dist/cjs/eip7708.js +37 -0
- package/dist/cjs/eip7708.js.map +1 -0
- package/dist/cjs/eof/constants.d.ts +22 -0
- package/dist/cjs/eof/constants.d.ts.map +1 -0
- package/dist/cjs/eof/constants.js +31 -0
- package/dist/cjs/eof/constants.js.map +1 -0
- package/dist/cjs/eof/container.d.ts +87 -0
- package/dist/cjs/eof/container.d.ts.map +1 -0
- package/dist/cjs/eof/container.js +380 -0
- package/dist/cjs/eof/container.js.map +1 -0
- package/dist/cjs/eof/errors.d.ts +66 -0
- package/dist/cjs/eof/errors.d.ts.map +1 -0
- package/dist/cjs/eof/errors.js +200 -0
- package/dist/cjs/eof/errors.js.map +1 -0
- package/dist/cjs/eof/setup.d.ts +9 -0
- package/dist/cjs/eof/setup.d.ts.map +1 -0
- package/dist/cjs/eof/setup.js +26 -0
- package/dist/cjs/eof/setup.js.map +1 -0
- package/dist/cjs/eof/stackDelta.d.ts +10 -0
- package/dist/cjs/eof/stackDelta.d.ts.map +1 -0
- package/dist/cjs/eof/stackDelta.js +164 -0
- package/dist/cjs/eof/stackDelta.js.map +1 -0
- package/dist/cjs/eof/util.d.ts +8 -0
- package/dist/cjs/eof/util.d.ts.map +1 -0
- package/dist/cjs/eof/util.js +18 -0
- package/dist/cjs/eof/util.js.map +1 -0
- package/dist/cjs/eof/verify.d.ts +38 -0
- package/dist/cjs/eof/verify.d.ts.map +1 -0
- package/dist/cjs/eof/verify.js +436 -0
- package/dist/cjs/eof/verify.js.map +1 -0
- package/dist/cjs/errors.d.ts +40 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +43 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/evm.d.ts +181 -0
- package/dist/cjs/evm.d.ts.map +1 -0
- package/dist/cjs/evm.js +1142 -0
- package/dist/cjs/evm.js.map +1 -0
- package/dist/cjs/frameContext.d.ts +50 -0
- package/dist/cjs/frameContext.d.ts.map +1 -0
- package/dist/cjs/frameContext.js +17 -0
- package/dist/cjs/frameContext.js.map +1 -0
- package/dist/cjs/index.d.ts +18 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +43 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interpreter.d.ts +361 -0
- package/dist/cjs/interpreter.d.ts.map +1 -0
- package/dist/cjs/interpreter.js +1057 -0
- package/dist/cjs/interpreter.js.map +1 -0
- package/dist/cjs/journal.d.ts +69 -0
- package/dist/cjs/journal.d.ts.map +1 -0
- package/dist/cjs/journal.js +247 -0
- package/dist/cjs/journal.js.map +1 -0
- package/dist/cjs/logger.d.ts +38 -0
- package/dist/cjs/logger.d.ts.map +1 -0
- package/dist/cjs/logger.js +126 -0
- package/dist/cjs/logger.js.map +1 -0
- package/dist/cjs/memory.d.ts +29 -0
- package/dist/cjs/memory.d.ts.map +1 -0
- package/dist/cjs/memory.js +75 -0
- package/dist/cjs/memory.js.map +1 -0
- package/dist/cjs/message.d.ts +70 -0
- package/dist/cjs/message.d.ts.map +1 -0
- package/dist/cjs/message.js +51 -0
- package/dist/cjs/message.js.map +1 -0
- package/dist/cjs/opcodes/EIP1283.d.ts +13 -0
- package/dist/cjs/opcodes/EIP1283.d.ts.map +1 -0
- package/dist/cjs/opcodes/EIP1283.js +58 -0
- package/dist/cjs/opcodes/EIP1283.js.map +1 -0
- package/dist/cjs/opcodes/EIP2200.d.ts +13 -0
- package/dist/cjs/opcodes/EIP2200.d.ts.map +1 -0
- package/dist/cjs/opcodes/EIP2200.js +64 -0
- package/dist/cjs/opcodes/EIP2200.js.map +1 -0
- package/dist/cjs/opcodes/EIP2929.d.ts +68 -0
- package/dist/cjs/opcodes/EIP2929.d.ts.map +1 -0
- package/dist/cjs/opcodes/EIP2929.js +146 -0
- package/dist/cjs/opcodes/EIP2929.js.map +1 -0
- package/dist/cjs/opcodes/codes.d.ts +45 -0
- package/dist/cjs/opcodes/codes.d.ts.map +1 -0
- package/dist/cjs/opcodes/codes.js +453 -0
- package/dist/cjs/opcodes/codes.js.map +1 -0
- package/dist/cjs/opcodes/functions.d.ts +11 -0
- package/dist/cjs/opcodes/functions.d.ts.map +1 -0
- package/dist/cjs/opcodes/functions.js +1778 -0
- package/dist/cjs/opcodes/functions.js.map +1 -0
- package/dist/cjs/opcodes/gas.d.ts +15 -0
- package/dist/cjs/opcodes/gas.d.ts.map +1 -0
- package/dist/cjs/opcodes/gas.js +1016 -0
- package/dist/cjs/opcodes/gas.js.map +1 -0
- package/dist/cjs/opcodes/index.d.ts +4 -0
- package/dist/cjs/opcodes/index.d.ts.map +1 -0
- package/dist/cjs/opcodes/index.js +20 -0
- package/dist/cjs/opcodes/index.js.map +1 -0
- package/dist/cjs/opcodes/util.d.ts +86 -0
- package/dist/cjs/opcodes/util.d.ts.map +1 -0
- package/dist/cjs/opcodes/util.js +281 -0
- package/dist/cjs/opcodes/util.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/params.d.ts +3 -0
- package/dist/cjs/params.d.ts.map +1 -0
- package/dist/cjs/params.js +424 -0
- package/dist/cjs/params.js.map +1 -0
- package/dist/cjs/precompiles/01-ecrecover.d.ts +4 -0
- package/dist/cjs/precompiles/01-ecrecover.d.ts.map +1 -0
- package/dist/cjs/precompiles/01-ecrecover.js +58 -0
- package/dist/cjs/precompiles/01-ecrecover.js.map +1 -0
- package/dist/cjs/precompiles/02-sha256.d.ts +4 -0
- package/dist/cjs/precompiles/02-sha256.d.ts.map +1 -0
- package/dist/cjs/precompiles/02-sha256.js +27 -0
- package/dist/cjs/precompiles/02-sha256.js.map +1 -0
- package/dist/cjs/precompiles/03-ripemd160.d.ts +4 -0
- package/dist/cjs/precompiles/03-ripemd160.d.ts.map +1 -0
- package/dist/cjs/precompiles/03-ripemd160.js +26 -0
- package/dist/cjs/precompiles/03-ripemd160.js.map +1 -0
- package/dist/cjs/precompiles/04-identity.d.ts +4 -0
- package/dist/cjs/precompiles/04-identity.d.ts.map +1 -0
- package/dist/cjs/precompiles/04-identity.js +24 -0
- package/dist/cjs/precompiles/04-identity.js.map +1 -0
- package/dist/cjs/precompiles/05-modexp.d.ts +5 -0
- package/dist/cjs/precompiles/05-modexp.d.ts.map +1 -0
- package/dist/cjs/precompiles/05-modexp.js +185 -0
- package/dist/cjs/precompiles/05-modexp.js.map +1 -0
- package/dist/cjs/precompiles/06-bn254-add.d.ts +4 -0
- package/dist/cjs/precompiles/06-bn254-add.d.ts.map +1 -0
- package/dist/cjs/precompiles/06-bn254-add.js +42 -0
- package/dist/cjs/precompiles/06-bn254-add.js.map +1 -0
- package/dist/cjs/precompiles/07-bn254-mul.d.ts +4 -0
- package/dist/cjs/precompiles/07-bn254-mul.d.ts.map +1 -0
- package/dist/cjs/precompiles/07-bn254-mul.js +43 -0
- package/dist/cjs/precompiles/07-bn254-mul.js.map +1 -0
- package/dist/cjs/precompiles/08-bn254-pairing.d.ts +4 -0
- package/dist/cjs/precompiles/08-bn254-pairing.d.ts.map +1 -0
- package/dist/cjs/precompiles/08-bn254-pairing.js +45 -0
- package/dist/cjs/precompiles/08-bn254-pairing.js.map +1 -0
- package/dist/cjs/precompiles/09-blake2f.d.ts +5 -0
- package/dist/cjs/precompiles/09-blake2f.d.ts.map +1 -0
- package/dist/cjs/precompiles/09-blake2f.js +201 -0
- package/dist/cjs/precompiles/09-blake2f.js.map +1 -0
- package/dist/cjs/precompiles/0a-kzg-point-evaluation.d.ts +5 -0
- package/dist/cjs/precompiles/0a-kzg-point-evaluation.d.ts.map +1 -0
- package/dist/cjs/precompiles/0a-kzg-point-evaluation.js +68 -0
- package/dist/cjs/precompiles/0a-kzg-point-evaluation.js.map +1 -0
- package/dist/cjs/precompiles/0b-bls12-g1add.d.ts +4 -0
- package/dist/cjs/precompiles/0b-bls12-g1add.d.ts.map +1 -0
- package/dist/cjs/precompiles/0b-bls12-g1add.js +49 -0
- package/dist/cjs/precompiles/0b-bls12-g1add.js.map +1 -0
- package/dist/cjs/precompiles/0c-bls12-g1msm.d.ts +4 -0
- package/dist/cjs/precompiles/0c-bls12-g1msm.d.ts.map +1 -0
- package/dist/cjs/precompiles/0c-bls12-g1msm.js +62 -0
- package/dist/cjs/precompiles/0c-bls12-g1msm.js.map +1 -0
- package/dist/cjs/precompiles/0d-bls12-g2add.d.ts +4 -0
- package/dist/cjs/precompiles/0d-bls12-g2add.d.ts.map +1 -0
- package/dist/cjs/precompiles/0d-bls12-g2add.js +51 -0
- package/dist/cjs/precompiles/0d-bls12-g2add.js.map +1 -0
- package/dist/cjs/precompiles/0e-bls12-g2msm.d.ts +4 -0
- package/dist/cjs/precompiles/0e-bls12-g2msm.d.ts.map +1 -0
- package/dist/cjs/precompiles/0e-bls12-g2msm.js +60 -0
- package/dist/cjs/precompiles/0e-bls12-g2msm.js.map +1 -0
- package/dist/cjs/precompiles/0f-bls12-pairing.d.ts +4 -0
- package/dist/cjs/precompiles/0f-bls12-pairing.d.ts.map +1 -0
- package/dist/cjs/precompiles/0f-bls12-pairing.js +66 -0
- package/dist/cjs/precompiles/0f-bls12-pairing.js.map +1 -0
- package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.d.ts +4 -0
- package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.d.ts.map +1 -0
- package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.js +44 -0
- package/dist/cjs/precompiles/10-bls12-map-fp-to-g1.js.map +1 -0
- package/dist/cjs/precompiles/100-p256verify.d.ts +4 -0
- package/dist/cjs/precompiles/100-p256verify.d.ts.map +1 -0
- package/dist/cjs/precompiles/100-p256verify.js +131 -0
- package/dist/cjs/precompiles/100-p256verify.js.map +1 -0
- package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.d.ts +4 -0
- package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.d.ts.map +1 -0
- package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.js +47 -0
- package/dist/cjs/precompiles/11-bls12-map-fp2-to-g2.js.map +1 -0
- package/dist/cjs/precompiles/bls12_381/constants.d.ts +10 -0
- package/dist/cjs/precompiles/bls12_381/constants.d.ts.map +1 -0
- package/dist/cjs/precompiles/bls12_381/constants.js +274 -0
- package/dist/cjs/precompiles/bls12_381/constants.js.map +1 -0
- package/dist/cjs/precompiles/bls12_381/index.d.ts +5 -0
- package/dist/cjs/precompiles/bls12_381/index.d.ts.map +1 -0
- package/dist/cjs/precompiles/bls12_381/index.js +24 -0
- package/dist/cjs/precompiles/bls12_381/index.js.map +1 -0
- package/dist/cjs/precompiles/bls12_381/mcl.d.ts +45 -0
- package/dist/cjs/precompiles/bls12_381/mcl.d.ts.map +1 -0
- package/dist/cjs/precompiles/bls12_381/mcl.js +264 -0
- package/dist/cjs/precompiles/bls12_381/mcl.js.map +1 -0
- package/dist/cjs/precompiles/bls12_381/noble.d.ts +39 -0
- package/dist/cjs/precompiles/bls12_381/noble.d.ts.map +1 -0
- package/dist/cjs/precompiles/bls12_381/noble.js +228 -0
- package/dist/cjs/precompiles/bls12_381/noble.js.map +1 -0
- package/dist/cjs/precompiles/bls12_381/util.d.ts +35 -0
- package/dist/cjs/precompiles/bls12_381/util.d.ts.map +1 -0
- package/dist/cjs/precompiles/bls12_381/util.js +68 -0
- package/dist/cjs/precompiles/bls12_381/util.js.map +1 -0
- package/dist/cjs/precompiles/bn254/index.d.ts +3 -0
- package/dist/cjs/precompiles/bn254/index.d.ts.map +1 -0
- package/dist/cjs/precompiles/bn254/index.js +8 -0
- package/dist/cjs/precompiles/bn254/index.js.map +1 -0
- package/dist/cjs/precompiles/bn254/noble.d.ts +13 -0
- package/dist/cjs/precompiles/bn254/noble.d.ts.map +1 -0
- package/dist/cjs/precompiles/bn254/noble.js +124 -0
- package/dist/cjs/precompiles/bn254/noble.js.map +1 -0
- package/dist/cjs/precompiles/bn254/rustbn.d.ts +16 -0
- package/dist/cjs/precompiles/bn254/rustbn.d.ts.map +1 -0
- package/dist/cjs/precompiles/bn254/rustbn.js +33 -0
- package/dist/cjs/precompiles/bn254/rustbn.js.map +1 -0
- package/dist/cjs/precompiles/index.d.ts +67 -0
- package/dist/cjs/precompiles/index.d.ts.map +1 -0
- package/dist/cjs/precompiles/index.js +262 -0
- package/dist/cjs/precompiles/index.js.map +1 -0
- package/dist/cjs/precompiles/types.d.ts +13 -0
- package/dist/cjs/precompiles/types.d.ts.map +1 -0
- package/dist/cjs/precompiles/types.js +3 -0
- package/dist/cjs/precompiles/types.js.map +1 -0
- package/dist/cjs/precompiles/util.d.ts +30 -0
- package/dist/cjs/precompiles/util.d.ts.map +1 -0
- package/dist/cjs/precompiles/util.js +63 -0
- package/dist/cjs/precompiles/util.js.map +1 -0
- package/dist/cjs/stack.d.ts +55 -0
- package/dist/cjs/stack.d.ts.map +1 -0
- package/dist/cjs/stack.js +143 -0
- package/dist/cjs/stack.js.map +1 -0
- package/dist/cjs/stemCache.d.ts +20 -0
- package/dist/cjs/stemCache.d.ts.map +1 -0
- package/dist/cjs/stemCache.js +37 -0
- package/dist/cjs/stemCache.js.map +1 -0
- package/dist/cjs/transientStorage.d.ts +54 -0
- package/dist/cjs/transientStorage.d.ts.map +1 -0
- package/dist/cjs/transientStorage.js +113 -0
- package/dist/cjs/transientStorage.js.map +1 -0
- package/dist/cjs/types.d.ts +465 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +28 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/binaryTreeAccessWitness.d.ts +61 -0
- package/dist/esm/binaryTreeAccessWitness.d.ts.map +1 -0
- package/dist/esm/binaryTreeAccessWitness.js +308 -0
- package/dist/esm/binaryTreeAccessWitness.js.map +1 -0
- package/dist/esm/chunkCache.d.ts +13 -0
- package/dist/esm/chunkCache.d.ts.map +1 -0
- package/dist/esm/chunkCache.js +26 -0
- package/dist/esm/chunkCache.js.map +1 -0
- package/dist/esm/constructors.d.ts +11 -0
- package/dist/esm/constructors.d.ts.map +1 -0
- package/dist/esm/constructors.js +27 -0
- package/dist/esm/constructors.js.map +1 -0
- package/dist/esm/eip7708.d.ts +24 -0
- package/dist/esm/eip7708.d.ts.map +1 -0
- package/dist/esm/eip7708.js +32 -0
- package/dist/esm/eip7708.js.map +1 -0
- package/dist/esm/eof/constants.d.ts +22 -0
- package/dist/esm/eof/constants.d.ts.map +1 -0
- package/dist/esm/eof/constants.js +28 -0
- package/dist/esm/eof/constants.js.map +1 -0
- package/dist/esm/eof/container.d.ts +87 -0
- package/dist/esm/eof/container.d.ts.map +1 -0
- package/dist/esm/eof/container.js +375 -0
- package/dist/esm/eof/container.js.map +1 -0
- package/dist/esm/eof/errors.d.ts +66 -0
- package/dist/esm/eof/errors.d.ts.map +1 -0
- package/dist/esm/eof/errors.js +195 -0
- package/dist/esm/eof/errors.js.map +1 -0
- package/dist/esm/eof/setup.d.ts +9 -0
- package/dist/esm/eof/setup.d.ts.map +1 -0
- package/dist/esm/eof/setup.js +23 -0
- package/dist/esm/eof/setup.js.map +1 -0
- package/dist/esm/eof/stackDelta.d.ts +10 -0
- package/dist/esm/eof/stackDelta.d.ts.map +1 -0
- package/dist/esm/eof/stackDelta.js +161 -0
- package/dist/esm/eof/stackDelta.js.map +1 -0
- package/dist/esm/eof/util.d.ts +8 -0
- package/dist/esm/eof/util.d.ts.map +1 -0
- package/dist/esm/eof/util.js +14 -0
- package/dist/esm/eof/util.js.map +1 -0
- package/dist/esm/eof/verify.d.ts +38 -0
- package/dist/esm/eof/verify.d.ts.map +1 -0
- package/dist/esm/eof/verify.js +432 -0
- package/dist/esm/eof/verify.js.map +1 -0
- package/dist/esm/errors.d.ts +40 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +39 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/evm.d.ts +181 -0
- package/dist/esm/evm.d.ts.map +1 -0
- package/dist/esm/evm.js +1131 -0
- package/dist/esm/evm.js.map +1 -0
- package/dist/esm/frameContext.d.ts +50 -0
- package/dist/esm/frameContext.d.ts.map +1 -0
- package/dist/esm/frameContext.js +14 -0
- package/dist/esm/frameContext.js.map +1 -0
- package/dist/esm/index.d.ts +18 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interpreter.d.ts +361 -0
- package/dist/esm/interpreter.d.ts.map +1 -0
- package/dist/esm/interpreter.js +1054 -0
- package/dist/esm/interpreter.js.map +1 -0
- package/dist/esm/journal.d.ts +69 -0
- package/dist/esm/journal.d.ts.map +1 -0
- package/dist/esm/journal.js +243 -0
- package/dist/esm/journal.js.map +1 -0
- package/dist/esm/logger.d.ts +38 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/logger.js +121 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/memory.d.ts +29 -0
- package/dist/esm/memory.d.ts.map +1 -0
- package/dist/esm/memory.js +71 -0
- package/dist/esm/memory.js.map +1 -0
- package/dist/esm/message.d.ts +70 -0
- package/dist/esm/message.d.ts.map +1 -0
- package/dist/esm/message.js +47 -0
- package/dist/esm/message.js.map +1 -0
- package/dist/esm/opcodes/EIP1283.d.ts +13 -0
- package/dist/esm/opcodes/EIP1283.d.ts.map +1 -0
- package/dist/esm/opcodes/EIP1283.js +55 -0
- package/dist/esm/opcodes/EIP1283.js.map +1 -0
- package/dist/esm/opcodes/EIP2200.d.ts +13 -0
- package/dist/esm/opcodes/EIP2200.d.ts.map +1 -0
- package/dist/esm/opcodes/EIP2200.js +61 -0
- package/dist/esm/opcodes/EIP2200.js.map +1 -0
- package/dist/esm/opcodes/EIP2929.d.ts +68 -0
- package/dist/esm/opcodes/EIP2929.d.ts.map +1 -0
- package/dist/esm/opcodes/EIP2929.js +138 -0
- package/dist/esm/opcodes/EIP2929.js.map +1 -0
- package/dist/esm/opcodes/codes.d.ts +45 -0
- package/dist/esm/opcodes/codes.d.ts.map +1 -0
- package/dist/esm/opcodes/codes.js +448 -0
- package/dist/esm/opcodes/codes.js.map +1 -0
- package/dist/esm/opcodes/functions.d.ts +11 -0
- package/dist/esm/opcodes/functions.d.ts.map +1 -0
- package/dist/esm/opcodes/functions.js +1775 -0
- package/dist/esm/opcodes/functions.js.map +1 -0
- package/dist/esm/opcodes/gas.d.ts +15 -0
- package/dist/esm/opcodes/gas.d.ts.map +1 -0
- package/dist/esm/opcodes/gas.js +1013 -0
- package/dist/esm/opcodes/gas.js.map +1 -0
- package/dist/esm/opcodes/index.d.ts +4 -0
- package/dist/esm/opcodes/index.d.ts.map +1 -0
- package/dist/esm/opcodes/index.js +4 -0
- package/dist/esm/opcodes/index.js.map +1 -0
- package/dist/esm/opcodes/util.d.ts +86 -0
- package/dist/esm/opcodes/util.d.ts.map +1 -0
- package/dist/esm/opcodes/util.js +257 -0
- package/dist/esm/opcodes/util.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/params.d.ts +3 -0
- package/dist/esm/params.d.ts.map +1 -0
- package/dist/esm/params.js +421 -0
- package/dist/esm/params.js.map +1 -0
- package/dist/esm/precompiles/01-ecrecover.d.ts +4 -0
- package/dist/esm/precompiles/01-ecrecover.d.ts.map +1 -0
- package/dist/esm/precompiles/01-ecrecover.js +55 -0
- package/dist/esm/precompiles/01-ecrecover.js.map +1 -0
- package/dist/esm/precompiles/02-sha256.d.ts +4 -0
- package/dist/esm/precompiles/02-sha256.d.ts.map +1 -0
- package/dist/esm/precompiles/02-sha256.js +24 -0
- package/dist/esm/precompiles/02-sha256.js.map +1 -0
- package/dist/esm/precompiles/03-ripemd160.d.ts +4 -0
- package/dist/esm/precompiles/03-ripemd160.d.ts.map +1 -0
- package/dist/esm/precompiles/03-ripemd160.js +23 -0
- package/dist/esm/precompiles/03-ripemd160.js.map +1 -0
- package/dist/esm/precompiles/04-identity.d.ts +4 -0
- package/dist/esm/precompiles/04-identity.d.ts.map +1 -0
- package/dist/esm/precompiles/04-identity.js +21 -0
- package/dist/esm/precompiles/04-identity.js.map +1 -0
- package/dist/esm/precompiles/05-modexp.d.ts +5 -0
- package/dist/esm/precompiles/05-modexp.d.ts.map +1 -0
- package/dist/esm/precompiles/05-modexp.js +181 -0
- package/dist/esm/precompiles/05-modexp.js.map +1 -0
- package/dist/esm/precompiles/06-bn254-add.d.ts +4 -0
- package/dist/esm/precompiles/06-bn254-add.d.ts.map +1 -0
- package/dist/esm/precompiles/06-bn254-add.js +39 -0
- package/dist/esm/precompiles/06-bn254-add.js.map +1 -0
- package/dist/esm/precompiles/07-bn254-mul.d.ts +4 -0
- package/dist/esm/precompiles/07-bn254-mul.d.ts.map +1 -0
- package/dist/esm/precompiles/07-bn254-mul.js +40 -0
- package/dist/esm/precompiles/07-bn254-mul.js.map +1 -0
- package/dist/esm/precompiles/08-bn254-pairing.d.ts +4 -0
- package/dist/esm/precompiles/08-bn254-pairing.d.ts.map +1 -0
- package/dist/esm/precompiles/08-bn254-pairing.js +42 -0
- package/dist/esm/precompiles/08-bn254-pairing.js.map +1 -0
- package/dist/esm/precompiles/09-blake2f.d.ts +5 -0
- package/dist/esm/precompiles/09-blake2f.d.ts.map +1 -0
- package/dist/esm/precompiles/09-blake2f.js +197 -0
- package/dist/esm/precompiles/09-blake2f.js.map +1 -0
- package/dist/esm/precompiles/0a-kzg-point-evaluation.d.ts +5 -0
- package/dist/esm/precompiles/0a-kzg-point-evaluation.d.ts.map +1 -0
- package/dist/esm/precompiles/0a-kzg-point-evaluation.js +64 -0
- package/dist/esm/precompiles/0a-kzg-point-evaluation.js.map +1 -0
- package/dist/esm/precompiles/0b-bls12-g1add.d.ts +4 -0
- package/dist/esm/precompiles/0b-bls12-g1add.d.ts.map +1 -0
- package/dist/esm/precompiles/0b-bls12-g1add.js +46 -0
- package/dist/esm/precompiles/0b-bls12-g1add.js.map +1 -0
- package/dist/esm/precompiles/0c-bls12-g1msm.d.ts +4 -0
- package/dist/esm/precompiles/0c-bls12-g1msm.d.ts.map +1 -0
- package/dist/esm/precompiles/0c-bls12-g1msm.js +59 -0
- package/dist/esm/precompiles/0c-bls12-g1msm.js.map +1 -0
- package/dist/esm/precompiles/0d-bls12-g2add.d.ts +4 -0
- package/dist/esm/precompiles/0d-bls12-g2add.d.ts.map +1 -0
- package/dist/esm/precompiles/0d-bls12-g2add.js +48 -0
- package/dist/esm/precompiles/0d-bls12-g2add.js.map +1 -0
- package/dist/esm/precompiles/0e-bls12-g2msm.d.ts +4 -0
- package/dist/esm/precompiles/0e-bls12-g2msm.d.ts.map +1 -0
- package/dist/esm/precompiles/0e-bls12-g2msm.js +57 -0
- package/dist/esm/precompiles/0e-bls12-g2msm.js.map +1 -0
- package/dist/esm/precompiles/0f-bls12-pairing.d.ts +4 -0
- package/dist/esm/precompiles/0f-bls12-pairing.d.ts.map +1 -0
- package/dist/esm/precompiles/0f-bls12-pairing.js +63 -0
- package/dist/esm/precompiles/0f-bls12-pairing.js.map +1 -0
- package/dist/esm/precompiles/10-bls12-map-fp-to-g1.d.ts +4 -0
- package/dist/esm/precompiles/10-bls12-map-fp-to-g1.d.ts.map +1 -0
- package/dist/esm/precompiles/10-bls12-map-fp-to-g1.js +41 -0
- package/dist/esm/precompiles/10-bls12-map-fp-to-g1.js.map +1 -0
- package/dist/esm/precompiles/100-p256verify.d.ts +4 -0
- package/dist/esm/precompiles/100-p256verify.d.ts.map +1 -0
- package/dist/esm/precompiles/100-p256verify.js +128 -0
- package/dist/esm/precompiles/100-p256verify.js.map +1 -0
- package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.d.ts +4 -0
- package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.d.ts.map +1 -0
- package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.js +44 -0
- package/dist/esm/precompiles/11-bls12-map-fp2-to-g2.js.map +1 -0
- package/dist/esm/precompiles/bls12_381/constants.d.ts +10 -0
- package/dist/esm/precompiles/bls12_381/constants.d.ts.map +1 -0
- package/dist/esm/precompiles/bls12_381/constants.js +271 -0
- package/dist/esm/precompiles/bls12_381/constants.js.map +1 -0
- package/dist/esm/precompiles/bls12_381/index.d.ts +5 -0
- package/dist/esm/precompiles/bls12_381/index.d.ts.map +1 -0
- package/dist/esm/precompiles/bls12_381/index.js +5 -0
- package/dist/esm/precompiles/bls12_381/index.js.map +1 -0
- package/dist/esm/precompiles/bls12_381/mcl.d.ts +45 -0
- package/dist/esm/precompiles/bls12_381/mcl.d.ts.map +1 -0
- package/dist/esm/precompiles/bls12_381/mcl.js +254 -0
- package/dist/esm/precompiles/bls12_381/mcl.js.map +1 -0
- package/dist/esm/precompiles/bls12_381/noble.d.ts +39 -0
- package/dist/esm/precompiles/bls12_381/noble.d.ts.map +1 -0
- package/dist/esm/precompiles/bls12_381/noble.js +218 -0
- package/dist/esm/precompiles/bls12_381/noble.js.map +1 -0
- package/dist/esm/precompiles/bls12_381/util.d.ts +35 -0
- package/dist/esm/precompiles/bls12_381/util.d.ts.map +1 -0
- package/dist/esm/precompiles/bls12_381/util.js +63 -0
- package/dist/esm/precompiles/bls12_381/util.js.map +1 -0
- package/dist/esm/precompiles/bn254/index.d.ts +3 -0
- package/dist/esm/precompiles/bn254/index.d.ts.map +1 -0
- package/dist/esm/precompiles/bn254/index.js +3 -0
- package/dist/esm/precompiles/bn254/index.js.map +1 -0
- package/dist/esm/precompiles/bn254/noble.d.ts +13 -0
- package/dist/esm/precompiles/bn254/noble.d.ts.map +1 -0
- package/dist/esm/precompiles/bn254/noble.js +120 -0
- package/dist/esm/precompiles/bn254/noble.js.map +1 -0
- package/dist/esm/precompiles/bn254/rustbn.d.ts +16 -0
- package/dist/esm/precompiles/bn254/rustbn.d.ts.map +1 -0
- package/dist/esm/precompiles/bn254/rustbn.js +29 -0
- package/dist/esm/precompiles/bn254/rustbn.js.map +1 -0
- package/dist/esm/precompiles/index.d.ts +67 -0
- package/dist/esm/precompiles/index.d.ts.map +1 -0
- package/dist/esm/precompiles/index.js +251 -0
- package/dist/esm/precompiles/index.js.map +1 -0
- package/dist/esm/precompiles/types.d.ts +13 -0
- package/dist/esm/precompiles/types.d.ts.map +1 -0
- package/dist/esm/precompiles/types.js +2 -0
- package/dist/esm/precompiles/types.js.map +1 -0
- package/dist/esm/precompiles/util.d.ts +30 -0
- package/dist/esm/precompiles/util.d.ts.map +1 -0
- package/dist/esm/precompiles/util.js +57 -0
- package/dist/esm/precompiles/util.js.map +1 -0
- package/dist/esm/stack.d.ts +55 -0
- package/dist/esm/stack.d.ts.map +1 -0
- package/dist/esm/stack.js +139 -0
- package/dist/esm/stack.js.map +1 -0
- package/dist/esm/stemCache.d.ts +20 -0
- package/dist/esm/stemCache.d.ts.map +1 -0
- package/dist/esm/stemCache.js +33 -0
- package/dist/esm/stemCache.js.map +1 -0
- package/dist/esm/transientStorage.d.ts +54 -0
- package/dist/esm/transientStorage.d.ts.map +1 -0
- package/dist/esm/transientStorage.js +109 -0
- package/dist/esm/transientStorage.js.map +1 -0
- package/dist/esm/types.d.ts +465 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +23 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/tsconfig.prod.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.prod.esm.tsbuildinfo +1 -0
- package/package.json +98 -0
- package/src/binaryTreeAccessWitness.ts +447 -0
- package/src/chunkCache.ts +36 -0
- package/src/constructors.ts +35 -0
- package/src/eip7708.ts +47 -0
- package/src/eof/constants.ts +36 -0
- package/src/eof/container.ts +495 -0
- package/src/eof/errors.ts +214 -0
- package/src/eof/setup.ts +27 -0
- package/src/eof/stackDelta.ts +169 -0
- package/src/eof/util.ts +16 -0
- package/src/eof/verify.ts +531 -0
- package/src/errors.ts +45 -0
- package/src/evm.ts +1415 -0
- package/src/frameContext.ts +56 -0
- package/src/index.ts +75 -0
- package/src/interpreter.ts +1437 -0
- package/src/journal.ts +317 -0
- package/src/logger.ts +180 -0
- package/src/memory.ts +82 -0
- package/src/message.ts +114 -0
- package/src/opcodes/EIP1283.ts +77 -0
- package/src/opcodes/EIP2200.ts +87 -0
- package/src/opcodes/EIP2929.ts +173 -0
- package/src/opcodes/codes.ts +528 -0
- package/src/opcodes/functions.ts +1937 -0
- package/src/opcodes/gas.ts +1329 -0
- package/src/opcodes/index.ts +3 -0
- package/src/opcodes/util.ts +313 -0
- package/src/params.ts +423 -0
- package/src/precompiles/01-ecrecover.ts +77 -0
- package/src/precompiles/02-sha256.ts +32 -0
- package/src/precompiles/03-ripemd160.ts +32 -0
- package/src/precompiles/04-identity.ts +29 -0
- package/src/precompiles/05-modexp.ts +215 -0
- package/src/precompiles/06-bn254-add.ts +49 -0
- package/src/precompiles/07-bn254-mul.ts +50 -0
- package/src/precompiles/08-bn254-pairing.ts +54 -0
- package/src/precompiles/09-blake2f.ts +243 -0
- package/src/precompiles/0a-kzg-point-evaluation.ts +94 -0
- package/src/precompiles/0b-bls12-g1add.ts +63 -0
- package/src/precompiles/0c-bls12-g1msm.ts +87 -0
- package/src/precompiles/0d-bls12-g2add.ts +66 -0
- package/src/precompiles/0e-bls12-g2msm.ts +84 -0
- package/src/precompiles/0f-bls12-pairing.ts +86 -0
- package/src/precompiles/10-bls12-map-fp-to-g1.ts +58 -0
- package/src/precompiles/100-p256verify.ts +152 -0
- package/src/precompiles/11-bls12-map-fp2-to-g2.ts +61 -0
- package/src/precompiles/bls12_381/constants.ts +278 -0
- package/src/precompiles/bls12_381/index.ts +4 -0
- package/src/precompiles/bls12_381/mcl.ts +376 -0
- package/src/precompiles/bls12_381/noble.ts +307 -0
- package/src/precompiles/bls12_381/util.ts +78 -0
- package/src/precompiles/bn254/index.ts +2 -0
- package/src/precompiles/bn254/noble.ts +156 -0
- package/src/precompiles/bn254/rustbn.ts +35 -0
- package/src/precompiles/index.ts +344 -0
- package/src/precompiles/types.ts +15 -0
- package/src/precompiles/util.ts +70 -0
- package/src/stack.ts +166 -0
- package/src/stemCache.ts +45 -0
- package/src/transientStorage.ts +131 -0
- package/src/types.ts +538 -0
package/dist/cjs/evm.js
ADDED
|
@@ -0,0 +1,1142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EVM = void 0;
|
|
4
|
+
exports.OOGResult = OOGResult;
|
|
5
|
+
exports.COOGResult = COOGResult;
|
|
6
|
+
exports.INVALID_BYTECODE_RESULT = INVALID_BYTECODE_RESULT;
|
|
7
|
+
exports.INVALID_EOF_RESULT = INVALID_EOF_RESULT;
|
|
8
|
+
exports.CodesizeExceedsMaximumError = CodesizeExceedsMaximumError;
|
|
9
|
+
exports.EVMErrorResult = EVMErrorResult;
|
|
10
|
+
exports.defaultBlock = defaultBlock;
|
|
11
|
+
const common_1 = require("@feelyourprotocol/common");
|
|
12
|
+
const util_1 = require("@feelyourprotocol/util");
|
|
13
|
+
const debug_1 = require("debug");
|
|
14
|
+
const eventemitter3_1 = require("eventemitter3");
|
|
15
|
+
const eip7708_ts_1 = require("./eip7708.js");
|
|
16
|
+
const constants_ts_1 = require("./eof/constants.js");
|
|
17
|
+
const util_ts_1 = require("./eof/util.js");
|
|
18
|
+
const errors_ts_1 = require("./errors.js");
|
|
19
|
+
const interpreter_ts_1 = require("./interpreter.js");
|
|
20
|
+
const journal_ts_1 = require("./journal.js");
|
|
21
|
+
const logger_ts_1 = require("./logger.js");
|
|
22
|
+
const message_ts_1 = require("./message.js");
|
|
23
|
+
const index_ts_1 = require("./opcodes/index.js");
|
|
24
|
+
const params_ts_1 = require("./params.js");
|
|
25
|
+
const index_ts_2 = require("./precompiles/index.js");
|
|
26
|
+
const transientStorage_ts_1 = require("./transientStorage.js");
|
|
27
|
+
const types_ts_1 = require("./types.js");
|
|
28
|
+
const debug = (0, debug_1.default)('evm:evm');
|
|
29
|
+
const debugGas = (0, debug_1.default)('evm:gas');
|
|
30
|
+
const debugPrecompiles = (0, debug_1.default)('evm:precompiles');
|
|
31
|
+
/**
|
|
32
|
+
* Creates a standardized ExecResult for out-of-gas errors.
|
|
33
|
+
* @param gasLimit - Gas limit consumed by the failing frame
|
|
34
|
+
* @returns Execution result describing the OOG failure
|
|
35
|
+
*/
|
|
36
|
+
function OOGResult(gasLimit) {
|
|
37
|
+
return {
|
|
38
|
+
returnValue: new Uint8Array(0),
|
|
39
|
+
executionGasUsed: gasLimit,
|
|
40
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.OUT_OF_GAS),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an ExecResult for code-deposit out-of-gas errors (EIP-3541).
|
|
45
|
+
* @param gasUsedCreateCode - Gas consumed while attempting to store code
|
|
46
|
+
*/
|
|
47
|
+
function COOGResult(gasUsedCreateCode) {
|
|
48
|
+
return {
|
|
49
|
+
returnValue: new Uint8Array(0),
|
|
50
|
+
executionGasUsed: gasUsedCreateCode,
|
|
51
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.CODESTORE_OUT_OF_GAS),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns an ExecResult signalling invalid bytecode input.
|
|
56
|
+
* @param gasLimit - Gas consumed up to the point of failure
|
|
57
|
+
*/
|
|
58
|
+
function INVALID_BYTECODE_RESULT(gasLimit) {
|
|
59
|
+
return {
|
|
60
|
+
returnValue: new Uint8Array(0),
|
|
61
|
+
executionGasUsed: gasLimit,
|
|
62
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.INVALID_BYTECODE_RESULT),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Returns an ExecResult signalling invalid EOF formatting.
|
|
67
|
+
* @param gasLimit - Gas consumed up to the point of failure
|
|
68
|
+
*/
|
|
69
|
+
function INVALID_EOF_RESULT(gasLimit) {
|
|
70
|
+
return {
|
|
71
|
+
returnValue: new Uint8Array(0),
|
|
72
|
+
executionGasUsed: gasLimit,
|
|
73
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.INVALID_EOF_FORMAT),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns an ExecResult for code size violations.
|
|
78
|
+
* @param gasUsed - Gas consumed before the violation was detected
|
|
79
|
+
*/
|
|
80
|
+
function CodesizeExceedsMaximumError(gasUsed) {
|
|
81
|
+
return {
|
|
82
|
+
returnValue: new Uint8Array(0),
|
|
83
|
+
executionGasUsed: gasUsed,
|
|
84
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.CODESIZE_EXCEEDS_MAXIMUM),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Wraps an {@link EVMError} in an ExecResult.
|
|
89
|
+
* @param error - Error encountered during execution
|
|
90
|
+
* @param gasUsed - Gas consumed up to the error
|
|
91
|
+
*/
|
|
92
|
+
function EVMErrorResult(error, gasUsed) {
|
|
93
|
+
return {
|
|
94
|
+
returnValue: new Uint8Array(0),
|
|
95
|
+
executionGasUsed: gasUsed,
|
|
96
|
+
exceptionError: error,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Creates a default block header used by stand-alone executions.
|
|
101
|
+
* @returns Block-like object with zeroed header fields
|
|
102
|
+
*/
|
|
103
|
+
function defaultBlock() {
|
|
104
|
+
return {
|
|
105
|
+
header: {
|
|
106
|
+
number: util_1.BIGINT_0,
|
|
107
|
+
coinbase: (0, util_1.createZeroAddress)(),
|
|
108
|
+
timestamp: util_1.BIGINT_0,
|
|
109
|
+
difficulty: util_1.BIGINT_0,
|
|
110
|
+
prevRandao: new Uint8Array(32),
|
|
111
|
+
gasLimit: util_1.BIGINT_0,
|
|
112
|
+
baseFeePerGas: undefined,
|
|
113
|
+
getBlobGasPrice: () => undefined,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The EVM (Ethereum Virtual Machine) is responsible for executing EVM bytecode, processing transactions, and managing state changes. It handles both contract calls and contract creation operations.
|
|
119
|
+
*
|
|
120
|
+
* An EVM instance can be created with the constructor method:
|
|
121
|
+
*
|
|
122
|
+
* - {@link createEVM}
|
|
123
|
+
*/
|
|
124
|
+
class EVM {
|
|
125
|
+
get precompiles() {
|
|
126
|
+
return this._precompiles;
|
|
127
|
+
}
|
|
128
|
+
get opcodes() {
|
|
129
|
+
return this._opcodes;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* Creates new EVM object
|
|
134
|
+
*
|
|
135
|
+
* @deprecated The direct usage of this constructor is replaced since
|
|
136
|
+
* non-finalized async initialization lead to side effects. Please
|
|
137
|
+
* use the async {@link createEVM} constructor instead (same API).
|
|
138
|
+
*
|
|
139
|
+
* @param opts The EVM options
|
|
140
|
+
* @param bn128 Initialized bn128 WASM object for precompile usage (internal)
|
|
141
|
+
*/
|
|
142
|
+
constructor(opts) {
|
|
143
|
+
/**
|
|
144
|
+
* EVM is run in DEBUG mode (default: false)
|
|
145
|
+
* Taken from DEBUG environment variable
|
|
146
|
+
*
|
|
147
|
+
* Safeguards on debug() calls are added for
|
|
148
|
+
* performance reasons to avoid string literal evaluation
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
151
|
+
this.DEBUG = false;
|
|
152
|
+
this.common = opts.common;
|
|
153
|
+
this.blockchain = opts.blockchain;
|
|
154
|
+
this.stateManager = opts.stateManager;
|
|
155
|
+
if (this.common.isActivatedEIP(7864)) {
|
|
156
|
+
const mandatory = ['checkChunkWitnessPresent'];
|
|
157
|
+
for (const m of mandatory) {
|
|
158
|
+
if (!(m in this.stateManager)) {
|
|
159
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`State manager used must implement ${m} if Binary Trees (EIP-7864) is activated`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
164
|
+
this.blockLevelAccessList = opts.blockLevelAccessList ?? (0, util_1.createBlockLevelAccessList)();
|
|
165
|
+
}
|
|
166
|
+
this.events = new eventemitter3_1.EventEmitter();
|
|
167
|
+
this._optsCached = opts;
|
|
168
|
+
// Supported EIPs
|
|
169
|
+
const supportedEIPs = [
|
|
170
|
+
1153, 1559, 2537, 2565, 2718, 2929, 2930, 2935, 3198, 3529, 3540, 3541, 3607, 3651, 3670,
|
|
171
|
+
3855, 3860, 4200, 4399, 4750, 4788, 4844, 4895, 5133, 5450, 5656, 6110, 6206, 6780, 7002,
|
|
172
|
+
7069, 7251, 7480, 7516, 7594, 7620, 7685, 7691, 7692, 7698, 7702, 7709, 7823, 7825, 7934,
|
|
173
|
+
7939, 7951, 8024, 8141,
|
|
174
|
+
];
|
|
175
|
+
for (const eip of this.common.eips()) {
|
|
176
|
+
if (!supportedEIPs.includes(eip)) {
|
|
177
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`EIP-${eip} is not supported by the EVM`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!EVM.supportedHardforks.includes(this.common.hardfork())) {
|
|
181
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)(`Hardfork ${this.common.hardfork()} not set as supported in supportedHardforks`);
|
|
182
|
+
}
|
|
183
|
+
this.common.updateParams(opts.params ?? params_ts_1.paramsEVM);
|
|
184
|
+
this.allowUnlimitedContractSize = opts.allowUnlimitedContractSize ?? false;
|
|
185
|
+
this.allowUnlimitedInitCodeSize = opts.allowUnlimitedInitCodeSize ?? false;
|
|
186
|
+
this._customOpcodes = opts.customOpcodes;
|
|
187
|
+
this._customPrecompiles = opts.customPrecompiles;
|
|
188
|
+
this.journal = new journal_ts_1.Journal(this.stateManager, this.common);
|
|
189
|
+
this.transientStorage = new transientStorage_ts_1.TransientStorage();
|
|
190
|
+
this.common.events.on('hardforkChanged', () => {
|
|
191
|
+
this.getActiveOpcodes();
|
|
192
|
+
this._precompiles = (0, index_ts_2.getActivePrecompiles)(this.common, this._customPrecompiles);
|
|
193
|
+
});
|
|
194
|
+
// Initialize the opcode data
|
|
195
|
+
this.getActiveOpcodes();
|
|
196
|
+
this._precompiles = (0, index_ts_2.getActivePrecompiles)(this.common, this._customPrecompiles);
|
|
197
|
+
// Precompile crypto libraries
|
|
198
|
+
if (this.common.isActivatedEIP(2537)) {
|
|
199
|
+
this._bls = opts.bls ?? new index_ts_2.NobleBLS();
|
|
200
|
+
this._bls.init?.();
|
|
201
|
+
}
|
|
202
|
+
this._bn254 = opts.bn254;
|
|
203
|
+
this._emit = async (topic, data) => {
|
|
204
|
+
const listeners = this.events.listeners(topic);
|
|
205
|
+
for (const listener of listeners) {
|
|
206
|
+
if (listener.length === 2) {
|
|
207
|
+
await new Promise((resolve) => {
|
|
208
|
+
listener(data, resolve);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
listener(data);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
this.performanceLogger = new logger_ts_1.EVMPerformanceLogger();
|
|
217
|
+
// Skip DEBUG calls unless 'ethjs' included in environmental DEBUG variables
|
|
218
|
+
this.DEBUG = (0, util_1.isDebugEnabled)('ethjs');
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Returns a list with the currently activated opcodes
|
|
222
|
+
* available for EVM execution
|
|
223
|
+
*/
|
|
224
|
+
getActiveOpcodes() {
|
|
225
|
+
const data = (0, index_ts_1.getOpcodesForHF)(this.common, this._customOpcodes);
|
|
226
|
+
this._opcodes = data.opcodes;
|
|
227
|
+
this._dynamicGasHandlers = data.dynamicGasHandlers;
|
|
228
|
+
this._handlers = data.handlers;
|
|
229
|
+
this._opcodeMap = data.opcodeMap;
|
|
230
|
+
return data.opcodes;
|
|
231
|
+
}
|
|
232
|
+
async _executeCall(message) {
|
|
233
|
+
let gasLimit = message.gasLimit;
|
|
234
|
+
const fromAddress = message.caller;
|
|
235
|
+
if (this.common.isActivatedEIP(7864)) {
|
|
236
|
+
if (message.accessWitness === undefined) {
|
|
237
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('accessWitness is required for EIP-7864');
|
|
238
|
+
}
|
|
239
|
+
const sendsValue = message.value !== util_1.BIGINT_0;
|
|
240
|
+
if (message.depth === 0) {
|
|
241
|
+
const originAccessGas = message.accessWitness.readAccountHeader(fromAddress);
|
|
242
|
+
debugGas(`originAccessGas=${originAccessGas} waived off for origin at depth=0`);
|
|
243
|
+
let destAccessGas = message.accessWitness.readAccountCodeHash(message.to);
|
|
244
|
+
if (sendsValue) {
|
|
245
|
+
destAccessGas += message.accessWitness.writeAccountBasicData(message.to);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
destAccessGas += message.accessWitness.readAccountBasicData(message.to);
|
|
249
|
+
}
|
|
250
|
+
debugGas(`destAccessGas=${destAccessGas} waived off for target at depth=0`);
|
|
251
|
+
}
|
|
252
|
+
let callAccessGas = message.accessWitness.readAccountBasicData(message.to);
|
|
253
|
+
if (sendsValue) {
|
|
254
|
+
callAccessGas += message.accessWitness.writeAccountBasicData(message.to);
|
|
255
|
+
}
|
|
256
|
+
gasLimit -= callAccessGas;
|
|
257
|
+
if (gasLimit < util_1.BIGINT_0) {
|
|
258
|
+
if (this.DEBUG) {
|
|
259
|
+
debugGas(`callAccessGas charged(${callAccessGas}) caused OOG (-> ${gasLimit})`);
|
|
260
|
+
}
|
|
261
|
+
message.accessWitness.revert();
|
|
262
|
+
return { execResult: OOGResult(message.gasLimit) };
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
if (this.DEBUG) {
|
|
266
|
+
debugGas(`callAccessGas used (${callAccessGas} gas (-> ${gasLimit}))`);
|
|
267
|
+
}
|
|
268
|
+
message.accessWitness.commit();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
let account = await this.stateManager.getAccount(fromAddress);
|
|
272
|
+
if (!account) {
|
|
273
|
+
account = new util_1.Account();
|
|
274
|
+
}
|
|
275
|
+
let errorMessage;
|
|
276
|
+
// Reduce tx value from sender
|
|
277
|
+
if (!message.delegatecall) {
|
|
278
|
+
try {
|
|
279
|
+
await this._reduceSenderBalance(account, message);
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
errorMessage = e;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// Load `to` account
|
|
286
|
+
let toAccount = await this.stateManager.getAccount(message.to);
|
|
287
|
+
if (!toAccount) {
|
|
288
|
+
if (this.common.isActivatedEIP(6800) || this.common.isActivatedEIP(7864)) {
|
|
289
|
+
const absenceProofAccessGas = message.accessWitness.readAccountHeader(message.to);
|
|
290
|
+
gasLimit -= absenceProofAccessGas;
|
|
291
|
+
if (gasLimit < util_1.BIGINT_0) {
|
|
292
|
+
if (this.DEBUG) {
|
|
293
|
+
debugGas(`Proof of absence access charged(${absenceProofAccessGas}) caused OOG (-> ${gasLimit})`);
|
|
294
|
+
}
|
|
295
|
+
message.accessWitness?.revert();
|
|
296
|
+
return { execResult: OOGResult(message.gasLimit) };
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
if (this.DEBUG) {
|
|
300
|
+
debugGas(`Proof of absence access used (${absenceProofAccessGas} gas (-> ${gasLimit}))`);
|
|
301
|
+
}
|
|
302
|
+
message.accessWitness?.commit();
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
toAccount = new util_1.Account();
|
|
306
|
+
}
|
|
307
|
+
// Add tx value to the `to` account
|
|
308
|
+
if (!message.delegatecall) {
|
|
309
|
+
try {
|
|
310
|
+
await this._addToBalance(toAccount, message);
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
errorMessage = e;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// EIP-7928: Add codeAddress to BAL for DELEGATECALL/CALLCODE
|
|
317
|
+
// For these opcodes, `to` is the current contract but `codeAddress` is the target
|
|
318
|
+
// whose code is being executed. The target MUST be included in the BAL.
|
|
319
|
+
if (this.common.isActivatedEIP(7928) &&
|
|
320
|
+
message.codeAddress !== undefined &&
|
|
321
|
+
message.codeAddress.toString() !== message.to.toString()) {
|
|
322
|
+
this.blockLevelAccessList.addAddress(message.codeAddress.toString());
|
|
323
|
+
}
|
|
324
|
+
// Load code
|
|
325
|
+
await this._loadCode(message);
|
|
326
|
+
let exit = false;
|
|
327
|
+
if (!message.code || (typeof message.code !== 'function' && message.code.length === 0)) {
|
|
328
|
+
exit = true;
|
|
329
|
+
if (this.DEBUG) {
|
|
330
|
+
debug(`Exit early on no code (CALL)`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (errorMessage !== undefined) {
|
|
334
|
+
exit = true;
|
|
335
|
+
if (this.DEBUG) {
|
|
336
|
+
debug(`Exit early on value transfer overflowed (CALL)`);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
// EIP-7708: Create ETH transfer log for non-zero value transfers to a different account.
|
|
340
|
+
// CALLCODE always executes in the caller's context (to == caller), so it is a self-transfer.
|
|
341
|
+
// Self-transfers (caller == to) and DELEGATECALL do not emit a log.
|
|
342
|
+
let eip7708Log;
|
|
343
|
+
const isTransferToDifferentAccount = !(0, util_1.equalsBytes)(message.caller.bytes, message.to.bytes);
|
|
344
|
+
if (this.common.isActivatedEIP(7708) &&
|
|
345
|
+
!message.delegatecall &&
|
|
346
|
+
message.value > util_1.BIGINT_0 &&
|
|
347
|
+
isTransferToDifferentAccount &&
|
|
348
|
+
errorMessage === undefined) {
|
|
349
|
+
eip7708Log = (0, eip7708_ts_1.createEIP7708TransferLog)(message.caller, message.to, message.value);
|
|
350
|
+
if (this.DEBUG) {
|
|
351
|
+
debug(`EIP-7708: Created ETH transfer log from ${message.caller} to ${message.to} value=${message.value}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (exit) {
|
|
355
|
+
// Even on early exit, we may need to return the EIP-7708 log if value was transferred
|
|
356
|
+
return {
|
|
357
|
+
execResult: {
|
|
358
|
+
gasRefund: message.gasRefund,
|
|
359
|
+
executionGasUsed: message.gasLimit - gasLimit,
|
|
360
|
+
exceptionError: errorMessage, // Only defined if addToBalance failed
|
|
361
|
+
returnValue: new Uint8Array(0),
|
|
362
|
+
logs: eip7708Log ? [eip7708Log] : undefined,
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
let result;
|
|
367
|
+
if (message.isCompiled) {
|
|
368
|
+
let timer;
|
|
369
|
+
let callTimer;
|
|
370
|
+
let target;
|
|
371
|
+
if (this._optsCached.profiler?.enabled === true) {
|
|
372
|
+
// Using deprecated bytesToUnprefixedHex for performance: used for profiler string formatting.
|
|
373
|
+
target = (0, util_1.bytesToUnprefixedHex)(message.codeAddress.bytes);
|
|
374
|
+
// TODO: map target precompile not to address, but to a name
|
|
375
|
+
target = (0, index_ts_2.getPrecompileName)(target) ?? target.slice(20);
|
|
376
|
+
if (this.performanceLogger.hasTimer()) {
|
|
377
|
+
callTimer = this.performanceLogger.pauseTimer();
|
|
378
|
+
}
|
|
379
|
+
timer = this.performanceLogger.startTimer(target);
|
|
380
|
+
}
|
|
381
|
+
result = await this.runPrecompile(message.code, message.data, gasLimit);
|
|
382
|
+
if (eip7708Log !== undefined) {
|
|
383
|
+
result.logs = result.logs !== undefined ? [eip7708Log, ...result.logs] : [eip7708Log];
|
|
384
|
+
}
|
|
385
|
+
if (this._optsCached.profiler?.enabled === true) {
|
|
386
|
+
this.performanceLogger.stopTimer(timer, Number(result.executionGasUsed), 'precompiles');
|
|
387
|
+
if (callTimer !== undefined) {
|
|
388
|
+
this.performanceLogger.unpauseTimer(callTimer);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
result.gasRefund = message.gasRefund;
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
if (this.DEBUG) {
|
|
395
|
+
debug(`Start bytecode processing...`);
|
|
396
|
+
}
|
|
397
|
+
result = await this.runInterpreter({
|
|
398
|
+
...{ codeAddress: message.codeAddress },
|
|
399
|
+
...message,
|
|
400
|
+
gasLimit,
|
|
401
|
+
}, { initialLogs: eip7708Log ? [eip7708Log] : undefined });
|
|
402
|
+
}
|
|
403
|
+
if (message.depth === 0) {
|
|
404
|
+
this.postMessageCleanup();
|
|
405
|
+
}
|
|
406
|
+
result.executionGasUsed += message.gasLimit - gasLimit;
|
|
407
|
+
return {
|
|
408
|
+
execResult: result,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
async _executeCreate(message) {
|
|
412
|
+
let gasLimit = message.gasLimit;
|
|
413
|
+
const fromAddress = message.caller;
|
|
414
|
+
if (this.common.isActivatedEIP(6800) || this.common.isActivatedEIP(7864)) {
|
|
415
|
+
if (message.depth === 0) {
|
|
416
|
+
const originAccessGas = message.accessWitness.readAccountHeader(fromAddress);
|
|
417
|
+
debugGas(`originAccessGas=${originAccessGas} waived off for origin at depth=0`);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
let account = await this.stateManager.getAccount(message.caller);
|
|
421
|
+
if (!account) {
|
|
422
|
+
account = new util_1.Account();
|
|
423
|
+
}
|
|
424
|
+
// Reduce tx value from sender
|
|
425
|
+
await this._reduceSenderBalance(account, message);
|
|
426
|
+
if (this.common.isActivatedEIP(3860)) {
|
|
427
|
+
if (message.data.length > Number(this.common.param('maxInitCodeSize')) &&
|
|
428
|
+
!this.allowUnlimitedInitCodeSize) {
|
|
429
|
+
return {
|
|
430
|
+
createdAddress: message.to,
|
|
431
|
+
execResult: {
|
|
432
|
+
returnValue: new Uint8Array(0),
|
|
433
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.INITCODE_SIZE_VIOLATION),
|
|
434
|
+
executionGasUsed: message.gasLimit,
|
|
435
|
+
},
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// TODO at some point, figure out why we swapped out data to code in the first place
|
|
440
|
+
message.code = message.data;
|
|
441
|
+
message.data = message.eofCallData ?? new Uint8Array();
|
|
442
|
+
message.to = await this._generateAddress(message);
|
|
443
|
+
if (this.common.isActivatedEIP(6780)) {
|
|
444
|
+
message.createdAddresses.add(message.to.toString());
|
|
445
|
+
}
|
|
446
|
+
if (this.DEBUG) {
|
|
447
|
+
debug(`Generated CREATE contract address ${message.to}`);
|
|
448
|
+
}
|
|
449
|
+
let toAccount = await this.stateManager.getAccount(message.to);
|
|
450
|
+
if (!toAccount) {
|
|
451
|
+
toAccount = new util_1.Account();
|
|
452
|
+
}
|
|
453
|
+
if (this.common.isActivatedEIP(6800) || this.common.isActivatedEIP(7864)) {
|
|
454
|
+
const contractCreateAccessGas = message.accessWitness.writeAccountBasicData(message.to) +
|
|
455
|
+
message.accessWitness.readAccountCodeHash(message.to);
|
|
456
|
+
gasLimit -= contractCreateAccessGas;
|
|
457
|
+
if (gasLimit < util_1.BIGINT_0) {
|
|
458
|
+
if (this.DEBUG) {
|
|
459
|
+
debugGas(`ContractCreateInit charge(${contractCreateAccessGas}) caused OOG (-> ${gasLimit})`);
|
|
460
|
+
message.accessWitness?.revert();
|
|
461
|
+
}
|
|
462
|
+
return { execResult: OOGResult(message.gasLimit) };
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
if (this.DEBUG) {
|
|
466
|
+
debugGas(`ContractCreateInit charged (${contractCreateAccessGas} gas (-> ${gasLimit}))`);
|
|
467
|
+
}
|
|
468
|
+
message.accessWitness?.commit();
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
// Check for collision
|
|
472
|
+
if ((toAccount.nonce && toAccount.nonce > util_1.BIGINT_0) ||
|
|
473
|
+
!((0, util_1.equalsBytes)(toAccount.codeHash, util_1.KECCAK256_NULL) === true) ||
|
|
474
|
+
// See EIP 7610 and the discussion `https://ethereum-magicians.org/t/eip-7610-revert-creation-in-case-of-non-empty-storage`
|
|
475
|
+
!((0, util_1.equalsBytes)(toAccount.storageRoot, util_1.KECCAK256_RLP) === true)) {
|
|
476
|
+
if (this.DEBUG) {
|
|
477
|
+
debug(`Returning on address collision`);
|
|
478
|
+
}
|
|
479
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
480
|
+
this.blockLevelAccessList.addAddress(message.to.toString());
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
createdAddress: message.to,
|
|
484
|
+
execResult: {
|
|
485
|
+
returnValue: new Uint8Array(0),
|
|
486
|
+
exceptionError: new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.CREATE_COLLISION),
|
|
487
|
+
executionGasUsed: message.gasLimit,
|
|
488
|
+
},
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
await this.journal.putAccount(message.to, toAccount);
|
|
492
|
+
await this.stateManager.clearStorage(message.to);
|
|
493
|
+
const newContractEvent = {
|
|
494
|
+
address: message.to,
|
|
495
|
+
code: message.code,
|
|
496
|
+
};
|
|
497
|
+
await this._emit('newContract', newContractEvent);
|
|
498
|
+
toAccount = await this.stateManager.getAccount(message.to);
|
|
499
|
+
if (!toAccount) {
|
|
500
|
+
toAccount = new util_1.Account();
|
|
501
|
+
}
|
|
502
|
+
// EIP-161 on account creation and CREATE execution
|
|
503
|
+
if (this.common.gteHardfork(common_1.Hardfork.SpuriousDragon)) {
|
|
504
|
+
toAccount.nonce += util_1.BIGINT_1;
|
|
505
|
+
}
|
|
506
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
507
|
+
this.blockLevelAccessList.addNonceChange(message.to.toString(), toAccount.nonce, this.blockLevelAccessList.blockAccessIndex);
|
|
508
|
+
}
|
|
509
|
+
// Add tx value to the `to` account
|
|
510
|
+
let errorMessage;
|
|
511
|
+
try {
|
|
512
|
+
await this._addToBalance(toAccount, message);
|
|
513
|
+
}
|
|
514
|
+
catch (e) {
|
|
515
|
+
errorMessage = e;
|
|
516
|
+
}
|
|
517
|
+
let exit = false;
|
|
518
|
+
if (message.code === undefined ||
|
|
519
|
+
(typeof message.code !== 'function' && message.code.length === 0)) {
|
|
520
|
+
exit = true;
|
|
521
|
+
if (this.DEBUG) {
|
|
522
|
+
debug(`Exit early on no code (CREATE)`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (errorMessage !== undefined) {
|
|
526
|
+
exit = true;
|
|
527
|
+
if (this.DEBUG) {
|
|
528
|
+
debug(`Exit early on value transfer overflowed (CREATE)`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
// EIP-7708: Create ETH transfer log for contract creation with value
|
|
532
|
+
let eip7708CreateLog;
|
|
533
|
+
if (this.common.isActivatedEIP(7708) &&
|
|
534
|
+
message.value > util_1.BIGINT_0 &&
|
|
535
|
+
message.to !== undefined &&
|
|
536
|
+
!(0, util_1.equalsBytes)(message.caller.bytes, message.to.bytes) &&
|
|
537
|
+
errorMessage === undefined) {
|
|
538
|
+
eip7708CreateLog = (0, eip7708_ts_1.createEIP7708TransferLog)(message.caller, message.to, message.value);
|
|
539
|
+
if (this.DEBUG) {
|
|
540
|
+
debug(`EIP-7708: Created ETH transfer log for CREATE from ${message.caller} to ${message.to} value=${message.value}`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (exit) {
|
|
544
|
+
if (this.common.isActivatedEIP(6800) || this.common.isActivatedEIP(7864)) {
|
|
545
|
+
const createCompleteAccessGas = message.accessWitness.writeAccountHeader(message.to);
|
|
546
|
+
gasLimit -= createCompleteAccessGas;
|
|
547
|
+
if (gasLimit < util_1.BIGINT_0) {
|
|
548
|
+
if (this.DEBUG) {
|
|
549
|
+
debug(`ContractCreateComplete access gas (${createCompleteAccessGas}) caused OOG (-> ${gasLimit})`);
|
|
550
|
+
}
|
|
551
|
+
message.accessWitness?.revert();
|
|
552
|
+
return { execResult: OOGResult(message.gasLimit) };
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
if (this.DEBUG) {
|
|
556
|
+
debug(`ContractCreateComplete access used (${createCompleteAccessGas}) gas (-> ${gasLimit})`);
|
|
557
|
+
}
|
|
558
|
+
message.accessWitness?.commit();
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
return {
|
|
562
|
+
createdAddress: message.to,
|
|
563
|
+
execResult: {
|
|
564
|
+
executionGasUsed: message.gasLimit - gasLimit,
|
|
565
|
+
gasRefund: message.gasRefund,
|
|
566
|
+
exceptionError: errorMessage, // only defined if addToBalance failed
|
|
567
|
+
returnValue: new Uint8Array(0),
|
|
568
|
+
logs: eip7708CreateLog ? [eip7708CreateLog] : undefined,
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
if (this.DEBUG) {
|
|
573
|
+
debug(`Start bytecode processing...`);
|
|
574
|
+
}
|
|
575
|
+
// run the message with the updated gas limit and add accessed gas used to the result
|
|
576
|
+
let result = await this.runInterpreter({ ...message, gasLimit, isCreate: true }, {
|
|
577
|
+
initialLogs: eip7708CreateLog ? [eip7708CreateLog] : undefined,
|
|
578
|
+
});
|
|
579
|
+
result.executionGasUsed += message.gasLimit - gasLimit;
|
|
580
|
+
// fee for size of the return value
|
|
581
|
+
let totalGas = result.executionGasUsed;
|
|
582
|
+
let returnFee = util_1.BIGINT_0;
|
|
583
|
+
if (!result.exceptionError && !this.common.isActivatedEIP(6800)) {
|
|
584
|
+
returnFee = BigInt(result.returnValue.length) * BigInt(this.common.param('createDataGas'));
|
|
585
|
+
totalGas = totalGas + returnFee;
|
|
586
|
+
if (this.DEBUG) {
|
|
587
|
+
debugGas(`Add return value size fee (${returnFee} to gas used (-> ${totalGas}))`);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
// Check for SpuriousDragon EIP-170 code size limit
|
|
591
|
+
let allowedCodeSize = true;
|
|
592
|
+
if (!result.exceptionError &&
|
|
593
|
+
this.common.gteHardfork(common_1.Hardfork.SpuriousDragon) &&
|
|
594
|
+
result.returnValue.length > Number(this.common.param('maxCodeSize'))) {
|
|
595
|
+
allowedCodeSize = false;
|
|
596
|
+
}
|
|
597
|
+
// If enough gas and allowed code size
|
|
598
|
+
let CodestoreOOG = false;
|
|
599
|
+
if (totalGas <= message.gasLimit && (this.allowUnlimitedContractSize || allowedCodeSize)) {
|
|
600
|
+
if (this.common.isActivatedEIP(3541) && result.returnValue[0] === constants_ts_1.FORMAT) {
|
|
601
|
+
if (!this.common.isActivatedEIP(3540)) {
|
|
602
|
+
result = { ...result, ...INVALID_BYTECODE_RESULT(message.gasLimit) };
|
|
603
|
+
}
|
|
604
|
+
else if (
|
|
605
|
+
// TODO check if this is correct
|
|
606
|
+
// Also likely cleanup this eofCallData stuff
|
|
607
|
+
/*(message.depth > 0 && message.eofCallData === undefined) ||
|
|
608
|
+
(message.depth === 0 && !isEOF(message.code))*/
|
|
609
|
+
!(0, util_ts_1.isEOF)(message.code)) {
|
|
610
|
+
// TODO the message.eof was flagged for this to work for this first
|
|
611
|
+
// Running into Legacy mode: unable to deploy EOF contract
|
|
612
|
+
result = { ...result, ...INVALID_BYTECODE_RESULT(message.gasLimit) };
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
// 3541 is active and current runtime mode is EOF
|
|
616
|
+
result.executionGasUsed = totalGas;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
result.executionGasUsed = totalGas;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
if (this.common.gteHardfork(common_1.Hardfork.Homestead)) {
|
|
625
|
+
if (!allowedCodeSize) {
|
|
626
|
+
if (this.DEBUG) {
|
|
627
|
+
debug(`Code size exceeds maximum code size (>= SpuriousDragon)`);
|
|
628
|
+
}
|
|
629
|
+
result = { ...result, ...CodesizeExceedsMaximumError(message.gasLimit) };
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
if (this.DEBUG) {
|
|
633
|
+
debug(`Contract creation: out of gas`);
|
|
634
|
+
}
|
|
635
|
+
message.accessWitness?.revert();
|
|
636
|
+
result = { ...result, ...OOGResult(message.gasLimit) };
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
// we are in Frontier
|
|
641
|
+
if (totalGas - returnFee <= message.gasLimit) {
|
|
642
|
+
// we cannot pay the code deposit fee (but the deposit code actually did run)
|
|
643
|
+
if (this.DEBUG) {
|
|
644
|
+
debug(`Not enough gas to pay the code deposit fee (Frontier)`);
|
|
645
|
+
}
|
|
646
|
+
message.accessWitness?.revert();
|
|
647
|
+
result = { ...result, ...COOGResult(totalGas - returnFee) };
|
|
648
|
+
CodestoreOOG = true;
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
if (this.DEBUG) {
|
|
652
|
+
debug(`Contract creation: out of gas`);
|
|
653
|
+
}
|
|
654
|
+
message.accessWitness?.revert();
|
|
655
|
+
result = { ...result, ...OOGResult(message.gasLimit) };
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
// get the fresh gas limit for the rest of the ops
|
|
660
|
+
gasLimit = message.gasLimit - result.executionGasUsed;
|
|
661
|
+
if (!result.exceptionError &&
|
|
662
|
+
(this.common.isActivatedEIP(6800) || this.common.isActivatedEIP(7864))) {
|
|
663
|
+
const createCompleteAccessGas = message.accessWitness.writeAccountHeader(message.to);
|
|
664
|
+
gasLimit -= createCompleteAccessGas;
|
|
665
|
+
if (gasLimit < util_1.BIGINT_0) {
|
|
666
|
+
if (this.DEBUG) {
|
|
667
|
+
debug(`ContractCreateComplete access gas (${createCompleteAccessGas}) caused OOG (-> ${gasLimit})`);
|
|
668
|
+
}
|
|
669
|
+
message.accessWitness?.revert();
|
|
670
|
+
result = { ...result, ...OOGResult(message.gasLimit) };
|
|
671
|
+
}
|
|
672
|
+
else {
|
|
673
|
+
debug(`ContractCreateComplete access used (${createCompleteAccessGas}) gas (-> ${gasLimit})`);
|
|
674
|
+
result.executionGasUsed += createCompleteAccessGas;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
// Save code if a new contract was created
|
|
678
|
+
if (!result.exceptionError &&
|
|
679
|
+
result.returnValue !== undefined &&
|
|
680
|
+
result.returnValue.length !== 0) {
|
|
681
|
+
// Add access charges for writing this code to the state
|
|
682
|
+
if (this.common.isActivatedEIP(6800) || this.common.isActivatedEIP(7864)) {
|
|
683
|
+
const byteCodeWriteAccessfee = message.accessWitness.writeAccountCodeChunks(message.to, 0, result.returnValue.length - 1);
|
|
684
|
+
gasLimit -= byteCodeWriteAccessfee;
|
|
685
|
+
if (gasLimit < util_1.BIGINT_0) {
|
|
686
|
+
if (this.DEBUG) {
|
|
687
|
+
debug(`byteCodeWrite access gas (${byteCodeWriteAccessfee}) caused OOG (-> ${gasLimit})`);
|
|
688
|
+
}
|
|
689
|
+
message.accessWitness?.revert();
|
|
690
|
+
result = { ...result, ...OOGResult(message.gasLimit) };
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
debug(`byteCodeWrite access used (${byteCodeWriteAccessfee}) gas (-> ${gasLimit})`);
|
|
694
|
+
message.accessWitness?.commit();
|
|
695
|
+
result.executionGasUsed += byteCodeWriteAccessfee;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
await this.stateManager.putCode(message.to, result.returnValue);
|
|
699
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
700
|
+
this.blockLevelAccessList.addCodeChange(message.to.toString(), result.returnValue, this.blockLevelAccessList.blockAccessIndex);
|
|
701
|
+
}
|
|
702
|
+
if (this.DEBUG) {
|
|
703
|
+
debug(`Code saved on new contract creation`);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
else if (CodestoreOOG) {
|
|
707
|
+
// This only happens at Frontier. But, let's do a sanity check;
|
|
708
|
+
if (!this.common.gteHardfork(common_1.Hardfork.Homestead)) {
|
|
709
|
+
// Pre-Homestead behavior; put an empty contract.
|
|
710
|
+
// This contract would be considered "DEAD" in later hard forks.
|
|
711
|
+
// It is thus an unnecessary default item, which we have to save to disk
|
|
712
|
+
// It does change the state root, but it only wastes storage.
|
|
713
|
+
const account = await this.stateManager.getAccount(message.to);
|
|
714
|
+
await this.journal.putAccount(message.to, account ?? new util_1.Account());
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
if (message.depth === 0) {
|
|
718
|
+
this.postMessageCleanup();
|
|
719
|
+
}
|
|
720
|
+
return {
|
|
721
|
+
createdAddress: message.to,
|
|
722
|
+
execResult: result,
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Starts the actual bytecode processing for a CALL or CREATE
|
|
727
|
+
*/
|
|
728
|
+
async runInterpreter(message, opts = {}) {
|
|
729
|
+
let contract = await this.stateManager.getAccount(message.to ?? (0, util_1.createZeroAddress)());
|
|
730
|
+
if (!contract) {
|
|
731
|
+
contract = new util_1.Account();
|
|
732
|
+
}
|
|
733
|
+
const env = {
|
|
734
|
+
address: message.to ?? (0, util_1.createZeroAddress)(),
|
|
735
|
+
caller: message.caller ?? (0, util_1.createZeroAddress)(),
|
|
736
|
+
callData: message.data ?? Uint8Array.from([0]),
|
|
737
|
+
callValue: message.value ?? util_1.BIGINT_0,
|
|
738
|
+
code: message.code,
|
|
739
|
+
isStatic: message.isStatic ?? false,
|
|
740
|
+
isCreate: message.isCreate ?? false,
|
|
741
|
+
depth: message.depth ?? 0,
|
|
742
|
+
gasPrice: this._tx.gasPrice,
|
|
743
|
+
origin: this._tx.origin ?? message.caller ?? (0, util_1.createZeroAddress)(),
|
|
744
|
+
block: this._block ?? defaultBlock(),
|
|
745
|
+
contract,
|
|
746
|
+
codeAddress: message.codeAddress,
|
|
747
|
+
gasRefund: message.gasRefund,
|
|
748
|
+
chargeCodeAccesses: message.chargeCodeAccesses,
|
|
749
|
+
blobVersionedHashes: message.blobVersionedHashes ?? [],
|
|
750
|
+
accessWitness: message.accessWitness,
|
|
751
|
+
createdAddresses: message.createdAddresses,
|
|
752
|
+
initialLogs: opts.initialLogs,
|
|
753
|
+
};
|
|
754
|
+
const interpreter = new interpreter_ts_1.Interpreter(this, this.stateManager, this.blockchain, env, message.gasLimit, this.journal, this.performanceLogger, this._optsCached.profiler);
|
|
755
|
+
if (message.selfdestruct) {
|
|
756
|
+
interpreter._result.selfdestruct = message.selfdestruct;
|
|
757
|
+
}
|
|
758
|
+
if (message.createdAddresses) {
|
|
759
|
+
interpreter._result.createdAddresses = message.createdAddresses;
|
|
760
|
+
}
|
|
761
|
+
const interpreterRes = await interpreter.run(message.code, opts);
|
|
762
|
+
let result = interpreter._result;
|
|
763
|
+
let gasUsed = message.gasLimit - interpreterRes.runState.gasLeft;
|
|
764
|
+
if (interpreterRes.exceptionError) {
|
|
765
|
+
if (interpreterRes.exceptionError.error !== errors_ts_1.EVMError.errorMessages.REVERT &&
|
|
766
|
+
interpreterRes.exceptionError.error !== errors_ts_1.EVMError.errorMessages.INVALID_EOF_FORMAT) {
|
|
767
|
+
gasUsed = message.gasLimit;
|
|
768
|
+
}
|
|
769
|
+
// Clear the result on error
|
|
770
|
+
result = {
|
|
771
|
+
...result,
|
|
772
|
+
logs: [],
|
|
773
|
+
selfdestruct: new Map(),
|
|
774
|
+
createdAddresses: new Set(),
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
message.accessWitness?.commit();
|
|
778
|
+
return {
|
|
779
|
+
...result,
|
|
780
|
+
runState: {
|
|
781
|
+
...interpreterRes.runState,
|
|
782
|
+
...result,
|
|
783
|
+
...interpreter._env,
|
|
784
|
+
},
|
|
785
|
+
exceptionError: interpreterRes.exceptionError,
|
|
786
|
+
gas: interpreterRes.runState?.gasLeft,
|
|
787
|
+
executionGasUsed: gasUsed,
|
|
788
|
+
gasRefund: interpreterRes.runState.gasRefund,
|
|
789
|
+
returnValue: result.returnValue ?? new Uint8Array(0),
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Executes an EVM message, determining whether it's a call or create
|
|
794
|
+
* based on the `to` address. It checkpoints the state and reverts changes
|
|
795
|
+
* if an exception happens during the message execution.
|
|
796
|
+
*/
|
|
797
|
+
async runCall(opts) {
|
|
798
|
+
let timer;
|
|
799
|
+
if ((opts.depth === 0 || opts.message === undefined) &&
|
|
800
|
+
this._optsCached.profiler?.enabled === true) {
|
|
801
|
+
timer = this.performanceLogger.startTimer('Initialization');
|
|
802
|
+
}
|
|
803
|
+
let message = opts.message;
|
|
804
|
+
let callerAccount;
|
|
805
|
+
if (!message) {
|
|
806
|
+
this._block = opts.block ?? defaultBlock();
|
|
807
|
+
const caller = opts.caller ?? (0, util_1.createZeroAddress)();
|
|
808
|
+
this._tx = {
|
|
809
|
+
gasPrice: opts.gasPrice ?? util_1.BIGINT_0,
|
|
810
|
+
origin: opts.origin ?? caller,
|
|
811
|
+
};
|
|
812
|
+
const value = opts.value ?? util_1.BIGINT_0;
|
|
813
|
+
if (opts.skipBalance === true) {
|
|
814
|
+
callerAccount = await this.stateManager.getAccount(caller);
|
|
815
|
+
if (!callerAccount) {
|
|
816
|
+
callerAccount = new util_1.Account();
|
|
817
|
+
}
|
|
818
|
+
const originalBalance = callerAccount.balance;
|
|
819
|
+
if (callerAccount.balance < value) {
|
|
820
|
+
// if skipBalance and balance less than value, set caller balance to `value` to ensure sufficient funds
|
|
821
|
+
callerAccount.balance = value;
|
|
822
|
+
await this.journal.putAccount(caller, callerAccount);
|
|
823
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
824
|
+
this.blockLevelAccessList.addBalanceChange(caller.toString(), callerAccount.balance, this.blockLevelAccessList.blockAccessIndex, originalBalance);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
message = new message_ts_1.Message({
|
|
829
|
+
caller,
|
|
830
|
+
gasLimit: opts.gasLimit ?? BigInt(0xffffff),
|
|
831
|
+
to: opts.to,
|
|
832
|
+
value,
|
|
833
|
+
data: opts.data,
|
|
834
|
+
code: opts.code,
|
|
835
|
+
depth: opts.depth,
|
|
836
|
+
isCompiled: opts.isCompiled,
|
|
837
|
+
isStatic: opts.isStatic,
|
|
838
|
+
salt: opts.salt,
|
|
839
|
+
selfdestruct: opts.selfdestruct ?? new Map(),
|
|
840
|
+
createdAddresses: opts.createdAddresses ?? new Set(),
|
|
841
|
+
delegatecall: opts.delegatecall,
|
|
842
|
+
blobVersionedHashes: opts.blobVersionedHashes,
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
if (message.depth === 0) {
|
|
846
|
+
if (!callerAccount) {
|
|
847
|
+
callerAccount = await this.stateManager.getAccount(message.caller);
|
|
848
|
+
}
|
|
849
|
+
if (!callerAccount) {
|
|
850
|
+
callerAccount = new util_1.Account();
|
|
851
|
+
}
|
|
852
|
+
callerAccount.nonce++;
|
|
853
|
+
await this.journal.putAccount(message.caller, callerAccount);
|
|
854
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
855
|
+
this.blockLevelAccessList.addNonceChange(message.caller.toString(), callerAccount.nonce, this.blockLevelAccessList.blockAccessIndex);
|
|
856
|
+
}
|
|
857
|
+
if (this.DEBUG) {
|
|
858
|
+
debug(`Update fromAccount (caller) nonce (-> ${callerAccount.nonce}))`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
await this._emit('beforeMessage', message);
|
|
862
|
+
if (!message.to && this.common.isActivatedEIP(2929)) {
|
|
863
|
+
message.code = message.data;
|
|
864
|
+
this.journal.addWarmedAddress((await this._generateAddress(message)).bytes);
|
|
865
|
+
}
|
|
866
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
867
|
+
this.blockLevelAccessList?.checkpoint();
|
|
868
|
+
}
|
|
869
|
+
await this.journal.checkpoint();
|
|
870
|
+
if (this.common.isActivatedEIP(1153))
|
|
871
|
+
this.transientStorage.checkpoint();
|
|
872
|
+
if (this.DEBUG) {
|
|
873
|
+
debug('-'.repeat(100));
|
|
874
|
+
debug(`message checkpoint`);
|
|
875
|
+
}
|
|
876
|
+
let result;
|
|
877
|
+
if (this.DEBUG) {
|
|
878
|
+
const { caller, gasLimit, to, value, delegatecall } = message;
|
|
879
|
+
debug(`New message caller=${caller} gasLimit=${gasLimit} to=${to?.toString() ?? 'none'} value=${value} delegatecall=${delegatecall ? 'yes' : 'no'}`);
|
|
880
|
+
}
|
|
881
|
+
if (message.to) {
|
|
882
|
+
if (this.DEBUG) {
|
|
883
|
+
debug(`Message CALL execution (to: ${message.to})`);
|
|
884
|
+
}
|
|
885
|
+
result = await this._executeCall(message);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
if (this.DEBUG) {
|
|
889
|
+
debug(`Message CREATE execution (to: undefined)`);
|
|
890
|
+
}
|
|
891
|
+
result = await this._executeCreate(message);
|
|
892
|
+
}
|
|
893
|
+
if (this.DEBUG) {
|
|
894
|
+
const { executionGasUsed, exceptionError, returnValue } = result.execResult;
|
|
895
|
+
debug(`Received message execResult: [ gasUsed=${executionGasUsed} exceptionError=${exceptionError ? `'${exceptionError.error}'` : 'none'} returnValue=${(0, util_1.short)(returnValue)} gasRefund=${result.execResult.gasRefund ?? 0} ]`);
|
|
896
|
+
}
|
|
897
|
+
const err = result.execResult.exceptionError;
|
|
898
|
+
// This clause captures any error which happened during execution
|
|
899
|
+
// If that is the case, then all refunds are forfeited
|
|
900
|
+
// There is one exception: if the CODESTORE_OUT_OF_GAS error is thrown
|
|
901
|
+
// (this only happens the Frontier/Chainstart fork)
|
|
902
|
+
// then the error is dismissed
|
|
903
|
+
if (err && err.error !== errors_ts_1.EVMError.errorMessages.CODESTORE_OUT_OF_GAS) {
|
|
904
|
+
result.execResult.selfdestruct = new Map();
|
|
905
|
+
result.execResult.createdAddresses = new Set();
|
|
906
|
+
result.execResult.gasRefund = util_1.BIGINT_0;
|
|
907
|
+
}
|
|
908
|
+
if (err &&
|
|
909
|
+
!(this.common.hardfork() === common_1.Hardfork.Chainstart &&
|
|
910
|
+
err.error === errors_ts_1.EVMError.errorMessages.CODESTORE_OUT_OF_GAS)) {
|
|
911
|
+
result.execResult.logs = [];
|
|
912
|
+
await this.journal.revert();
|
|
913
|
+
if (this.common.isActivatedEIP(1153))
|
|
914
|
+
this.transientStorage.revert();
|
|
915
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
916
|
+
this.blockLevelAccessList?.revert();
|
|
917
|
+
}
|
|
918
|
+
if (this.DEBUG) {
|
|
919
|
+
debug(`message checkpoint reverted`);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
await this.journal.commit();
|
|
924
|
+
if (this.common.isActivatedEIP(1153))
|
|
925
|
+
this.transientStorage.commit();
|
|
926
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
927
|
+
this.blockLevelAccessList?.commit();
|
|
928
|
+
}
|
|
929
|
+
if (this.DEBUG) {
|
|
930
|
+
debug(`message checkpoint committed`);
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
await this._emit('afterMessage', result);
|
|
934
|
+
if (message.depth === 0 && this._optsCached.profiler?.enabled === true) {
|
|
935
|
+
this.performanceLogger.stopTimer(timer, 0);
|
|
936
|
+
}
|
|
937
|
+
message.accessWitness?.commit();
|
|
938
|
+
return result;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Bound to the global VM and therefore
|
|
942
|
+
* shouldn't be used directly from the evm class
|
|
943
|
+
*/
|
|
944
|
+
async runCode(opts) {
|
|
945
|
+
this._block = opts.block ?? defaultBlock();
|
|
946
|
+
this._tx = {
|
|
947
|
+
gasPrice: opts.gasPrice ?? util_1.BIGINT_0,
|
|
948
|
+
origin: opts.origin ?? opts.caller ?? (0, util_1.createZeroAddress)(),
|
|
949
|
+
};
|
|
950
|
+
const message = new message_ts_1.Message({
|
|
951
|
+
code: opts.code,
|
|
952
|
+
data: opts.data,
|
|
953
|
+
gasLimit: opts.gasLimit ?? BigInt(0xffffff),
|
|
954
|
+
to: opts.to ?? (0, util_1.createZeroAddress)(),
|
|
955
|
+
caller: opts.caller,
|
|
956
|
+
value: opts.value,
|
|
957
|
+
depth: opts.depth,
|
|
958
|
+
selfdestruct: opts.selfdestruct ?? new Map(),
|
|
959
|
+
isStatic: opts.isStatic,
|
|
960
|
+
blobVersionedHashes: opts.blobVersionedHashes,
|
|
961
|
+
});
|
|
962
|
+
return this.runInterpreter(message, { pc: opts.pc });
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Returns the precompile function registered at the given address,
|
|
966
|
+
* or `undefined` if no precompile is active there.
|
|
967
|
+
*
|
|
968
|
+
* Accepts either an `Address` instance or a `0x`-prefixed hex string.
|
|
969
|
+
*
|
|
970
|
+
* ```ts
|
|
971
|
+
* const evm = await createEVM({
|
|
972
|
+
* customPrecompiles: [{ address: '0x000000000000000000000000000000000000ff01', function: myFn }],
|
|
973
|
+
* })
|
|
974
|
+
* const fn = evm.getPrecompile('0x000000000000000000000000000000000000ff01')
|
|
975
|
+
* ```
|
|
976
|
+
*/
|
|
977
|
+
getPrecompile(address) {
|
|
978
|
+
if (typeof address === 'string') {
|
|
979
|
+
return this.precompiles.get(address.slice(2).padStart(40, '0').toLowerCase());
|
|
980
|
+
}
|
|
981
|
+
return this.precompiles.get((0, util_1.bytesToUnprefixedHex)(address.bytes));
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Executes a precompiled contract with given data and gas limit.
|
|
985
|
+
*/
|
|
986
|
+
runPrecompile(code, data, gasLimit) {
|
|
987
|
+
if (typeof code !== 'function') {
|
|
988
|
+
throw (0, util_1.EthereumJSErrorWithoutCode)('Invalid precompile');
|
|
989
|
+
}
|
|
990
|
+
const opts = {
|
|
991
|
+
data,
|
|
992
|
+
gasLimit,
|
|
993
|
+
common: this.common,
|
|
994
|
+
_EVM: this,
|
|
995
|
+
_debug: this.DEBUG ? debugPrecompiles : undefined,
|
|
996
|
+
stateManager: this.stateManager,
|
|
997
|
+
};
|
|
998
|
+
return code(opts);
|
|
999
|
+
}
|
|
1000
|
+
async _loadCode(message) {
|
|
1001
|
+
if (!message.code) {
|
|
1002
|
+
const precompile = this.getPrecompile(message.codeAddress);
|
|
1003
|
+
if (precompile) {
|
|
1004
|
+
message.code = precompile;
|
|
1005
|
+
message.isCompiled = true;
|
|
1006
|
+
}
|
|
1007
|
+
else {
|
|
1008
|
+
message.code = await this.stateManager.getCode(message.codeAddress);
|
|
1009
|
+
// EIP-7702 delegation check
|
|
1010
|
+
if (this.common.isActivatedEIP(7702) &&
|
|
1011
|
+
(0, util_1.equalsBytes)(message.code.slice(0, 3), types_ts_1.DELEGATION_7702_FLAG)) {
|
|
1012
|
+
const address = new util_1.Address(message.code.slice(3, 24));
|
|
1013
|
+
message.code = await this.stateManager.getCode(address);
|
|
1014
|
+
// EIP-7928: Track delegation target access in BAL
|
|
1015
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
1016
|
+
this.blockLevelAccessList?.addAddress(address.toString());
|
|
1017
|
+
}
|
|
1018
|
+
if (message.depth === 0) {
|
|
1019
|
+
this.journal.addAlwaysWarmAddress(address.toString());
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
message.isCompiled = false;
|
|
1023
|
+
message.chargeCodeAccesses = true;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
async _generateAddress(message) {
|
|
1028
|
+
let addr;
|
|
1029
|
+
if (message.salt) {
|
|
1030
|
+
addr = (0, util_1.generateAddress2)(message.caller.bytes, message.salt, message.code);
|
|
1031
|
+
}
|
|
1032
|
+
else {
|
|
1033
|
+
let acc = await this.stateManager.getAccount(message.caller);
|
|
1034
|
+
if (!acc) {
|
|
1035
|
+
acc = new util_1.Account();
|
|
1036
|
+
}
|
|
1037
|
+
const newNonce = acc.nonce - util_1.BIGINT_1;
|
|
1038
|
+
addr = (0, util_1.generateAddress)(message.caller.bytes, (0, util_1.bigIntToBytes)(newNonce));
|
|
1039
|
+
}
|
|
1040
|
+
return new util_1.Address(addr);
|
|
1041
|
+
}
|
|
1042
|
+
async _reduceSenderBalance(account, message) {
|
|
1043
|
+
const originalBalance = account.balance;
|
|
1044
|
+
account.balance -= message.value;
|
|
1045
|
+
if (account.balance < util_1.BIGINT_0) {
|
|
1046
|
+
throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.INSUFFICIENT_BALANCE);
|
|
1047
|
+
}
|
|
1048
|
+
// EIP-7928: Record the sender's reduced balance in BAL
|
|
1049
|
+
// Per spec, CALL/CALLCODE senders must have their balance recorded
|
|
1050
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
1051
|
+
this.blockLevelAccessList.addBalanceChange(message.caller.toString(), account.balance, this.blockLevelAccessList.blockAccessIndex, originalBalance);
|
|
1052
|
+
}
|
|
1053
|
+
const result = this.journal.putAccount(message.caller, account);
|
|
1054
|
+
if (this.DEBUG) {
|
|
1055
|
+
debug(`Reduced sender (${message.caller}) balance (-> ${account.balance})`);
|
|
1056
|
+
}
|
|
1057
|
+
return result;
|
|
1058
|
+
}
|
|
1059
|
+
async _addToBalance(toAccount, message) {
|
|
1060
|
+
const originalBalance = toAccount.balance;
|
|
1061
|
+
const newBalance = toAccount.balance + message.value;
|
|
1062
|
+
if (newBalance > util_1.MAX_INTEGER) {
|
|
1063
|
+
throw new errors_ts_1.EVMError(errors_ts_1.EVMError.errorMessages.VALUE_OVERFLOW);
|
|
1064
|
+
}
|
|
1065
|
+
toAccount.balance = newBalance;
|
|
1066
|
+
if (this.common.isActivatedEIP(7928)) {
|
|
1067
|
+
this.blockLevelAccessList.addAddress(message.to.toString());
|
|
1068
|
+
if (message.value !== util_1.BIGINT_0) {
|
|
1069
|
+
this.blockLevelAccessList.addBalanceChange(message.to.toString(), newBalance, this.blockLevelAccessList.blockAccessIndex, originalBalance);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
// putAccount as the nonce may have changed for contract creation
|
|
1073
|
+
await this.journal.putAccount(message.to, toAccount);
|
|
1074
|
+
if (this.DEBUG) {
|
|
1075
|
+
debug(`Added toAccount (${message.to}) balance (-> ${toAccount.balance})`);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Once the interpreter has finished depth 0, a post-message cleanup should be done
|
|
1080
|
+
*/
|
|
1081
|
+
postMessageCleanup() {
|
|
1082
|
+
if (this.common.isActivatedEIP(1153))
|
|
1083
|
+
this.transientStorage.clear();
|
|
1084
|
+
}
|
|
1085
|
+
/**
|
|
1086
|
+
* This method copies the EVM, current HF and EIP settings
|
|
1087
|
+
* and returns a new EVM instance.
|
|
1088
|
+
*
|
|
1089
|
+
* Note: this is only a shallow copy and both EVM instances
|
|
1090
|
+
* will point to the same underlying state DB.
|
|
1091
|
+
*
|
|
1092
|
+
* @returns EVM
|
|
1093
|
+
*/
|
|
1094
|
+
shallowCopy() {
|
|
1095
|
+
const common = this.common.copy();
|
|
1096
|
+
common.setHardfork(this.common.hardfork());
|
|
1097
|
+
const opts = {
|
|
1098
|
+
...this._optsCached,
|
|
1099
|
+
common,
|
|
1100
|
+
stateManager: this.stateManager.shallowCopy(),
|
|
1101
|
+
};
|
|
1102
|
+
// @ts-expect-error -- Assigning a StateManager property that is absent from the interface
|
|
1103
|
+
opts.stateManager['common'] = common;
|
|
1104
|
+
return new EVM(opts);
|
|
1105
|
+
}
|
|
1106
|
+
getPerformanceLogs() {
|
|
1107
|
+
return this.performanceLogger.getLogs();
|
|
1108
|
+
}
|
|
1109
|
+
clearPerformanceLogs() {
|
|
1110
|
+
this.performanceLogger.clear();
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
exports.EVM = EVM;
|
|
1114
|
+
EVM.supportedHardforks = [
|
|
1115
|
+
common_1.Hardfork.Chainstart,
|
|
1116
|
+
common_1.Hardfork.Homestead,
|
|
1117
|
+
common_1.Hardfork.Dao,
|
|
1118
|
+
common_1.Hardfork.TangerineWhistle,
|
|
1119
|
+
common_1.Hardfork.SpuriousDragon,
|
|
1120
|
+
common_1.Hardfork.Byzantium,
|
|
1121
|
+
common_1.Hardfork.Constantinople,
|
|
1122
|
+
common_1.Hardfork.Petersburg,
|
|
1123
|
+
common_1.Hardfork.Istanbul,
|
|
1124
|
+
common_1.Hardfork.MuirGlacier,
|
|
1125
|
+
common_1.Hardfork.Berlin,
|
|
1126
|
+
common_1.Hardfork.London,
|
|
1127
|
+
common_1.Hardfork.ArrowGlacier,
|
|
1128
|
+
common_1.Hardfork.GrayGlacier,
|
|
1129
|
+
common_1.Hardfork.MergeNetsplitBlock,
|
|
1130
|
+
common_1.Hardfork.Paris,
|
|
1131
|
+
common_1.Hardfork.Shanghai,
|
|
1132
|
+
common_1.Hardfork.Cancun,
|
|
1133
|
+
common_1.Hardfork.Prague,
|
|
1134
|
+
common_1.Hardfork.Osaka,
|
|
1135
|
+
common_1.Hardfork.Bpo1,
|
|
1136
|
+
common_1.Hardfork.Bpo2,
|
|
1137
|
+
common_1.Hardfork.Bpo3,
|
|
1138
|
+
common_1.Hardfork.Bpo4,
|
|
1139
|
+
common_1.Hardfork.Bpo5,
|
|
1140
|
+
common_1.Hardfork.Amsterdam,
|
|
1141
|
+
];
|
|
1142
|
+
//# sourceMappingURL=evm.js.map
|