@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
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicGasHandlers = void 0;
|
|
4
|
+
const common_1 = require("@feelyourprotocol/common");
|
|
5
|
+
const util_1 = require("@feelyourprotocol/util");
|
|
6
|
+
const errors_ts_1 = require("../eof/errors.js");
|
|
7
|
+
const errors_ts_2 = require("../errors.js");
|
|
8
|
+
const types_ts_1 = require("../types.js");
|
|
9
|
+
const EIP1283_ts_1 = require("./EIP1283.js");
|
|
10
|
+
const EIP2200_ts_1 = require("./EIP2200.js");
|
|
11
|
+
const EIP2929_ts_1 = require("./EIP2929.js");
|
|
12
|
+
const util_ts_1 = require("./util.js");
|
|
13
|
+
const EXTCALL_TARGET_MAX = BigInt(2) ** BigInt(8 * 20) - BigInt(1);
|
|
14
|
+
/**
|
|
15
|
+
* Gets the gas cost for EIP-7702 delegation lookup WITHOUT side effects.
|
|
16
|
+
* Returns the gas cost and delegation address so callers can check gas
|
|
17
|
+
* availability before committing to the access.
|
|
18
|
+
*/
|
|
19
|
+
async function eip7702GetAccessCost(runState, common, address, charge2929Gas) {
|
|
20
|
+
const code = await runState.stateManager.getCode(address);
|
|
21
|
+
if ((0, util_1.equalsBytes)(code.slice(0, 3), types_ts_1.DELEGATION_7702_FLAG)) {
|
|
22
|
+
const delegationAddress = code.slice(3, 24);
|
|
23
|
+
// Just get the cost, don't warm yet
|
|
24
|
+
const gas = (0, EIP2929_ts_1.getAddressAccessCost)(runState, delegationAddress, common, charge2929Gas);
|
|
25
|
+
return { gas, delegationAddress };
|
|
26
|
+
}
|
|
27
|
+
return { gas: util_1.BIGINT_0, delegationAddress: null };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Warms the delegation address for EIP-7702 (call after verifying sufficient gas).
|
|
31
|
+
*/
|
|
32
|
+
function eip7702WarmAddress(runState, delegationAddress) {
|
|
33
|
+
(0, EIP2929_ts_1.warmAddress)(runState, delegationAddress);
|
|
34
|
+
}
|
|
35
|
+
exports.dynamicGasHandlers = new Map([
|
|
36
|
+
[
|
|
37
|
+
/* EXP */
|
|
38
|
+
0x0a,
|
|
39
|
+
async function (runState, gas, common) {
|
|
40
|
+
const [_base, exponent] = runState.stack.peek(2);
|
|
41
|
+
if (exponent === util_1.BIGINT_0) {
|
|
42
|
+
return gas;
|
|
43
|
+
}
|
|
44
|
+
let byteLength = exponent.toString(2).length / 8;
|
|
45
|
+
if (byteLength > Math.trunc(byteLength)) {
|
|
46
|
+
byteLength = Math.trunc(byteLength) + 1;
|
|
47
|
+
}
|
|
48
|
+
if (byteLength < 1 || byteLength > 32) {
|
|
49
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_RANGE);
|
|
50
|
+
}
|
|
51
|
+
const expPricePerByte = common.param('expByteGas');
|
|
52
|
+
gas += BigInt(byteLength) * expPricePerByte;
|
|
53
|
+
return gas;
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
/* KECCAK256 */
|
|
58
|
+
0x20,
|
|
59
|
+
async function (runState, gas, common) {
|
|
60
|
+
const [offset, length] = runState.stack.peek(2);
|
|
61
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, length, common);
|
|
62
|
+
gas += common.param('keccak256WordGas') * (0, util_ts_1.divCeil)(length, util_1.BIGINT_32);
|
|
63
|
+
return gas;
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
/* BALANCE */
|
|
68
|
+
0x31,
|
|
69
|
+
async function (runState, gas, common) {
|
|
70
|
+
const address = (0, util_ts_1.createAddressFromStackBigInt)(runState.stack.peek()[0]);
|
|
71
|
+
let charge2929Gas = true;
|
|
72
|
+
if (common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) {
|
|
73
|
+
const coldAccessGas = runState.env.accessWitness.readAccountBasicData(address);
|
|
74
|
+
gas += coldAccessGas;
|
|
75
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
76
|
+
}
|
|
77
|
+
if (common.isActivatedEIP(2929)) {
|
|
78
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, address.bytes, common, charge2929Gas);
|
|
79
|
+
}
|
|
80
|
+
return gas;
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
[
|
|
84
|
+
/* CALLDATACOPY */
|
|
85
|
+
0x37,
|
|
86
|
+
async function (runState, gas, common) {
|
|
87
|
+
const [memOffset, _dataOffset, dataLength] = runState.stack.peek(3);
|
|
88
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, dataLength, common);
|
|
89
|
+
if (dataLength !== util_1.BIGINT_0) {
|
|
90
|
+
gas += common.param('copyGas') * (0, util_ts_1.divCeil)(dataLength, util_1.BIGINT_32);
|
|
91
|
+
}
|
|
92
|
+
return gas;
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
/* CODECOPY */
|
|
97
|
+
0x39,
|
|
98
|
+
async function (runState, gas, common) {
|
|
99
|
+
const [memOffset, _codeOffset, dataLength] = runState.stack.peek(3);
|
|
100
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, dataLength, common);
|
|
101
|
+
if (dataLength !== util_1.BIGINT_0) {
|
|
102
|
+
gas += common.param('copyGas') * (0, util_ts_1.divCeil)(dataLength, util_1.BIGINT_32);
|
|
103
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
104
|
+
runState.env.chargeCodeAccesses === true) {
|
|
105
|
+
const contract = runState.interpreter.getAddress();
|
|
106
|
+
let codeEnd = _codeOffset + dataLength;
|
|
107
|
+
const codeSize = runState.interpreter.getCodeSize();
|
|
108
|
+
if (codeEnd > codeSize) {
|
|
109
|
+
codeEnd = codeSize;
|
|
110
|
+
}
|
|
111
|
+
gas += runState.env.accessWitness.readAccountCodeChunks(contract, Number(_codeOffset), Number(codeEnd));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return gas;
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
[
|
|
118
|
+
/* EXTCODESIZE */
|
|
119
|
+
0x3b,
|
|
120
|
+
async function (runState, gas, common) {
|
|
121
|
+
const address = (0, util_ts_1.createAddressFromStackBigInt)(runState.stack.peek()[0]);
|
|
122
|
+
let charge2929Gas = true;
|
|
123
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
124
|
+
runState.interpreter._evm.getPrecompile(address) === undefined &&
|
|
125
|
+
!address.equals((0, util_ts_1.createAddressFromStackBigInt)(common.param('systemAddress')))) {
|
|
126
|
+
let coldAccessGas = util_1.BIGINT_0;
|
|
127
|
+
coldAccessGas += runState.env.accessWitness.readAccountBasicData(address);
|
|
128
|
+
gas += coldAccessGas;
|
|
129
|
+
// if cold access gas has been charged 2929 gas shouldn't be charged
|
|
130
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
131
|
+
}
|
|
132
|
+
if (common.isActivatedEIP(2929)) {
|
|
133
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, address.bytes, common, charge2929Gas);
|
|
134
|
+
}
|
|
135
|
+
return gas;
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
[
|
|
139
|
+
/* EXTCODECOPY */
|
|
140
|
+
0x3c,
|
|
141
|
+
async function (runState, gas, common) {
|
|
142
|
+
const [addressBigInt, memOffset, _codeOffset, dataLength] = runState.stack.peek(4);
|
|
143
|
+
const address = (0, util_ts_1.createAddressFromStackBigInt)(addressBigInt);
|
|
144
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, dataLength, common);
|
|
145
|
+
let charge2929Gas = true;
|
|
146
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
147
|
+
runState.interpreter._evm.getPrecompile(address) === undefined &&
|
|
148
|
+
!address.equals((0, util_ts_1.createAddressFromStackBigInt)(common.param('systemAddress')))) {
|
|
149
|
+
let coldAccessGas = util_1.BIGINT_0;
|
|
150
|
+
coldAccessGas += runState.env.accessWitness.readAccountBasicData(address);
|
|
151
|
+
gas += coldAccessGas;
|
|
152
|
+
// if cold access gas has been charged 2929 gas shouldn't be charged
|
|
153
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
154
|
+
}
|
|
155
|
+
if (common.isActivatedEIP(2929)) {
|
|
156
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, address.bytes, common, charge2929Gas);
|
|
157
|
+
}
|
|
158
|
+
if (dataLength !== util_1.BIGINT_0) {
|
|
159
|
+
gas += common.param('copyGas') * (0, util_ts_1.divCeil)(dataLength, util_1.BIGINT_32);
|
|
160
|
+
if (common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) {
|
|
161
|
+
let codeEnd = _codeOffset + dataLength;
|
|
162
|
+
const codeSize = BigInt((await runState.stateManager.getCode(address)).length);
|
|
163
|
+
if (codeEnd > codeSize) {
|
|
164
|
+
codeEnd = codeSize;
|
|
165
|
+
}
|
|
166
|
+
gas += runState.env.accessWitness.readAccountCodeChunks(address, Number(_codeOffset), Number(codeEnd));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return gas;
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
/* RETURNDATACOPY */
|
|
174
|
+
0x3e,
|
|
175
|
+
async function (runState, gas, common) {
|
|
176
|
+
const [memOffset, returnDataOffset, dataLength] = runState.stack.peek(3);
|
|
177
|
+
if (returnDataOffset + dataLength > runState.interpreter.getReturnDataSize()) {
|
|
178
|
+
// For an EOF contract, the behavior is changed (see EIP 7069)
|
|
179
|
+
// RETURNDATACOPY in that case does not throw OOG when reading out-of-bounds
|
|
180
|
+
if (runState.env.eof === undefined) {
|
|
181
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, dataLength, common);
|
|
185
|
+
if (dataLength !== util_1.BIGINT_0) {
|
|
186
|
+
gas += common.param('copyGas') * (0, util_ts_1.divCeil)(dataLength, util_1.BIGINT_32);
|
|
187
|
+
}
|
|
188
|
+
return gas;
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
/* EXTCODEHASH */
|
|
193
|
+
0x3f,
|
|
194
|
+
async function (runState, gas, common) {
|
|
195
|
+
const address = (0, util_ts_1.createAddressFromStackBigInt)(runState.stack.peek()[0]);
|
|
196
|
+
let charge2929Gas = true;
|
|
197
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
198
|
+
runState.interpreter._evm.getPrecompile(address) === undefined &&
|
|
199
|
+
!address.equals((0, util_ts_1.createAddressFromStackBigInt)(common.param('systemAddress')))) {
|
|
200
|
+
let coldAccessGas = util_1.BIGINT_0;
|
|
201
|
+
coldAccessGas += runState.env.accessWitness.readAccountCodeHash(address);
|
|
202
|
+
gas += coldAccessGas;
|
|
203
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
204
|
+
}
|
|
205
|
+
if (common.isActivatedEIP(2929)) {
|
|
206
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, address.bytes, common, charge2929Gas);
|
|
207
|
+
}
|
|
208
|
+
return gas;
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
/* MLOAD */
|
|
213
|
+
0x51,
|
|
214
|
+
async function (runState, gas, common) {
|
|
215
|
+
const pos = runState.stack.peek()[0];
|
|
216
|
+
gas += (0, util_ts_1.subMemUsage)(runState, pos, util_1.BIGINT_32, common);
|
|
217
|
+
return gas;
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
[
|
|
221
|
+
/* MSTORE */
|
|
222
|
+
0x52,
|
|
223
|
+
async function (runState, gas, common) {
|
|
224
|
+
const offset = runState.stack.peek()[0];
|
|
225
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, util_1.BIGINT_32, common);
|
|
226
|
+
return gas;
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
/* MSTORE8 */
|
|
231
|
+
0x53,
|
|
232
|
+
async function (runState, gas, common) {
|
|
233
|
+
const offset = runState.stack.peek()[0];
|
|
234
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, util_1.BIGINT_1, common);
|
|
235
|
+
return gas;
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
[
|
|
239
|
+
/* SLOAD */
|
|
240
|
+
0x54,
|
|
241
|
+
async function (runState, gas, common) {
|
|
242
|
+
const key = runState.stack.peek()[0];
|
|
243
|
+
const keyBuf = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(key), 32);
|
|
244
|
+
let charge2929Gas = true;
|
|
245
|
+
if (common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) {
|
|
246
|
+
const address = runState.interpreter.getAddress();
|
|
247
|
+
const coldAccessGas = runState.env.accessWitness.readAccountStorage(address, key);
|
|
248
|
+
gas += coldAccessGas;
|
|
249
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
250
|
+
}
|
|
251
|
+
if (common.isActivatedEIP(2929)) {
|
|
252
|
+
gas += (0, EIP2929_ts_1.accessStorageEIP2929)(runState, keyBuf, false, common, charge2929Gas);
|
|
253
|
+
}
|
|
254
|
+
return gas;
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
/* SSTORE */
|
|
259
|
+
0x55,
|
|
260
|
+
async function (runState, gas, common) {
|
|
261
|
+
if (runState.interpreter.isStatic()) {
|
|
262
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
263
|
+
}
|
|
264
|
+
const [key, val] = runState.stack.peek(2);
|
|
265
|
+
const keyBytes = (0, util_1.setLengthLeft)((0, util_1.bigIntToBytes)(key), 32);
|
|
266
|
+
// NOTE: this should be the shortest representation
|
|
267
|
+
let value;
|
|
268
|
+
if (val === util_1.BIGINT_0) {
|
|
269
|
+
value = Uint8Array.from([]);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
value = (0, util_1.bigIntToBytes)(val);
|
|
273
|
+
}
|
|
274
|
+
// Read current and original storage for gas calculation.
|
|
275
|
+
// Pass trackBAL=false because we'll track the read manually below,
|
|
276
|
+
// but ONLY if the EIP-2200 sentry check passes (per EIP-7928).
|
|
277
|
+
const currentStorage = (0, util_ts_1.setLengthLeftStorage)(await runState.interpreter.storageLoad(keyBytes, false, false));
|
|
278
|
+
const originalStorage = (0, util_ts_1.setLengthLeftStorage)(await runState.interpreter.storageLoad(keyBytes, true, false));
|
|
279
|
+
if (common.hardfork() === common_1.Hardfork.Constantinople) {
|
|
280
|
+
gas += (0, EIP1283_ts_1.updateSstoreGasEIP1283)(runState, currentStorage, originalStorage, (0, util_ts_1.setLengthLeftStorage)(value), common);
|
|
281
|
+
}
|
|
282
|
+
else if (common.gteHardfork(common_1.Hardfork.Istanbul)) {
|
|
283
|
+
if (!common.isActivatedEIP(6800) && !common.isActivatedEIP(7864)) {
|
|
284
|
+
gas += (0, EIP2200_ts_1.updateSstoreGasEIP2200)(runState, currentStorage, originalStorage, (0, util_ts_1.setLengthLeftStorage)(value), keyBytes, common);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
gas += (0, util_ts_1.updateSstoreGas)(runState, currentStorage, (0, util_ts_1.setLengthLeftStorage)(value), common);
|
|
289
|
+
}
|
|
290
|
+
// If we reach here, the EIP-2200 sentry check passed (didn't trap).
|
|
291
|
+
// Per EIP-7928, now track the storage read for BAL. If the SSTORE
|
|
292
|
+
// succeeds later, the write will remove this read (see addStorageWrite).
|
|
293
|
+
// If SSTORE fails with OOG after the sentry, the read remains in BAL.
|
|
294
|
+
if (common.isActivatedEIP(7928)) {
|
|
295
|
+
runState.interpreter._evm.blockLevelAccessList?.addStorageRead(runState.interpreter.getAddress().toString(), keyBytes);
|
|
296
|
+
}
|
|
297
|
+
let charge2929Gas = true;
|
|
298
|
+
if (common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) {
|
|
299
|
+
const contract = runState.interpreter.getAddress();
|
|
300
|
+
const coldAccessGas = runState.env.accessWitness.writeAccountStorage(contract, key);
|
|
301
|
+
gas += coldAccessGas;
|
|
302
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
303
|
+
}
|
|
304
|
+
if (common.isActivatedEIP(2929)) {
|
|
305
|
+
// We have to do this after the Istanbul (EIP2200) checks.
|
|
306
|
+
// Otherwise, we might run out of gas, due to "sentry check" of 2300 gas,
|
|
307
|
+
// if we deduct extra gas first.
|
|
308
|
+
gas += (0, EIP2929_ts_1.accessStorageEIP2929)(runState, keyBytes, true, common, charge2929Gas);
|
|
309
|
+
}
|
|
310
|
+
return gas;
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
[
|
|
314
|
+
/* MCOPY */
|
|
315
|
+
0x5e,
|
|
316
|
+
async function (runState, gas, common) {
|
|
317
|
+
const [dst, src, length] = runState.stack.peek(3);
|
|
318
|
+
const wordsCopied = (length + util_1.BIGINT_31) / util_1.BIGINT_32;
|
|
319
|
+
gas += util_1.BIGINT_3 * wordsCopied;
|
|
320
|
+
gas += (0, util_ts_1.subMemUsage)(runState, src, length, common);
|
|
321
|
+
gas += (0, util_ts_1.subMemUsage)(runState, dst, length, common);
|
|
322
|
+
return gas;
|
|
323
|
+
},
|
|
324
|
+
],
|
|
325
|
+
[
|
|
326
|
+
/* LOG */
|
|
327
|
+
0xa0,
|
|
328
|
+
async function (runState, gas, common) {
|
|
329
|
+
if (runState.interpreter.isStatic()) {
|
|
330
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
331
|
+
}
|
|
332
|
+
const [memOffset, memLength] = runState.stack.peek(2);
|
|
333
|
+
const topicsCount = runState.opCode - 0xa0;
|
|
334
|
+
if (topicsCount < 0 || topicsCount > 4) {
|
|
335
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_RANGE);
|
|
336
|
+
}
|
|
337
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, memLength, common);
|
|
338
|
+
gas +=
|
|
339
|
+
common.param('logTopicGas') * BigInt(topicsCount) + memLength * common.param('logDataGas');
|
|
340
|
+
return gas;
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
/* DATACOPY */
|
|
344
|
+
[
|
|
345
|
+
0xd3,
|
|
346
|
+
async function (runState, gas, common) {
|
|
347
|
+
if (runState.env.eof === undefined) {
|
|
348
|
+
// Opcode not available in legacy contracts
|
|
349
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
|
|
350
|
+
}
|
|
351
|
+
const [memOffset, _dataOffset, dataLength] = runState.stack.peek(3);
|
|
352
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, dataLength, common);
|
|
353
|
+
if (dataLength !== util_1.BIGINT_0) {
|
|
354
|
+
gas += common.param('copyGas') * (0, util_ts_1.divCeil)(dataLength, util_1.BIGINT_32);
|
|
355
|
+
}
|
|
356
|
+
return gas;
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
/* EOFCREATE */
|
|
360
|
+
[
|
|
361
|
+
0xec,
|
|
362
|
+
async function (runState, gas, common) {
|
|
363
|
+
if (runState.env.eof === undefined) {
|
|
364
|
+
// Opcode not available in legacy contracts
|
|
365
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
|
|
366
|
+
}
|
|
367
|
+
// Note: TX_CREATE_COST is in the base fee (this is 32000 and same as CREATE / CREATE2)
|
|
368
|
+
// Note: in `gas.ts` programCounter is not yet incremented (which it is in `functions.ts`)
|
|
369
|
+
// So have to manually add to programCounter here to get the right container index
|
|
370
|
+
// Read container index
|
|
371
|
+
const containerIndex = runState.env.code[runState.programCounter + 1];
|
|
372
|
+
// Pop stack values
|
|
373
|
+
const [_value, _salt, inputOffset, inputSize] = runState.stack.peek(4);
|
|
374
|
+
//if (common.isActivatedEIP(2929)) {
|
|
375
|
+
// TODO: adding or not adding this makes test
|
|
376
|
+
// --test=tests/prague/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_eofcreate_then_call[fork_CancunEIP7692-blockchain_test]
|
|
377
|
+
// still succeed. This only warms the current address?? This is also in CREATE/CREATE2
|
|
378
|
+
// Can this be removed in both?
|
|
379
|
+
/*gas += accessAddressEIP2929(
|
|
380
|
+
runState,
|
|
381
|
+
runState.interpreter.getAddress().bytes,
|
|
382
|
+
common,
|
|
383
|
+
false
|
|
384
|
+
)
|
|
385
|
+
}*/
|
|
386
|
+
// Expand memory
|
|
387
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inputOffset, inputSize, common);
|
|
388
|
+
// Read container
|
|
389
|
+
const container = runState.env.eof.container.body.containerSections[containerIndex];
|
|
390
|
+
// Charge for hashing cost
|
|
391
|
+
gas += common.param('keccak256WordGas') * (0, util_ts_1.divCeil)(BigInt(container.length), util_1.BIGINT_32);
|
|
392
|
+
const gasLeft = runState.interpreter.getGasLeft() - gas;
|
|
393
|
+
runState.messageGasLimit = (0, util_ts_1.maxCallGas)(gasLeft, gasLeft, runState, common);
|
|
394
|
+
return gas;
|
|
395
|
+
},
|
|
396
|
+
],
|
|
397
|
+
/* RETURNCONTRACT */
|
|
398
|
+
[
|
|
399
|
+
0xee,
|
|
400
|
+
async function (runState, gas, common) {
|
|
401
|
+
// Pop stack values
|
|
402
|
+
const [auxDataOffset, auxDataSize] = runState.stack.peek(2);
|
|
403
|
+
// Expand memory
|
|
404
|
+
gas += (0, util_ts_1.subMemUsage)(runState, auxDataOffset, auxDataSize, common);
|
|
405
|
+
return gas;
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
[
|
|
409
|
+
/* CREATE */
|
|
410
|
+
0xf0,
|
|
411
|
+
async function (runState, gas, common) {
|
|
412
|
+
if (runState.interpreter.isStatic()) {
|
|
413
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
414
|
+
}
|
|
415
|
+
const [_value, offset, length] = runState.stack.peek(3);
|
|
416
|
+
if (common.isActivatedEIP(2929)) {
|
|
417
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, runState.interpreter.getAddress().bytes, common, false);
|
|
418
|
+
}
|
|
419
|
+
if (common.isActivatedEIP(3860)) {
|
|
420
|
+
gas += ((length + util_1.BIGINT_31) / util_1.BIGINT_32) * common.param('initCodeWordGas');
|
|
421
|
+
}
|
|
422
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, length, common);
|
|
423
|
+
let gasLimit = BigInt(runState.interpreter.getGasLeft()) - gas;
|
|
424
|
+
gasLimit = (0, util_ts_1.maxCallGas)(gasLimit, gasLimit, runState, common);
|
|
425
|
+
runState.messageGasLimit = gasLimit;
|
|
426
|
+
return gas;
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
[
|
|
430
|
+
/* CALL */
|
|
431
|
+
0xf1,
|
|
432
|
+
async function (runState, gas, common) {
|
|
433
|
+
const [currentGasLimit, toAddr, value, inOffset, inLength, outOffset, outLength] = runState.stack.peek(7);
|
|
434
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
435
|
+
if (runState.interpreter.isStatic() && value !== util_1.BIGINT_0) {
|
|
436
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
437
|
+
}
|
|
438
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
439
|
+
gas += (0, util_ts_1.subMemUsage)(runState, outOffset, outLength, common);
|
|
440
|
+
// EIP-7928: Early OOG check before address access
|
|
441
|
+
// If we don't have enough gas to proceed, trap before adding to BAL
|
|
442
|
+
if (common.isActivatedEIP(7928) && gas > runState.interpreter.getGasLeft()) {
|
|
443
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
444
|
+
}
|
|
445
|
+
let charge2929Gas = true;
|
|
446
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
447
|
+
runState.interpreter._evm.getPrecompile(toAddress) === undefined) {
|
|
448
|
+
const coldAccessGas = runState.env.accessWitness.readAccountBasicData(toAddress);
|
|
449
|
+
if (value !== util_1.BIGINT_0) {
|
|
450
|
+
const contractAddress = runState.interpreter.getAddress();
|
|
451
|
+
gas += runState.env.accessWitness.writeAccountBasicData(contractAddress);
|
|
452
|
+
gas += runState.env.accessWitness.writeAccountBasicData(toAddress);
|
|
453
|
+
}
|
|
454
|
+
gas += coldAccessGas;
|
|
455
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
456
|
+
}
|
|
457
|
+
// EIP-2929/7928: Get target access cost first (no side effects)
|
|
458
|
+
let targetAccessCost = util_1.BIGINT_0;
|
|
459
|
+
if (common.isActivatedEIP(2929)) {
|
|
460
|
+
targetAccessCost = (0, EIP2929_ts_1.getAddressAccessCost)(runState, toAddress.bytes, common, charge2929Gas);
|
|
461
|
+
gas += targetAccessCost;
|
|
462
|
+
}
|
|
463
|
+
// EIP-7928: Check gas before committing target access.
|
|
464
|
+
// Include value transfer gas in this boundary, but defer new-account gas
|
|
465
|
+
// until after target access commit so OOG can still happen after target
|
|
466
|
+
// access for account-creation cases.
|
|
467
|
+
let valueTransferGas = util_1.BIGINT_0;
|
|
468
|
+
let newAccountGas = util_1.BIGINT_0;
|
|
469
|
+
if (value !== util_1.BIGINT_0 && !common.isActivatedEIP(6800) && !common.isActivatedEIP(7864)) {
|
|
470
|
+
valueTransferGas = common.param('callValueTransferGas');
|
|
471
|
+
}
|
|
472
|
+
// For BAL eligibility check: compute new account gas upfront only when needed
|
|
473
|
+
// (SpuriousDragon+ with value transfer)
|
|
474
|
+
if (value !== util_1.BIGINT_0 && common.gteHardfork(common_1.Hardfork.SpuriousDragon)) {
|
|
475
|
+
const account = await runState.stateManager.getAccount(toAddress);
|
|
476
|
+
if (account === undefined || account.isEmpty()) {
|
|
477
|
+
newAccountGas = common.param('callNewAccountGas');
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
// EIP-7928: Check gas before committing target access
|
|
481
|
+
const gasForTargetAccess = gas + valueTransferGas;
|
|
482
|
+
if (common.isActivatedEIP(7928) && gasForTargetAccess > runState.interpreter.getGasLeft()) {
|
|
483
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
484
|
+
}
|
|
485
|
+
// Now commit target access: warm the address and add to BAL
|
|
486
|
+
if (common.isActivatedEIP(2929)) {
|
|
487
|
+
(0, EIP2929_ts_1.warmAddress)(runState, toAddress.bytes);
|
|
488
|
+
}
|
|
489
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, toAddress.bytes, common);
|
|
490
|
+
// Add the value-related gas costs (already computed above for value transfers)
|
|
491
|
+
gas += valueTransferGas + newAccountGas;
|
|
492
|
+
// For pre-SpuriousDragon: check new account gas regardless of value
|
|
493
|
+
if (!common.gteHardfork(common_1.Hardfork.SpuriousDragon)) {
|
|
494
|
+
if ((await runState.stateManager.getAccount(toAddress)) === undefined) {
|
|
495
|
+
gas += common.param('callNewAccountGas');
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
// EIP-7702: Get delegation access cost (no side effects)
|
|
499
|
+
let delegationAddress = null;
|
|
500
|
+
if (common.isActivatedEIP(7702)) {
|
|
501
|
+
const { gas: delegationGas, delegationAddress: delAddr } = await eip7702GetAccessCost(runState, common, toAddress, charge2929Gas);
|
|
502
|
+
delegationAddress = delAddr;
|
|
503
|
+
gas += delegationGas;
|
|
504
|
+
// EIP-7928: Check gas before committing delegation access
|
|
505
|
+
if (common.isActivatedEIP(7928) && delegationAddress !== null) {
|
|
506
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
507
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
508
|
+
}
|
|
509
|
+
// Commit delegation access: warm and add to BAL
|
|
510
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
511
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, delegationAddress, common);
|
|
512
|
+
}
|
|
513
|
+
else if (delegationAddress !== null) {
|
|
514
|
+
// No BAL check needed, just warm the address
|
|
515
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const gasLimit = (0, util_ts_1.maxCallGas)(currentGasLimit, runState.interpreter.getGasLeft() - gas, runState, common);
|
|
519
|
+
// note that TangerineWhistle or later this cannot happen
|
|
520
|
+
// (it could have ran out of gas prior to getting here though)
|
|
521
|
+
if (gasLimit > runState.interpreter.getGasLeft() - gas) {
|
|
522
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
523
|
+
}
|
|
524
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
525
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
526
|
+
}
|
|
527
|
+
runState.messageGasLimit = gasLimit;
|
|
528
|
+
return gas;
|
|
529
|
+
},
|
|
530
|
+
],
|
|
531
|
+
[
|
|
532
|
+
/* CALLCODE */
|
|
533
|
+
0xf2,
|
|
534
|
+
async function (runState, gas, common) {
|
|
535
|
+
const [currentGasLimit, toAddr, value, inOffset, inLength, outOffset, outLength] = runState.stack.peek(7);
|
|
536
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
537
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
538
|
+
gas += (0, util_ts_1.subMemUsage)(runState, outOffset, outLength, common);
|
|
539
|
+
// EIP-7928: Early OOG check before address access
|
|
540
|
+
// If we don't have enough gas to proceed, trap before adding to BAL
|
|
541
|
+
if (common.isActivatedEIP(7928) && gas > runState.interpreter.getGasLeft()) {
|
|
542
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
543
|
+
}
|
|
544
|
+
let charge2929Gas = true;
|
|
545
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
546
|
+
runState.interpreter._evm.getPrecompile(toAddress) === undefined) {
|
|
547
|
+
const coldAccessGas = runState.env.accessWitness.readAccountBasicData(toAddress);
|
|
548
|
+
gas += coldAccessGas;
|
|
549
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
550
|
+
}
|
|
551
|
+
// EIP-2929/7928: Get target access cost first (no side effects)
|
|
552
|
+
let targetAccessCost = util_1.BIGINT_0;
|
|
553
|
+
if (common.isActivatedEIP(2929)) {
|
|
554
|
+
targetAccessCost = (0, EIP2929_ts_1.getAddressAccessCost)(runState, toAddress.bytes, common, charge2929Gas);
|
|
555
|
+
gas += targetAccessCost;
|
|
556
|
+
}
|
|
557
|
+
// For CALLCODE with value, compute value transfer cost before checking BAL eligibility
|
|
558
|
+
let valueTransferGas = util_1.BIGINT_0;
|
|
559
|
+
if (value !== util_1.BIGINT_0) {
|
|
560
|
+
valueTransferGas = common.param('callValueTransferGas');
|
|
561
|
+
}
|
|
562
|
+
// EIP-7928: Check gas before committing target access
|
|
563
|
+
// For value transfers, include value transfer gas in the check
|
|
564
|
+
const gasForTargetAccess = gas + valueTransferGas;
|
|
565
|
+
if (common.isActivatedEIP(7928) && gasForTargetAccess > runState.interpreter.getGasLeft()) {
|
|
566
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
567
|
+
}
|
|
568
|
+
// Now commit target access: warm the address and add to BAL
|
|
569
|
+
if (common.isActivatedEIP(2929)) {
|
|
570
|
+
(0, EIP2929_ts_1.warmAddress)(runState, toAddress.bytes);
|
|
571
|
+
}
|
|
572
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, toAddress.bytes, common);
|
|
573
|
+
// Add the value transfer gas (already computed above)
|
|
574
|
+
gas += valueTransferGas;
|
|
575
|
+
// EIP-7702: Get delegation access cost (no side effects)
|
|
576
|
+
let delegationAddress = null;
|
|
577
|
+
if (common.isActivatedEIP(7702)) {
|
|
578
|
+
const { gas: delegationGas, delegationAddress: delAddr } = await eip7702GetAccessCost(runState, common, toAddress, charge2929Gas);
|
|
579
|
+
delegationAddress = delAddr;
|
|
580
|
+
gas += delegationGas;
|
|
581
|
+
// EIP-7928: Check gas before committing delegation access
|
|
582
|
+
if (common.isActivatedEIP(7928) && delegationAddress !== null) {
|
|
583
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
584
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
585
|
+
}
|
|
586
|
+
// Commit delegation access: warm and add to BAL
|
|
587
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
588
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, delegationAddress, common);
|
|
589
|
+
}
|
|
590
|
+
else if (delegationAddress !== null) {
|
|
591
|
+
// No BAL check needed, just warm the address
|
|
592
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
const gasLimit = (0, util_ts_1.maxCallGas)(currentGasLimit, runState.interpreter.getGasLeft() - gas, runState, common);
|
|
596
|
+
// note that TangerineWhistle or later this cannot happen
|
|
597
|
+
// (it could have ran out of gas prior to getting here though)
|
|
598
|
+
if (gasLimit > runState.interpreter.getGasLeft() - gas) {
|
|
599
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
600
|
+
}
|
|
601
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
602
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
603
|
+
}
|
|
604
|
+
runState.messageGasLimit = gasLimit;
|
|
605
|
+
return gas;
|
|
606
|
+
},
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
/* RETURN */
|
|
610
|
+
0xf3,
|
|
611
|
+
async function (runState, gas, common) {
|
|
612
|
+
const [offset, length] = runState.stack.peek(2);
|
|
613
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, length, common);
|
|
614
|
+
return gas;
|
|
615
|
+
},
|
|
616
|
+
],
|
|
617
|
+
[
|
|
618
|
+
/* DELEGATECALL */
|
|
619
|
+
0xf4,
|
|
620
|
+
async function (runState, gas, common) {
|
|
621
|
+
const [currentGasLimit, toAddr, inOffset, inLength, outOffset, outLength] = runState.stack.peek(6);
|
|
622
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
623
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
624
|
+
gas += (0, util_ts_1.subMemUsage)(runState, outOffset, outLength, common);
|
|
625
|
+
// EIP-7928: Early OOG check before address access
|
|
626
|
+
// If we don't have enough gas to proceed, trap before adding to BAL
|
|
627
|
+
if (common.isActivatedEIP(7928) && gas > runState.interpreter.getGasLeft()) {
|
|
628
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
629
|
+
}
|
|
630
|
+
let charge2929Gas = true;
|
|
631
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
632
|
+
runState.interpreter._evm.getPrecompile(toAddress) === undefined) {
|
|
633
|
+
const coldAccessGas = runState.env.accessWitness.readAccountBasicData(toAddress);
|
|
634
|
+
gas += coldAccessGas;
|
|
635
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
636
|
+
}
|
|
637
|
+
// EIP-2929/7928: Get target access cost first (no side effects)
|
|
638
|
+
let targetAccessCost = util_1.BIGINT_0;
|
|
639
|
+
if (common.isActivatedEIP(2929)) {
|
|
640
|
+
targetAccessCost = (0, EIP2929_ts_1.getAddressAccessCost)(runState, toAddress.bytes, common, charge2929Gas);
|
|
641
|
+
gas += targetAccessCost;
|
|
642
|
+
}
|
|
643
|
+
// EIP-7928: Check gas before committing target access
|
|
644
|
+
if (common.isActivatedEIP(7928) && gas > runState.interpreter.getGasLeft()) {
|
|
645
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
646
|
+
}
|
|
647
|
+
// Now commit target access: warm the address and add to BAL
|
|
648
|
+
if (common.isActivatedEIP(2929)) {
|
|
649
|
+
(0, EIP2929_ts_1.warmAddress)(runState, toAddress.bytes);
|
|
650
|
+
}
|
|
651
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, toAddress.bytes, common);
|
|
652
|
+
// EIP-7702: Get delegation access cost (no side effects)
|
|
653
|
+
let delegationAddress = null;
|
|
654
|
+
if (common.isActivatedEIP(7702)) {
|
|
655
|
+
const { gas: delegationGas, delegationAddress: delAddr } = await eip7702GetAccessCost(runState, common, toAddress, charge2929Gas);
|
|
656
|
+
delegationAddress = delAddr;
|
|
657
|
+
gas += delegationGas;
|
|
658
|
+
// EIP-7928: Check gas before committing delegation access
|
|
659
|
+
if (common.isActivatedEIP(7928) && delegationAddress !== null) {
|
|
660
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
661
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
662
|
+
}
|
|
663
|
+
// Commit delegation access: warm and add to BAL
|
|
664
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
665
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, delegationAddress, common);
|
|
666
|
+
}
|
|
667
|
+
else if (delegationAddress !== null) {
|
|
668
|
+
// No BAL check needed, just warm the address
|
|
669
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
const gasLimit = (0, util_ts_1.maxCallGas)(currentGasLimit, runState.interpreter.getGasLeft() - gas, runState, common);
|
|
673
|
+
// note that TangerineWhistle or later this cannot happen
|
|
674
|
+
// (it could have ran out of gas prior to getting here though)
|
|
675
|
+
if (gasLimit > runState.interpreter.getGasLeft() - gas) {
|
|
676
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
677
|
+
}
|
|
678
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
679
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
680
|
+
}
|
|
681
|
+
runState.messageGasLimit = gasLimit;
|
|
682
|
+
return gas;
|
|
683
|
+
},
|
|
684
|
+
],
|
|
685
|
+
[
|
|
686
|
+
/* CREATE2 */
|
|
687
|
+
0xf5,
|
|
688
|
+
async function (runState, gas, common) {
|
|
689
|
+
if (runState.interpreter.isStatic()) {
|
|
690
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
691
|
+
}
|
|
692
|
+
const [_value, offset, length, _salt] = runState.stack.peek(4);
|
|
693
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, length, common);
|
|
694
|
+
if (common.isActivatedEIP(2929)) {
|
|
695
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, runState.interpreter.getAddress().bytes, common, false);
|
|
696
|
+
}
|
|
697
|
+
if (common.isActivatedEIP(3860)) {
|
|
698
|
+
gas += ((length + util_1.BIGINT_31) / util_1.BIGINT_32) * common.param('initCodeWordGas');
|
|
699
|
+
}
|
|
700
|
+
gas += common.param('keccak256WordGas') * (0, util_ts_1.divCeil)(length, util_1.BIGINT_32);
|
|
701
|
+
let gasLimit = runState.interpreter.getGasLeft() - gas;
|
|
702
|
+
gasLimit = (0, util_ts_1.maxCallGas)(gasLimit, gasLimit, runState, common); // CREATE2 is only available after TangerineWhistle (Constantinople introduced this opcode)
|
|
703
|
+
runState.messageGasLimit = gasLimit;
|
|
704
|
+
return gas;
|
|
705
|
+
},
|
|
706
|
+
],
|
|
707
|
+
/* EXTCALL */
|
|
708
|
+
[
|
|
709
|
+
0xf8,
|
|
710
|
+
async function (runState, gas, common) {
|
|
711
|
+
if (runState.env.eof === undefined) {
|
|
712
|
+
// Opcode not available in legacy contracts
|
|
713
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
|
|
714
|
+
}
|
|
715
|
+
// Charge WARM_STORAGE_READ_COST (100) -> done in accessAddressEIP2929
|
|
716
|
+
// Peek stack values
|
|
717
|
+
const [toAddr, inOffset, inLength, value] = runState.stack.peek(4);
|
|
718
|
+
// If value is nonzero and in static mode, throw:
|
|
719
|
+
if (runState.interpreter.isStatic() && value !== util_1.BIGINT_0) {
|
|
720
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
721
|
+
}
|
|
722
|
+
// If value > 0, charge CALL_VALUE_COST
|
|
723
|
+
if (value > util_1.BIGINT_0) {
|
|
724
|
+
gas += common.param('callValueTransferGas');
|
|
725
|
+
}
|
|
726
|
+
// Check if the target address > 20 bytes
|
|
727
|
+
if (toAddr > EXTCALL_TARGET_MAX) {
|
|
728
|
+
(0, util_ts_1.trap)(errors_ts_1.EOFErrorMessage.INVALID_EXTCALL_TARGET);
|
|
729
|
+
}
|
|
730
|
+
// Charge for memory expansion
|
|
731
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
732
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
733
|
+
// Charge to make address warm (2600 gas)
|
|
734
|
+
// (in case if address is already warm, this charges the 100 gas)
|
|
735
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, toAddress.bytes, common);
|
|
736
|
+
// Charge account creation cost if value is nonzero
|
|
737
|
+
if (value > util_1.BIGINT_0) {
|
|
738
|
+
const account = await runState.stateManager.getAccount(toAddress);
|
|
739
|
+
const deadAccount = account === undefined || account.isEmpty();
|
|
740
|
+
if (deadAccount) {
|
|
741
|
+
gas += common.param('callNewAccountGas');
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
const minRetainedGas = common.param('minRetainedGas');
|
|
745
|
+
const minCalleeGas = common.param('minCalleeGas');
|
|
746
|
+
const currentGasAvailable = runState.interpreter.getGasLeft() - gas;
|
|
747
|
+
const reducedGas = currentGasAvailable / util_1.BIGINT_64;
|
|
748
|
+
// Calculate the gas limit for the callee
|
|
749
|
+
// (this is the gas available for the next call frame)
|
|
750
|
+
let gasLimit;
|
|
751
|
+
if (reducedGas < minRetainedGas) {
|
|
752
|
+
gasLimit = currentGasAvailable - minRetainedGas;
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
gasLimit = currentGasAvailable - reducedGas;
|
|
756
|
+
}
|
|
757
|
+
if (runState.env.depth >= Number(common.param('stackLimit')) ||
|
|
758
|
+
runState.env.contract.balance < value ||
|
|
759
|
+
gasLimit < minCalleeGas) {
|
|
760
|
+
// Note: this is a hack, TODO: get around this hack and clean this up
|
|
761
|
+
// This special case will ensure that the actual EXT*CALL is being ran,
|
|
762
|
+
// But, the code in `function.ts` will note that `runState.messageGasLimit` is set to a negative number
|
|
763
|
+
// This special number signals that `1` should be put on the stack (per spec)
|
|
764
|
+
gasLimit = -util_1.BIGINT_1;
|
|
765
|
+
}
|
|
766
|
+
runState.messageGasLimit = gasLimit;
|
|
767
|
+
return gas;
|
|
768
|
+
},
|
|
769
|
+
],
|
|
770
|
+
/* EXTDELEGATECALL */
|
|
771
|
+
[
|
|
772
|
+
0xf9,
|
|
773
|
+
async function (runState, gas, common) {
|
|
774
|
+
if (runState.env.eof === undefined) {
|
|
775
|
+
// Opcode not available in legacy contracts
|
|
776
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
|
|
777
|
+
}
|
|
778
|
+
// Charge WARM_STORAGE_READ_COST (100) -> done in accessAddressEIP2929
|
|
779
|
+
// Peek stack values
|
|
780
|
+
const [toAddr, inOffset, inLength] = runState.stack.peek(3);
|
|
781
|
+
// Check if the target address > 20 bytes
|
|
782
|
+
if (toAddr > EXTCALL_TARGET_MAX) {
|
|
783
|
+
(0, util_ts_1.trap)(errors_ts_1.EOFErrorMessage.INVALID_EXTCALL_TARGET);
|
|
784
|
+
}
|
|
785
|
+
// Charge for memory expansion
|
|
786
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
787
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
788
|
+
// Charge to make address warm (2600 gas)
|
|
789
|
+
// (in case if address is already warm, this charges the 100 gas)
|
|
790
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, toAddress.bytes, common);
|
|
791
|
+
const minRetainedGas = common.param('minRetainedGas');
|
|
792
|
+
const minCalleeGas = common.param('minCalleeGas');
|
|
793
|
+
const currentGasAvailable = runState.interpreter.getGasLeft() - gas;
|
|
794
|
+
const reducedGas = currentGasAvailable / util_1.BIGINT_64;
|
|
795
|
+
// Calculate the gas limit for the callee
|
|
796
|
+
// (this is the gas available for the next call frame)
|
|
797
|
+
let gasLimit;
|
|
798
|
+
if (reducedGas < minRetainedGas) {
|
|
799
|
+
gasLimit = currentGasAvailable - minRetainedGas;
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
gasLimit = currentGasAvailable - reducedGas;
|
|
803
|
+
}
|
|
804
|
+
if (runState.env.depth >= Number(common.param('stackLimit')) || gasLimit < minCalleeGas) {
|
|
805
|
+
// Note: this is a hack, TODO: get around this hack and clean this up
|
|
806
|
+
// This special case will ensure that the actual EXT*CALL is being ran,
|
|
807
|
+
// But, the code in `function.ts` will note that `runState.messageGasLimit` is set to a negative number
|
|
808
|
+
// This special number signals that `1` should be put on the stack (per spec)
|
|
809
|
+
gasLimit = -util_1.BIGINT_1;
|
|
810
|
+
}
|
|
811
|
+
runState.messageGasLimit = gasLimit;
|
|
812
|
+
return gas;
|
|
813
|
+
},
|
|
814
|
+
],
|
|
815
|
+
[
|
|
816
|
+
/* STATICCALL */
|
|
817
|
+
0xfa,
|
|
818
|
+
async function (runState, gas, common) {
|
|
819
|
+
const [currentGasLimit, toAddr, inOffset, inLength, outOffset, outLength] = runState.stack.peek(6);
|
|
820
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
821
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
822
|
+
gas += (0, util_ts_1.subMemUsage)(runState, outOffset, outLength, common);
|
|
823
|
+
// EIP-7928: Early OOG check before address access
|
|
824
|
+
// If we don't have enough gas to proceed, trap before adding to BAL
|
|
825
|
+
if (common.isActivatedEIP(7928) && gas > runState.interpreter.getGasLeft()) {
|
|
826
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
827
|
+
}
|
|
828
|
+
let charge2929Gas = true;
|
|
829
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
830
|
+
runState.interpreter._evm.getPrecompile(toAddress) === undefined) {
|
|
831
|
+
const coldAccessGas = runState.env.accessWitness.readAccountBasicData(toAddress);
|
|
832
|
+
gas += coldAccessGas;
|
|
833
|
+
charge2929Gas = coldAccessGas === util_1.BIGINT_0;
|
|
834
|
+
}
|
|
835
|
+
// EIP-2929/7928: Get target access cost first (no side effects)
|
|
836
|
+
let targetAccessCost = util_1.BIGINT_0;
|
|
837
|
+
if (common.isActivatedEIP(2929)) {
|
|
838
|
+
targetAccessCost = (0, EIP2929_ts_1.getAddressAccessCost)(runState, toAddress.bytes, common, charge2929Gas);
|
|
839
|
+
gas += targetAccessCost;
|
|
840
|
+
}
|
|
841
|
+
// EIP-7928: Check gas before committing target access
|
|
842
|
+
if (common.isActivatedEIP(7928) && gas > runState.interpreter.getGasLeft()) {
|
|
843
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
844
|
+
}
|
|
845
|
+
// Now commit target access: warm the address and add to BAL
|
|
846
|
+
if (common.isActivatedEIP(2929)) {
|
|
847
|
+
(0, EIP2929_ts_1.warmAddress)(runState, toAddress.bytes);
|
|
848
|
+
}
|
|
849
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, toAddress.bytes, common);
|
|
850
|
+
// EIP-7702: Get delegation access cost (no side effects)
|
|
851
|
+
let delegationAddress = null;
|
|
852
|
+
if (common.isActivatedEIP(7702)) {
|
|
853
|
+
const { gas: delegationGas, delegationAddress: delAddr } = await eip7702GetAccessCost(runState, common, toAddress, charge2929Gas);
|
|
854
|
+
delegationAddress = delAddr;
|
|
855
|
+
gas += delegationGas;
|
|
856
|
+
// EIP-7928: Check gas before committing delegation access
|
|
857
|
+
if (common.isActivatedEIP(7928) && delegationAddress !== null) {
|
|
858
|
+
if (gas > runState.interpreter.getGasLeft()) {
|
|
859
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.OUT_OF_GAS);
|
|
860
|
+
}
|
|
861
|
+
// Commit delegation access: warm and add to BAL
|
|
862
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
863
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, delegationAddress, common);
|
|
864
|
+
}
|
|
865
|
+
else if (delegationAddress !== null) {
|
|
866
|
+
// No BAL check needed, just warm the address
|
|
867
|
+
eip7702WarmAddress(runState, delegationAddress);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const gasLimit = (0, util_ts_1.maxCallGas)(currentGasLimit, runState.interpreter.getGasLeft() - gas, runState, common); // we set TangerineWhistle or later to true here, as STATICCALL was available from Byzantium (which is after TangerineWhistle)
|
|
871
|
+
runState.messageGasLimit = gasLimit;
|
|
872
|
+
return gas;
|
|
873
|
+
},
|
|
874
|
+
],
|
|
875
|
+
/* EXTSTATICCALL */
|
|
876
|
+
[
|
|
877
|
+
0xfb,
|
|
878
|
+
async function (runState, gas, common) {
|
|
879
|
+
if (runState.env.eof === undefined) {
|
|
880
|
+
// Opcode not available in legacy contracts
|
|
881
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.INVALID_OPCODE);
|
|
882
|
+
}
|
|
883
|
+
// Charge WARM_STORAGE_READ_COST (100) -> done in accessAddressEIP2929
|
|
884
|
+
// Peek stack values
|
|
885
|
+
const [toAddr, inOffset, inLength] = runState.stack.peek(3);
|
|
886
|
+
// Check if the target address > 20 bytes
|
|
887
|
+
if (toAddr > EXTCALL_TARGET_MAX) {
|
|
888
|
+
(0, util_ts_1.trap)(errors_ts_1.EOFErrorMessage.INVALID_EXTCALL_TARGET);
|
|
889
|
+
}
|
|
890
|
+
// Charge for memory expansion
|
|
891
|
+
gas += (0, util_ts_1.subMemUsage)(runState, inOffset, inLength, common);
|
|
892
|
+
const toAddress = (0, util_ts_1.createAddressFromStackBigInt)(toAddr);
|
|
893
|
+
// Charge to make address warm (2600 gas)
|
|
894
|
+
// (in case if address is already warm, this charges the 100 gas)
|
|
895
|
+
gas += (0, EIP2929_ts_1.accessAddressEIP2929)(runState, toAddress.bytes, common);
|
|
896
|
+
const minRetainedGas = common.param('minRetainedGas');
|
|
897
|
+
const minCalleeGas = common.param('minCalleeGas');
|
|
898
|
+
const currentGasAvailable = runState.interpreter.getGasLeft() - gas;
|
|
899
|
+
const reducedGas = currentGasAvailable / util_1.BIGINT_64;
|
|
900
|
+
// Calculate the gas limit for the callee
|
|
901
|
+
// (this is the gas available for the next call frame)
|
|
902
|
+
let gasLimit;
|
|
903
|
+
if (reducedGas < minRetainedGas) {
|
|
904
|
+
gasLimit = currentGasAvailable - minRetainedGas;
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
gasLimit = currentGasAvailable - reducedGas;
|
|
908
|
+
}
|
|
909
|
+
if (runState.env.depth >= Number(common.param('stackLimit')) || gasLimit < minCalleeGas) {
|
|
910
|
+
// Note: this is a hack, TODO: get around this hack and clean this up
|
|
911
|
+
// This special case will ensure that the actual EXT*CALL is being ran,
|
|
912
|
+
// But, the code in `function.ts` will note that `runState.messageGasLimit` is set to a negative number
|
|
913
|
+
// This special number signals that `1` should be put on the stack (per spec)
|
|
914
|
+
gasLimit = -util_1.BIGINT_1;
|
|
915
|
+
}
|
|
916
|
+
runState.messageGasLimit = gasLimit;
|
|
917
|
+
return gas;
|
|
918
|
+
},
|
|
919
|
+
],
|
|
920
|
+
[
|
|
921
|
+
/* REVERT */
|
|
922
|
+
0xfd,
|
|
923
|
+
async function (runState, gas, common) {
|
|
924
|
+
const [offset, length] = runState.stack.peek(2);
|
|
925
|
+
gas += (0, util_ts_1.subMemUsage)(runState, offset, length, common);
|
|
926
|
+
return gas;
|
|
927
|
+
},
|
|
928
|
+
],
|
|
929
|
+
[
|
|
930
|
+
/* SELFDESTRUCT */
|
|
931
|
+
0xff,
|
|
932
|
+
async function (runState, gas, common) {
|
|
933
|
+
if (runState.interpreter.isStatic()) {
|
|
934
|
+
(0, util_ts_1.trap)(errors_ts_2.EVMError.errorMessages.STATIC_STATE_CHANGE);
|
|
935
|
+
}
|
|
936
|
+
const selfdestructToaddressBigInt = runState.stack.peek()[0];
|
|
937
|
+
const selfdestructToAddress = (0, util_ts_1.createAddressFromStackBigInt)(selfdestructToaddressBigInt);
|
|
938
|
+
const contractAddress = runState.interpreter.getAddress();
|
|
939
|
+
const balance = await runState.interpreter.getExternalBalance(contractAddress);
|
|
940
|
+
// Calculate new account gas first (needed for checkpoint ordering)
|
|
941
|
+
let newAccountGas = util_1.BIGINT_0;
|
|
942
|
+
if (common.gteHardfork(common_1.Hardfork.SpuriousDragon)) {
|
|
943
|
+
// EIP-161: State Trie Clearing
|
|
944
|
+
if (balance > util_1.BIGINT_0) {
|
|
945
|
+
// This technically checks if account is empty or non-existent
|
|
946
|
+
const account = await runState.stateManager.getAccount(selfdestructToAddress);
|
|
947
|
+
if (account === undefined || account.isEmpty()) {
|
|
948
|
+
newAccountGas = common.param('callNewAccountGas');
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
else if (common.gteHardfork(common_1.Hardfork.TangerineWhistle)) {
|
|
953
|
+
// EIP-150 (Tangerine Whistle) gas semantics
|
|
954
|
+
const exists = (await runState.stateManager.getAccount(selfdestructToAddress)) !== undefined;
|
|
955
|
+
if (!exists) {
|
|
956
|
+
newAccountGas = common.param('callNewAccountGas');
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
let selfDestructToCharge2929Gas = true;
|
|
960
|
+
if ((common.isActivatedEIP(6800) || common.isActivatedEIP(7864)) &&
|
|
961
|
+
runState.env.chargeCodeAccesses === true) {
|
|
962
|
+
gas += runState.env.accessWitness.readAccountBasicData(contractAddress);
|
|
963
|
+
if (balance > util_1.BIGINT_0) {
|
|
964
|
+
gas += runState.env.accessWitness.writeAccountBasicData(contractAddress);
|
|
965
|
+
}
|
|
966
|
+
let selfDestructToColdAccessGas = runState.env.accessWitness.readAccountBasicData(selfdestructToAddress);
|
|
967
|
+
if (balance > util_1.BIGINT_0) {
|
|
968
|
+
selfDestructToColdAccessGas +=
|
|
969
|
+
runState.env.accessWitness.writeAccountBasicData(selfdestructToAddress);
|
|
970
|
+
}
|
|
971
|
+
gas += selfDestructToColdAccessGas;
|
|
972
|
+
selfDestructToCharge2929Gas = selfDestructToColdAccessGas === util_1.BIGINT_0;
|
|
973
|
+
}
|
|
974
|
+
// EIP-2929/7928: Get cold access cost first (no side effects)
|
|
975
|
+
let coldAccessCost = util_1.BIGINT_0;
|
|
976
|
+
if (common.isActivatedEIP(2929)) {
|
|
977
|
+
coldAccessCost = (0, EIP2929_ts_1.getAddressAccessCost)(runState, selfdestructToAddress.bytes, common, selfDestructToCharge2929Gas, true);
|
|
978
|
+
gas += coldAccessCost;
|
|
979
|
+
}
|
|
980
|
+
// EIP-7928: Check if we have enough gas for the cold access (checkpoint 1)
|
|
981
|
+
// If yes, add beneficiary to BAL - this is the "state access" point
|
|
982
|
+
// The newAccountGas (checkpoint 2) is added after, so OOG there still records BAL
|
|
983
|
+
if (common.isActivatedEIP(7928)) {
|
|
984
|
+
// Only add to BAL if we have enough gas for the current accumulated cost
|
|
985
|
+
// (base gas + cold access). newAccountGas is NOT included here because
|
|
986
|
+
// per EIP-7928, if we pass the cold access check but fail at new account
|
|
987
|
+
// creation, the beneficiary should still be in BAL.
|
|
988
|
+
if (gas <= runState.interpreter.getGasLeft()) {
|
|
989
|
+
(0, EIP2929_ts_1.addAddressToBAL)(runState, selfdestructToAddress.bytes, common);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
// Now commit the address warming (EIP-2929)
|
|
993
|
+
if (common.isActivatedEIP(2929)) {
|
|
994
|
+
(0, EIP2929_ts_1.warmAddress)(runState, selfdestructToAddress.bytes);
|
|
995
|
+
}
|
|
996
|
+
// Add new account gas (checkpoint 2)
|
|
997
|
+
gas += newAccountGas;
|
|
998
|
+
return gas;
|
|
999
|
+
},
|
|
1000
|
+
],
|
|
1001
|
+
]);
|
|
1002
|
+
// Set the range [0xa0, 0xa4] to the LOG handler
|
|
1003
|
+
const logDynamicFunc = exports.dynamicGasHandlers.get(0xa0);
|
|
1004
|
+
for (let i = 0xa1; i <= 0xa4; i++) {
|
|
1005
|
+
exports.dynamicGasHandlers.set(i, logDynamicFunc);
|
|
1006
|
+
}
|
|
1007
|
+
// EIP-8141: FRAMEDATACOPY dynamic gas (matches CALLDATACOPY)
|
|
1008
|
+
exports.dynamicGasHandlers.set(0xb2, async function (runState, gas, common) {
|
|
1009
|
+
const [memOffset, _dataOffset, dataLength] = runState.stack.peek(4);
|
|
1010
|
+
gas += (0, util_ts_1.subMemUsage)(runState, memOffset, dataLength, common);
|
|
1011
|
+
if (dataLength !== util_1.BIGINT_0) {
|
|
1012
|
+
gas += common.param('copyGas') * (0, util_ts_1.divCeil)(dataLength, util_1.BIGINT_32);
|
|
1013
|
+
}
|
|
1014
|
+
return gas;
|
|
1015
|
+
});
|
|
1016
|
+
//# sourceMappingURL=gas.js.map
|