@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,495 @@
|
|
|
1
|
+
import { EthereumJSErrorWithoutCode } from '@feelyourprotocol/util'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CODE_MIN,
|
|
5
|
+
CODE_SIZE_MIN,
|
|
6
|
+
CONTAINER_MAX,
|
|
7
|
+
CONTAINER_MIN,
|
|
8
|
+
CONTAINER_SIZE_MIN,
|
|
9
|
+
FORMAT,
|
|
10
|
+
INPUTS_MAX,
|
|
11
|
+
KIND_CODE,
|
|
12
|
+
KIND_CONTAINER,
|
|
13
|
+
KIND_DATA,
|
|
14
|
+
KIND_TYPE,
|
|
15
|
+
MAGIC,
|
|
16
|
+
MAX_HEADER_SIZE,
|
|
17
|
+
MAX_STACK_HEIGHT,
|
|
18
|
+
OUTPUTS_MAX,
|
|
19
|
+
TERMINATOR,
|
|
20
|
+
TYPE_DIVISOR,
|
|
21
|
+
TYPE_MAX,
|
|
22
|
+
TYPE_MIN,
|
|
23
|
+
VERSION,
|
|
24
|
+
} from './constants.ts'
|
|
25
|
+
import { EOFErrorMessage, validationError } from './errors.ts'
|
|
26
|
+
import { ContainerSectionType, verifyCode } from './verify.ts'
|
|
27
|
+
|
|
28
|
+
import type { EVM } from '../evm.ts'
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
This file creates EOF Containers
|
|
32
|
+
EOF Containers are described in EIP-3540.
|
|
33
|
+
A container consists of a header and a body. The header describes the layout of the body.
|
|
34
|
+
The body has the actual "interesting" contents, such as the bytecode to run, the data section,
|
|
35
|
+
and possibly yet-to-be-deployed containers (via EOFCREATE, to create new EOF contracts from an existing one)
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
// This enum marks the "mode" of a container
|
|
39
|
+
// Depending on this mode, certain extra checks for validity have to be done, or some checks can be skipped
|
|
40
|
+
export type EOFContainerMode = (typeof EOFContainerMode)[keyof typeof EOFContainerMode]
|
|
41
|
+
|
|
42
|
+
export const EOFContainerMode = {
|
|
43
|
+
Default: 'default', // Default container validation
|
|
44
|
+
Initmode: 'initMode', // Initmode container validation (for subcontainers pointed to by EOFCreate)
|
|
45
|
+
TxInitmode: 'txInitMode', // Tx initmode container validation (for txs deploying EOF contracts)
|
|
46
|
+
} as const
|
|
47
|
+
|
|
48
|
+
// The StreamReader is a helper class to help reading byte arrays
|
|
49
|
+
class StreamReader {
|
|
50
|
+
private data: Uint8Array // Stream to read
|
|
51
|
+
private ptr: number // Current pointer to where the stream is being read
|
|
52
|
+
constructor(stream: Uint8Array) {
|
|
53
|
+
this.data = stream
|
|
54
|
+
this.ptr = 0
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Read `amount` bytes from the stream. Throws when trying to read out of bounds with an optional error string.
|
|
59
|
+
* This also updates the internal pointer
|
|
60
|
+
* @param amount Bytes to read
|
|
61
|
+
* @param errorStr Optional error string to throw when trying to read out-of-bounds
|
|
62
|
+
* @returns The byte array with length `amount`
|
|
63
|
+
*/
|
|
64
|
+
readBytes(amount: number, errorStr?: string) {
|
|
65
|
+
const end = this.ptr + amount
|
|
66
|
+
if (end > this.data.length) {
|
|
67
|
+
validationError(EOFErrorMessage.OUT_OF_BOUNDS, this.ptr, errorStr)
|
|
68
|
+
}
|
|
69
|
+
const ptr = this.ptr
|
|
70
|
+
this.ptr += amount
|
|
71
|
+
return this.data.slice(ptr, end)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Reads an Uint8. Also updates the pointer.
|
|
76
|
+
* @param errorStr Optional error string
|
|
77
|
+
* @returns The uint8
|
|
78
|
+
*/
|
|
79
|
+
readUint(errorStr?: string) {
|
|
80
|
+
if (this.ptr >= this.data.length) {
|
|
81
|
+
validationError(EOFErrorMessage.OUT_OF_BOUNDS, this.ptr, errorStr)
|
|
82
|
+
}
|
|
83
|
+
return this.data[this.ptr++]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Verify that the current uint8 pointed to by the pointer is the expected uint8
|
|
88
|
+
* Also updates the pointer
|
|
89
|
+
* @param expect The uint to expect
|
|
90
|
+
* @param errorStr Optional error string when the read uint is not the expected uint
|
|
91
|
+
*/
|
|
92
|
+
verifyUint(expect: number, errorStr?: string) {
|
|
93
|
+
if (this.readUint() !== expect) {
|
|
94
|
+
validationError(EOFErrorMessage.VERIFY_UINT, this.ptr - 1, errorStr)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Same as readUint, except this reads an uint16
|
|
100
|
+
* @param errorStr - Optional error message to include in thrown validation errors
|
|
101
|
+
* @returns Unsigned 16-bit integer read from the stream
|
|
102
|
+
*/
|
|
103
|
+
readUint16(errorStr?: string) {
|
|
104
|
+
const end = this.ptr + 2
|
|
105
|
+
if (end > this.data.length) {
|
|
106
|
+
validationError(EOFErrorMessage.OUT_OF_BOUNDS, this.ptr, errorStr)
|
|
107
|
+
}
|
|
108
|
+
const ptr = this.ptr
|
|
109
|
+
this.ptr += 2
|
|
110
|
+
return new DataView(this.data.buffer).getUint16(ptr)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get the current pointer of the stream
|
|
115
|
+
* @returns The pointer
|
|
116
|
+
*/
|
|
117
|
+
getPtr() {
|
|
118
|
+
return this.ptr
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Get the remainder bytes of the current stream
|
|
122
|
+
readRemainder() {
|
|
123
|
+
return this.data.slice(this.ptr)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Returns `true` if the stream is fully read, or false if there are dangling bytes
|
|
127
|
+
isAtEnd() {
|
|
128
|
+
return this.ptr === this.data.length
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// TODO add initcode flags (isEOFContract)
|
|
133
|
+
// TODO validation: mark sections as either initcode or runtime code to validate
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The EOFHeader, describing the header of the EOF container
|
|
137
|
+
*/
|
|
138
|
+
class EOFHeader {
|
|
139
|
+
typeSize: number // Size of types section
|
|
140
|
+
codeSizes: number[] // Sizes of code sections
|
|
141
|
+
containerSizes: number[] // Sizes of containers
|
|
142
|
+
dataSize: number // Size of data section
|
|
143
|
+
dataSizePtr: number // Used to edit the dataSize in RETURNCONTRACT
|
|
144
|
+
buffer: Uint8Array // The raw buffer of the entire header
|
|
145
|
+
|
|
146
|
+
private codeStartPos: number[] // Internal array to track at which byte of the container the code starts (per section)
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Create an EOF header. Performs various validation checks inside the constructor
|
|
150
|
+
* @param input either a raw header or a complete container
|
|
151
|
+
*/
|
|
152
|
+
constructor(input: Uint8Array) {
|
|
153
|
+
if (input.length > MAX_HEADER_SIZE) {
|
|
154
|
+
throw EthereumJSErrorWithoutCode('err: container size more than maximum valid size')
|
|
155
|
+
}
|
|
156
|
+
const stream = new StreamReader(input)
|
|
157
|
+
// Verify that the header starts with 0xEF0001
|
|
158
|
+
stream.verifyUint(FORMAT, EOFErrorMessage.FORMAT)
|
|
159
|
+
stream.verifyUint(MAGIC, EOFErrorMessage.MAGIC)
|
|
160
|
+
stream.verifyUint(VERSION, EOFErrorMessage.VERSION)
|
|
161
|
+
if (input.length < 15) {
|
|
162
|
+
throw EthereumJSErrorWithoutCode('err: container size less than minimum valid size')
|
|
163
|
+
}
|
|
164
|
+
// Verify that the types section is present and its length is valid
|
|
165
|
+
stream.verifyUint(KIND_TYPE, EOFErrorMessage.KIND_TYPE)
|
|
166
|
+
const typeSize = stream.readUint16(EOFErrorMessage.TYPE_SIZE)
|
|
167
|
+
if (typeSize < TYPE_MIN) {
|
|
168
|
+
validationError(EOFErrorMessage.INVALID_TYPE_SIZE, typeSize)
|
|
169
|
+
}
|
|
170
|
+
if (typeSize % TYPE_DIVISOR !== 0) {
|
|
171
|
+
validationError(EOFErrorMessage.INVALID_TYPE_SIZE, typeSize)
|
|
172
|
+
}
|
|
173
|
+
if (typeSize > TYPE_MAX) {
|
|
174
|
+
throw EthereumJSErrorWithoutCode(
|
|
175
|
+
`err: number of code sections must not exceed 1024 (got ${typeSize})`,
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
// Verify that the code section is present and its size is valid
|
|
179
|
+
stream.verifyUint(KIND_CODE, EOFErrorMessage.KIND_CODE)
|
|
180
|
+
const codeSize = stream.readUint16(EOFErrorMessage.CODE_SIZE)
|
|
181
|
+
if (codeSize < CODE_MIN) {
|
|
182
|
+
validationError(EOFErrorMessage.MIN_CODE_SECTIONS)
|
|
183
|
+
}
|
|
184
|
+
if (codeSize !== typeSize / TYPE_DIVISOR) {
|
|
185
|
+
validationError(EOFErrorMessage.TYPE_SECTIONS, typeSize / TYPE_DIVISOR, codeSize)
|
|
186
|
+
}
|
|
187
|
+
// Read the actual code sizes in the code section and verify that each section has the minimum size
|
|
188
|
+
const codeSizes = []
|
|
189
|
+
for (let i = 0; i < codeSize; i++) {
|
|
190
|
+
const codeSectionSize = stream.readUint16(EOFErrorMessage.CODE_SECTION)
|
|
191
|
+
if (codeSectionSize < CODE_SIZE_MIN) {
|
|
192
|
+
validationError(EOFErrorMessage.CODE_SECTION_SIZE)
|
|
193
|
+
}
|
|
194
|
+
codeSizes.push(codeSectionSize)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Check if there are container sections
|
|
198
|
+
let nextSection = stream.readUint()
|
|
199
|
+
const containerSizes: number[] = []
|
|
200
|
+
if (nextSection === KIND_CONTAINER) {
|
|
201
|
+
// The optional container section is present, validate that the size is within bounds
|
|
202
|
+
const containerSectionSize = stream.readUint16(EOFErrorMessage.CONTAINER_SIZE)
|
|
203
|
+
|
|
204
|
+
if (containerSectionSize < CONTAINER_MIN) {
|
|
205
|
+
validationError(EOFErrorMessage.CONTAINER_SECTION_SIZE)
|
|
206
|
+
}
|
|
207
|
+
if (containerSectionSize > CONTAINER_MAX) {
|
|
208
|
+
validationError(EOFErrorMessage.CONTAINER_SECTION_SIZE)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Read the actual container sections and validate that each section has the minimum size
|
|
212
|
+
for (let i = 0; i < containerSectionSize; i++) {
|
|
213
|
+
const containerSize = stream.readUint16(EOFErrorMessage.CONTAINER_SECTION)
|
|
214
|
+
|
|
215
|
+
if (containerSize < CONTAINER_SIZE_MIN) {
|
|
216
|
+
validationError(EOFErrorMessage.CONTAINER_SECTION_MIN)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
containerSizes.push(containerSize)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
nextSection = stream.readUint()
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Verify that the next section is of the data type
|
|
226
|
+
if (nextSection !== KIND_DATA) {
|
|
227
|
+
validationError(EOFErrorMessage.KIND_DATA)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
this.dataSizePtr = stream.getPtr()
|
|
231
|
+
|
|
232
|
+
const dataSize = stream.readUint16(EOFErrorMessage.DATA_SIZE)
|
|
233
|
+
|
|
234
|
+
// Verify that the header ends with the TERMINATOR byte
|
|
235
|
+
stream.verifyUint(TERMINATOR, EOFErrorMessage.TERMINATOR)
|
|
236
|
+
|
|
237
|
+
// Write all values to the header object
|
|
238
|
+
this.typeSize = typeSize
|
|
239
|
+
this.codeSizes = codeSizes
|
|
240
|
+
this.containerSizes = containerSizes
|
|
241
|
+
this.dataSize = dataSize
|
|
242
|
+
// Slice the input such that `this.buffer` is now the complete header
|
|
243
|
+
// If there are dangling bytes in the stream, this is OK: this is the body section of the container
|
|
244
|
+
this.buffer = input.slice(0, stream.getPtr())
|
|
245
|
+
const relativeOffset = this.buffer.length + this.typeSize
|
|
246
|
+
// Write the start of the first code section into `codeStartPos`
|
|
247
|
+
// Note: in EVM, if one would set the Program Counter to this byte, it would start executing the bytecode of the first code section
|
|
248
|
+
this.codeStartPos = [relativeOffset]
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
sections() {
|
|
252
|
+
return [this.typeSize, this.codeSizes, this.containerSizes, this.dataSize]
|
|
253
|
+
}
|
|
254
|
+
sectionSizes() {
|
|
255
|
+
return [1, this.codeSizes.length, this.containerSizes.length, 1]
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Returns the code position in the container for the requested section
|
|
259
|
+
// Setting the Program Counter in the EVM to a number of this array would start executing the bytecode of the indexed section
|
|
260
|
+
getCodePosition(section: number) {
|
|
261
|
+
if (this.codeStartPos[section]) {
|
|
262
|
+
return this.codeStartPos[section]
|
|
263
|
+
}
|
|
264
|
+
const start = this.codeStartPos.length
|
|
265
|
+
let offset = this.codeStartPos[start - 1]
|
|
266
|
+
for (let i = start; i <= section; i++) {
|
|
267
|
+
offset += this.codeSizes[i - 1]
|
|
268
|
+
this.codeStartPos[i] = offset
|
|
269
|
+
}
|
|
270
|
+
return offset
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Returns the code section for a given program counter position
|
|
274
|
+
getSectionFromProgramCounter(programCounter: number) {
|
|
275
|
+
const lastIndex = this.codeSizes.length - 1
|
|
276
|
+
const lastStart = this.getCodePosition(lastIndex)
|
|
277
|
+
const lastEnd = lastStart + this.codeSizes[lastIndex]
|
|
278
|
+
if (programCounter < 0 || programCounter > lastEnd) {
|
|
279
|
+
// If code position is outside the beginning or end of the code sections, return 0
|
|
280
|
+
throw EthereumJSErrorWithoutCode('program counter out of bounds')
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (this.codeStartPos.length < this.codeSizes.length) {
|
|
284
|
+
this.getCodePosition(this.codeSizes.length - 1) // initialize code positions if uninitialized
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
for (let i = 0; i < this.codeSizes.length; i++) {
|
|
288
|
+
if (programCounter < this.codeStartPos[i] + this.codeSizes[i]) {
|
|
289
|
+
// We've found our section if the code position is less than the end of the current code section
|
|
290
|
+
return i
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// This shouldn't happen so just error
|
|
294
|
+
throw EthereumJSErrorWithoutCode(`Invalid program counter value: ${programCounter}`)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface TypeSection {
|
|
299
|
+
inputs: number
|
|
300
|
+
outputs: number
|
|
301
|
+
maxStackHeight: number
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The EOF body holds the contents of the EOF container, such as the code sections (bytecode),
|
|
306
|
+
* the subcontainers (EOF containers to be deployed via EOFCREATE) and the data section
|
|
307
|
+
*/
|
|
308
|
+
class EOFBody {
|
|
309
|
+
typeSections: TypeSection[] // Array of type sections, used to index the inputs/outputs/max stack height of each section
|
|
310
|
+
codeSections: Uint8Array[] // Bytecode of each code section
|
|
311
|
+
containerSections: Uint8Array[] // Raw container bytes of each subcontainer
|
|
312
|
+
entireCode: Uint8Array // The `entireCode` are all code sections concatenated
|
|
313
|
+
dataSection: Uint8Array // Bytes of the data section
|
|
314
|
+
buffer: Uint8Array // Raw bytes of the body
|
|
315
|
+
|
|
316
|
+
txCallData?: Uint8Array // Only available in TxInitmode. The `txCallData` are the dangling bytes after parsing the container,
|
|
317
|
+
// and these are used for the CALLDATA in the EVM when trying to create a contract via a transaction, and the deployment code is an EOF container
|
|
318
|
+
|
|
319
|
+
constructor(
|
|
320
|
+
buf: Uint8Array, // Buffer of the body. This should be the entire body. It is not valid to pass an entire EOF container in here
|
|
321
|
+
header: EOFHeader, // EOFHeader corresponding to this body
|
|
322
|
+
eofMode: EOFContainerMode = EOFContainerMode.Default, // Container mode of EOF
|
|
323
|
+
dataSectionAllowedSmaller = false, // Only for validation: Deployment containers are allowed to have smaller data section size
|
|
324
|
+
) {
|
|
325
|
+
const stream = new StreamReader(buf)
|
|
326
|
+
const typeSections: TypeSection[] = []
|
|
327
|
+
// Read and parse each type section, and validate that the type section values are within valid bounds
|
|
328
|
+
for (let i = 0; i < header.typeSize / 4; i++) {
|
|
329
|
+
const inputs = stream.readUint(EOFErrorMessage.INPUTS)
|
|
330
|
+
const outputs = stream.readUint(EOFErrorMessage.OUTPUTS)
|
|
331
|
+
const maxStackHeight = stream.readUint16(EOFErrorMessage.MAX_STACK_HEIGHT)
|
|
332
|
+
if (i === 0) {
|
|
333
|
+
if (inputs !== 0) {
|
|
334
|
+
validationError(EOFErrorMessage.CODE0_INPUTS)
|
|
335
|
+
}
|
|
336
|
+
if (outputs !== 0x80) {
|
|
337
|
+
validationError(EOFErrorMessage.CODE0_OUTPUTS)
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (inputs > INPUTS_MAX) {
|
|
341
|
+
validationError(EOFErrorMessage.MAX_INPUTS, i, inputs)
|
|
342
|
+
}
|
|
343
|
+
if (outputs > OUTPUTS_MAX) {
|
|
344
|
+
validationError(EOFErrorMessage.MAX_OUTPUTS, i, outputs)
|
|
345
|
+
}
|
|
346
|
+
if (maxStackHeight > MAX_STACK_HEIGHT) {
|
|
347
|
+
validationError(EOFErrorMessage.MAX_STACK_HEIGHT_LIMIT, i, maxStackHeight)
|
|
348
|
+
}
|
|
349
|
+
typeSections.push({
|
|
350
|
+
inputs,
|
|
351
|
+
outputs,
|
|
352
|
+
maxStackHeight,
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
// Read each code section
|
|
356
|
+
const codeStartPtr = stream.getPtr()
|
|
357
|
+
const codes = []
|
|
358
|
+
for (const [i, codeSize] of header.codeSizes.entries()) {
|
|
359
|
+
try {
|
|
360
|
+
const code = stream.readBytes(codeSize)
|
|
361
|
+
codes.push(code)
|
|
362
|
+
} catch {
|
|
363
|
+
validationError(EOFErrorMessage.CODE_SECTION, i)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
// Write the entire code section to the entireCodeSection
|
|
367
|
+
const entireCodeSection = buf.slice(codeStartPtr, stream.getPtr())
|
|
368
|
+
|
|
369
|
+
// Read all raw subcontainers and push those to the containers array
|
|
370
|
+
const containers = []
|
|
371
|
+
for (const [i, containerSize] of header.containerSizes.entries()) {
|
|
372
|
+
try {
|
|
373
|
+
const container = stream.readBytes(containerSize)
|
|
374
|
+
containers.push(container)
|
|
375
|
+
} catch {
|
|
376
|
+
validationError(EOFErrorMessage.CONTAINER_SECTION, i)
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Data section of the body
|
|
381
|
+
// Note: for EOF containers in Initmode (these are Subcontainers) it is allowed
|
|
382
|
+
// to have a data section of size lower than what is written in the header
|
|
383
|
+
// For details, see "Data section lifecycle" of EIP 7620
|
|
384
|
+
let dataSection: Uint8Array
|
|
385
|
+
|
|
386
|
+
// Edge case: deployment code validation
|
|
387
|
+
if (eofMode !== EOFContainerMode.Initmode && !dataSectionAllowedSmaller) {
|
|
388
|
+
dataSection = stream.readBytes(header.dataSize, EOFErrorMessage.DATA_SECTION)
|
|
389
|
+
|
|
390
|
+
if (eofMode === EOFContainerMode.Default) {
|
|
391
|
+
if (!stream.isAtEnd()) {
|
|
392
|
+
// If there are dangling bytes in default container mode, this is invalid
|
|
393
|
+
validationError(EOFErrorMessage.DANGLING_BYTES)
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
// Tx init mode: the remaining bytes (if any) are used as CALLDATA in the EVM, in case of a Tx init
|
|
397
|
+
this.txCallData = stream.readRemainder()
|
|
398
|
+
}
|
|
399
|
+
} else {
|
|
400
|
+
dataSection = stream.readRemainder()
|
|
401
|
+
|
|
402
|
+
if (dataSection.length > header.dataSize) {
|
|
403
|
+
validationError(EOFErrorMessage.DANGLING_BYTES)
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// Write all data to the object
|
|
408
|
+
this.typeSections = typeSections
|
|
409
|
+
this.codeSections = codes
|
|
410
|
+
this.containerSections = containers
|
|
411
|
+
this.entireCode = entireCodeSection
|
|
412
|
+
this.dataSection = dataSection
|
|
413
|
+
this.buffer = buf
|
|
414
|
+
}
|
|
415
|
+
sections() {
|
|
416
|
+
return [this.typeSections, this.codeSections, this.dataSection]
|
|
417
|
+
}
|
|
418
|
+
size() {
|
|
419
|
+
return {
|
|
420
|
+
typeSize: this.typeSections.length,
|
|
421
|
+
codeSize: this.codeSections.length,
|
|
422
|
+
dataSize: this.dataSection.length,
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
sectionSizes() {
|
|
426
|
+
return [
|
|
427
|
+
this.typeSections.map(() => 4),
|
|
428
|
+
this.codeSections.map((b) => b.length),
|
|
429
|
+
this.dataSection.length,
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Main constructor for the EOFContainer
|
|
436
|
+
*/
|
|
437
|
+
export class EOFContainer {
|
|
438
|
+
header: EOFHeader
|
|
439
|
+
body: EOFBody
|
|
440
|
+
buffer: Uint8Array
|
|
441
|
+
eofMode: EOFContainerMode
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
*
|
|
445
|
+
* @param buf Entire container buffer
|
|
446
|
+
* @param eofMode Container mode to validate the container on
|
|
447
|
+
* @param dataSectionAllowedSmaller `true` if the data section is allowed to be smaller than the data section size in the header
|
|
448
|
+
*/
|
|
449
|
+
constructor(
|
|
450
|
+
buf: Uint8Array,
|
|
451
|
+
eofMode: EOFContainerMode = EOFContainerMode.Default,
|
|
452
|
+
dataSectionAllowedSmaller = false,
|
|
453
|
+
) {
|
|
454
|
+
this.eofMode = eofMode
|
|
455
|
+
this.header = new EOFHeader(buf)
|
|
456
|
+
this.body = new EOFBody(
|
|
457
|
+
buf.slice(this.header.buffer.length),
|
|
458
|
+
this.header,
|
|
459
|
+
eofMode,
|
|
460
|
+
dataSectionAllowedSmaller,
|
|
461
|
+
)
|
|
462
|
+
this.buffer = buf
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* This method validates the EOF. It also performs deeper validation of the body, such as stack/opcode validation
|
|
468
|
+
* This is ONLY necessary when trying to deploy contracts from a transaction: these can submit containers which are invalid
|
|
469
|
+
* Since all deployed EOF containers are valid by definition, `validateEOF` does not need to be called each time an EOF contract is called
|
|
470
|
+
* @param input Full container buffer
|
|
471
|
+
* @param evm EVM, to read opcodes from
|
|
472
|
+
* @param containerMode Container mode to validate on
|
|
473
|
+
* @param eofMode EOF mode to run in
|
|
474
|
+
* @returns The decoded EOF container
|
|
475
|
+
*/
|
|
476
|
+
export function validateEOF(
|
|
477
|
+
input: Uint8Array,
|
|
478
|
+
evm: EVM,
|
|
479
|
+
containerMode: ContainerSectionType = ContainerSectionType.RuntimeCode,
|
|
480
|
+
eofMode: EOFContainerMode = EOFContainerMode.Default,
|
|
481
|
+
) {
|
|
482
|
+
const container = new EOFContainer(
|
|
483
|
+
input,
|
|
484
|
+
eofMode,
|
|
485
|
+
containerMode === ContainerSectionType.DeploymentCode,
|
|
486
|
+
)
|
|
487
|
+
const containerMap = verifyCode(container, evm, containerMode)
|
|
488
|
+
// Recursively validate the containerSections
|
|
489
|
+
for (let i = 0; i < container.body.containerSections.length; i++) {
|
|
490
|
+
const subContainer = container.body.containerSections[i]
|
|
491
|
+
const mode = containerMap.get(i)!
|
|
492
|
+
validateEOF(subContainer, evm, mode)
|
|
493
|
+
}
|
|
494
|
+
return container
|
|
495
|
+
}
|