diff --git a/.changeset/thick-monkeys-march.md b/.changeset/thick-monkeys-march.md new file mode 100644 index 0000000000..1543496595 --- /dev/null +++ b/.changeset/thick-monkeys-march.md @@ -0,0 +1,5 @@ +--- +"@tevm/utils": minor +--- + +Added randomBytes to `@tevm/utils`. randomBytes(32) will generate 32 random bytes. diff --git a/packages/utils/docs/functions/randomBytes.md b/packages/utils/docs/functions/randomBytes.md new file mode 100644 index 0000000000..7c946280bb --- /dev/null +++ b/packages/utils/docs/functions/randomBytes.md @@ -0,0 +1,25 @@ +[**@tevm/utils**](../README.md) • **Docs** + +*** + +[@tevm/utils](../globals.md) / randomBytes + +# Function: randomBytes() + +> **randomBytes**(`length`): `Uint8Array` + +## Parameters + +• **length**: `number` + +The length of the Uint8Array. + +## Returns + +`Uint8Array` + +A Uint8Array of random bytes of specified length. + +## Defined in + +node\_modules/.pnpm/@ethereumjs+util@9.0.3/node\_modules/@ethereumjs/util/dist/esm/bytes.d.ts:186 diff --git a/packages/utils/docs/globals.md b/packages/utils/docs/globals.md index d4cba029cd..ccb6cd6324 100644 --- a/packages/utils/docs/globals.md +++ b/packages/utils/docs/globals.md @@ -74,6 +74,7 @@ ## Variables +- [GWEI\_TO\_WEI](variables/GWEI_TO_WEI.md) - [KECCAK256\_RLP](variables/KECCAK256_RLP.md) - [KECCAK256\_RLP\_ARRAY](variables/KECCAK256_RLP_ARRAY.md) - [PREFUNDED\_ACCOUNTS](variables/PREFUNDED_ACCOUNTS.md) @@ -133,6 +134,7 @@ - [parseAbi](functions/parseAbi.md) - [parseEther](functions/parseEther.md) - [parseGwei](functions/parseGwei.md) +- [randomBytes](functions/randomBytes.md) - [serializeTransaction](functions/serializeTransaction.md) - [setLengthLeft](functions/setLengthLeft.md) - [stringToHex](functions/stringToHex.md) diff --git a/packages/utils/docs/variables/GWEI_TO_WEI.md b/packages/utils/docs/variables/GWEI_TO_WEI.md new file mode 100644 index 0000000000..ccfa382397 --- /dev/null +++ b/packages/utils/docs/variables/GWEI_TO_WEI.md @@ -0,0 +1,15 @@ +[**@tevm/utils**](../README.md) • **Docs** + +*** + +[@tevm/utils](../globals.md) / GWEI\_TO\_WEI + +# Variable: GWEI\_TO\_WEI + +> `const` **GWEI\_TO\_WEI**: `bigint` + +Easy conversion from Gwei to wei + +## Defined in + +node\_modules/.pnpm/@ethereumjs+util@9.0.3/node\_modules/@ethereumjs/util/dist/esm/units.d.ts:2 diff --git a/packages/utils/src/ethereumjs.js b/packages/utils/src/ethereumjs.js index d202ecfb29..cc17623a72 100644 --- a/packages/utils/src/ethereumjs.js +++ b/packages/utils/src/ethereumjs.js @@ -19,5 +19,6 @@ export { ecrecover, ecsign, zeros, + randomBytes, AsyncEventEmitter, } from '@ethereumjs/util' diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 06ffb26804..f6b372aae3 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -102,6 +102,8 @@ export { ecsign, zeros, AsyncEventEmitter, + GWEI_TO_WEI, + randomBytes, } from './ethereumjs.js' export type { GenesisState, diff --git a/packages/vm/docs/classes/BlockBuilder.md b/packages/vm/docs/classes/BlockBuilder.md index 8bbf7f947e..771050a351 100644 --- a/packages/vm/docs/classes/BlockBuilder.md +++ b/packages/vm/docs/classes/BlockBuilder.md @@ -24,7 +24,7 @@ #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:78](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L78) +[packages/vm/src/actions/BlockBuilder.ts:76](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L76) ## Properties @@ -36,7 +36,7 @@ The cumulative blob gas used by the blobs in a block #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:54](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L54) +[packages/vm/src/actions/BlockBuilder.ts:52](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L52) *** @@ -48,7 +48,7 @@ The cumulative gas used by the transactions added to the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:50](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L50) +[packages/vm/src/actions/BlockBuilder.ts:48](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L48) ## Accessors @@ -62,7 +62,7 @@ The cumulative gas used by the transactions added to the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:74](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L74) +[packages/vm/src/actions/BlockBuilder.ts:72](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L72) *** @@ -76,7 +76,7 @@ The cumulative gas used by the transactions added to the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:70](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L70) +[packages/vm/src/actions/BlockBuilder.ts:68](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L68) ## Methods @@ -103,7 +103,7 @@ the remaining gas in the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:218](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L218) +[packages/vm/src/actions/BlockBuilder.ts:216](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L216) *** @@ -131,7 +131,7 @@ as the signer will be awarded the txs amount spent on gas as they are added. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:309](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L309) +[packages/vm/src/actions/BlockBuilder.ts:307](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L307) *** @@ -145,7 +145,7 @@ as the signer will be awarded the txs amount spent on gas as they are added. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:130](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L130) +[packages/vm/src/actions/BlockBuilder.ts:128](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L128) *** @@ -159,7 +159,7 @@ as the signer will be awarded the txs amount spent on gas as they are added. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:373](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L373) +[packages/vm/src/actions/BlockBuilder.ts:371](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L371) *** @@ -175,7 +175,7 @@ Calculates and returns the logs bloom for the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:147](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L147) +[packages/vm/src/actions/BlockBuilder.ts:145](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L145) *** @@ -191,7 +191,7 @@ Calculates and returns the receiptTrie for the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:159](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L159) +[packages/vm/src/actions/BlockBuilder.ts:157](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L157) *** @@ -207,7 +207,7 @@ Reverts the checkpoint on the StateManager to reset the state from any transacti #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:290](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L290) +[packages/vm/src/actions/BlockBuilder.ts:288](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L288) *** @@ -223,4 +223,4 @@ Calculates and returns the transactionsTrie for the block. #### Defined in -[packages/vm/src/actions/BlockBuilder.ts:137](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L137) +[packages/vm/src/actions/BlockBuilder.ts:135](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L135) diff --git a/packages/vm/docs/functions/accumulateParentBeaconBlockRoot.md b/packages/vm/docs/functions/accumulateParentBeaconBlockRoot.md index 181635d9ea..836b4303d3 100644 --- a/packages/vm/docs/functions/accumulateParentBeaconBlockRoot.md +++ b/packages/vm/docs/functions/accumulateParentBeaconBlockRoot.md @@ -28,4 +28,4 @@ ## Defined in -[packages/vm/src/actions/runBlock.ts:293](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L293) +[packages/vm/src/actions/accumulateParentBeaconBlockRoot.ts:7](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/accumulateParentBeaconBlockRoot.ts#L7) diff --git a/packages/vm/docs/functions/accumulateParentBlockHash.md b/packages/vm/docs/functions/accumulateParentBlockHash.md index 405220d375..a95b3b190c 100644 --- a/packages/vm/docs/functions/accumulateParentBlockHash.md +++ b/packages/vm/docs/functions/accumulateParentBlockHash.md @@ -34,4 +34,4 @@ also add the currently available past blockhashes which are available by BLOCKHA ## Defined in -[packages/vm/src/actions/runBlock.ts:250](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L250) +[packages/vm/src/actions/accumulateParentBlockHash.ts:15](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/accumulateParentBlockHash.ts#L15) diff --git a/packages/vm/docs/functions/applyBlock.md b/packages/vm/docs/functions/applyBlock.md new file mode 100644 index 0000000000..ab8f271f10 --- /dev/null +++ b/packages/vm/docs/functions/applyBlock.md @@ -0,0 +1,36 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / applyBlock + +# Function: applyBlock() + +> **applyBlock**(`vm`): (`block`, `opts`) => `Promise`\<[`ApplyBlockResult`](../interfaces/ApplyBlockResult.md)\> + +Validates and applies a block, computing the results of +applying its transactions. This method doesn't modify the +block itself. It computes the block rewards and puts +them on state (but doesn't persist the changes). + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: `Block` + +• **opts**: [`RunBlockOpts`](../interfaces/RunBlockOpts.md) + +### Returns + +`Promise`\<[`ApplyBlockResult`](../interfaces/ApplyBlockResult.md)\> + +## Defined in + +[packages/vm/src/actions/applyBlock.ts:24](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/applyBlock.ts#L24) diff --git a/packages/vm/docs/functions/applyDAOHardfork.md b/packages/vm/docs/functions/applyDAOHardfork.md new file mode 100644 index 0000000000..0378945011 --- /dev/null +++ b/packages/vm/docs/functions/applyDAOHardfork.md @@ -0,0 +1,23 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / applyDAOHardfork + +# Function: applyDAOHardfork() + +> **applyDAOHardfork**(`evm`): `Promise`\<`void`\> + +Apply the DAO fork changes to the VM + +## Parameters + +• **evm**: `Evm` + +## Returns + +`Promise`\<`void`\> + +## Defined in + +[packages/vm/src/actions/applyDAOHardfork.ts:9](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/applyDAOHardfork.ts#L9) diff --git a/packages/vm/docs/functions/applyTransactions.md b/packages/vm/docs/functions/applyTransactions.md new file mode 100644 index 0000000000..3f4d2b461f --- /dev/null +++ b/packages/vm/docs/functions/applyTransactions.md @@ -0,0 +1,59 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / applyTransactions + +# Function: applyTransactions() + +> **applyTransactions**(`vm`): (`block`, `opts`) => `Promise`\<`object`\> + +Applies the transactions in a block, computing the receipts +as well as gas usage and some relevant data. This method is +side-effect free (it doesn't modify the block nor the state). + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: `Block` + +• **opts**: [`RunBlockOpts`](../interfaces/RunBlockOpts.md) + +### Returns + +`Promise`\<`object`\> + +#### bloom + +> **bloom**: `Bloom` + +#### gasUsed + +> **gasUsed**: `bigint` + +#### preimages + +> **preimages**: `Map`\<`string`, `Uint8Array`\> + +#### receipts + +> **receipts**: [`TxReceipt`](../type-aliases/TxReceipt.md)[] + +#### receiptsRoot + +> **receiptsRoot**: `Uint8Array` + +#### results + +> **results**: [`RunTxResult`](../interfaces/RunTxResult.md)[] = `txResults` + +## Defined in + +[packages/vm/src/actions/applyTransactions.ts:19](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/applyTransactions.ts#L19) diff --git a/packages/vm/docs/functions/assignBlockRewards.md b/packages/vm/docs/functions/assignBlockRewards.md new file mode 100644 index 0000000000..c9a7ff465e --- /dev/null +++ b/packages/vm/docs/functions/assignBlockRewards.md @@ -0,0 +1,32 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / assignBlockRewards + +# Function: assignBlockRewards() + +> **assignBlockRewards**(`vm`): (`block`) => `Promise`\<`void`\> + +Calculates block rewards for miner and ommers and puts +the updated balances of their accounts to state. + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: `Block` + +### Returns + +`Promise`\<`void`\> + +## Defined in + +[packages/vm/src/actions/assignBlockRewards.ts:12](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/assignBlockRewards.ts#L12) diff --git a/packages/vm/docs/functions/assignWithdrawals.md b/packages/vm/docs/functions/assignWithdrawals.md new file mode 100644 index 0000000000..0706b8d5fd --- /dev/null +++ b/packages/vm/docs/functions/assignWithdrawals.md @@ -0,0 +1,29 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / assignWithdrawals + +# Function: assignWithdrawals() + +> **assignWithdrawals**(`vm`): (`block`) => `Promise`\<`void`\> + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: `Block` + +### Returns + +`Promise`\<`void`\> + +## Defined in + +[packages/vm/src/actions/assignWithdrawals.ts:8](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/assignWithdrawals.ts#L8) diff --git a/packages/vm/docs/functions/calculateMinerReward.md b/packages/vm/docs/functions/calculateMinerReward.md index 83639ea63d..97c5ca1a14 100644 --- a/packages/vm/docs/functions/calculateMinerReward.md +++ b/packages/vm/docs/functions/calculateMinerReward.md @@ -20,4 +20,4 @@ ## Defined in -[packages/vm/src/actions/runBlock.ts:439](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L439) +[packages/vm/src/actions/calculateMinerReward.ts:1](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/calculateMinerReward.ts#L1) diff --git a/packages/vm/docs/functions/calculateOmmerReward.md b/packages/vm/docs/functions/calculateOmmerReward.md new file mode 100644 index 0000000000..75fdf12a60 --- /dev/null +++ b/packages/vm/docs/functions/calculateOmmerReward.md @@ -0,0 +1,25 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / calculateOmmerReward + +# Function: calculateOmmerReward() + +> **calculateOmmerReward**(`ommerBlockNumber`, `blockNumber`, `minerReward`): `bigint` + +## Parameters + +• **ommerBlockNumber**: `bigint` + +• **blockNumber**: `bigint` + +• **minerReward**: `bigint` + +## Returns + +`bigint` + +## Defined in + +[packages/vm/src/actions/calculateOmmerReward.ts:1](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/calculateOmmerReward.ts#L1) diff --git a/packages/vm/docs/functions/encodeReceipt.md b/packages/vm/docs/functions/encodeReceipt.md deleted file mode 100644 index ea24768805..0000000000 --- a/packages/vm/docs/functions/encodeReceipt.md +++ /dev/null @@ -1,25 +0,0 @@ -[**@tevm/vm**](../README.md) • **Docs** - -*** - -[@tevm/vm](../globals.md) / encodeReceipt - -# Function: encodeReceipt() - -> **encodeReceipt**(`receipt`, `txType`): `Uint8Array` - -Returns the encoded tx receipt. - -## Parameters - -• **receipt**: [`TxReceipt`](../type-aliases/TxReceipt.md) - -• **txType**: `TransactionType` - -## Returns - -`Uint8Array` - -## Defined in - -[packages/vm/src/actions/runBlock.ts:461](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L461) diff --git a/packages/vm/docs/functions/genTxTrie.md b/packages/vm/docs/functions/genTxTrie.md new file mode 100644 index 0000000000..22aeba9084 --- /dev/null +++ b/packages/vm/docs/functions/genTxTrie.md @@ -0,0 +1,21 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / genTxTrie + +# Function: genTxTrie() + +> **genTxTrie**(`block`): `Promise`\<`Uint8Array`\> + +## Parameters + +• **block**: `Block` + +## Returns + +`Promise`\<`Uint8Array`\> + +## Defined in + +[packages/vm/src/actions/genTxTrie.ts:6](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/genTxTrie.ts#L6) diff --git a/packages/vm/docs/functions/rewardAccount.md b/packages/vm/docs/functions/rewardAccount.md index c092961eb1..375edff4c6 100644 --- a/packages/vm/docs/functions/rewardAccount.md +++ b/packages/vm/docs/functions/rewardAccount.md @@ -22,4 +22,4 @@ ## Defined in -[packages/vm/src/actions/runBlock.ts:447](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L447) +[packages/vm/src/actions/rewardAccount.ts:5](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/rewardAccount.ts#L5) diff --git a/packages/vm/docs/functions/validateRunTx.md b/packages/vm/docs/functions/validateRunTx.md new file mode 100644 index 0000000000..b64ae4e77b --- /dev/null +++ b/packages/vm/docs/functions/validateRunTx.md @@ -0,0 +1,29 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / validateRunTx + +# Function: validateRunTx() + +> **validateRunTx**(`vm`): (`opts`) => `Promise`\<[`RunTxOpts`](../interfaces/RunTxOpts.md) & `Required`\<`Pick`\<[`RunTxOpts`](../interfaces/RunTxOpts.md), `"block"`\>\>\> + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **opts**: [`RunTxOpts`](../interfaces/RunTxOpts.md) + +### Returns + +`Promise`\<[`RunTxOpts`](../interfaces/RunTxOpts.md) & `Required`\<`Pick`\<[`RunTxOpts`](../interfaces/RunTxOpts.md), `"block"`\>\>\> + +## Defined in + +[packages/vm/src/actions/validateRunTx.js:10](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/validateRunTx.js#L10) diff --git a/packages/vm/docs/functions/warmAddresses2929.md b/packages/vm/docs/functions/warmAddresses2929.md new file mode 100644 index 0000000000..36315e44e1 --- /dev/null +++ b/packages/vm/docs/functions/warmAddresses2929.md @@ -0,0 +1,27 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / warmAddresses2929 + +# Function: warmAddresses2929() + +> **warmAddresses2929**(`vm`, `caller`, `to`, `coinbase`): `void` + +## Parameters + +• **vm**: `BaseVm` + +• **caller**: `Address` + +• **to**: `undefined` \| `Address` + +• **coinbase**: `Address` + +## Returns + +`void` + +## Defined in + +[packages/vm/src/actions/warmAddresses2929.js:9](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/warmAddresses2929.js#L9) diff --git a/packages/vm/docs/globals.md b/packages/vm/docs/globals.md index 5dce1b4cf3..6b331435e9 100644 --- a/packages/vm/docs/globals.md +++ b/packages/vm/docs/globals.md @@ -37,6 +37,7 @@ - [BuildBlock](type-aliases/BuildBlock.md) - [CreateVmOptions](type-aliases/CreateVmOptions.md) - [DeepCopy](type-aliases/DeepCopy.md) +- [DeepCopyError](type-aliases/DeepCopyError.md) - [EVMProfilerOpts](type-aliases/EVMProfilerOpts.md) - [RunBlock](type-aliases/RunBlock.md) - [TxReceipt](type-aliases/TxReceipt.md) @@ -44,16 +45,30 @@ - [VMProfilerOpts](type-aliases/VMProfilerOpts.md) - [Vm](type-aliases/Vm.md) +## Variables + +- [DAOConfig](variables/DAOConfig.md) +- [KECCAK256\_NULL](variables/KECCAK256_NULL.md) +- [parentBeaconBlockRootAddress](variables/parentBeaconBlockRootAddress.md) + ## Functions - [accumulateParentBeaconBlockRoot](functions/accumulateParentBeaconBlockRoot.md) - [accumulateParentBlockHash](functions/accumulateParentBlockHash.md) +- [applyBlock](functions/applyBlock.md) +- [applyDAOHardfork](functions/applyDAOHardfork.md) +- [applyTransactions](functions/applyTransactions.md) +- [assignBlockRewards](functions/assignBlockRewards.md) +- [assignWithdrawals](functions/assignWithdrawals.md) - [buildBlock](functions/buildBlock.md) - [calculateMinerReward](functions/calculateMinerReward.md) +- [calculateOmmerReward](functions/calculateOmmerReward.md) - [createVm](functions/createVm.md) - [deepCopy](functions/deepCopy.md) -- [encodeReceipt](functions/encodeReceipt.md) - [execHardfork](functions/execHardfork.md) +- [genTxTrie](functions/genTxTrie.md) - [generateTxReceipt](functions/generateTxReceipt.md) - [rewardAccount](functions/rewardAccount.md) - [txLogsBloom](functions/txLogsBloom.md) +- [validateRunTx](functions/validateRunTx.md) +- [warmAddresses2929](functions/warmAddresses2929.md) diff --git a/packages/vm/docs/interfaces/ApplyBlockResult.md b/packages/vm/docs/interfaces/ApplyBlockResult.md index 6a34e44f9c..caa8aca48e 100644 --- a/packages/vm/docs/interfaces/ApplyBlockResult.md +++ b/packages/vm/docs/interfaces/ApplyBlockResult.md @@ -6,7 +6,7 @@ # Interface: ApplyBlockResult -Result of applyBlock +Result of [applyBlock](../functions/applyBlock.md) ## Properties diff --git a/packages/vm/docs/type-aliases/AddTransactionError.md b/packages/vm/docs/type-aliases/AddTransactionError.md index 7351f2bb83..2fb9b382f1 100644 --- a/packages/vm/docs/type-aliases/AddTransactionError.md +++ b/packages/vm/docs/type-aliases/AddTransactionError.md @@ -10,4 +10,4 @@ ## Defined in -[packages/vm/src/actions/BlockBuilder.ts:44](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L44) +[packages/vm/src/actions/BlockBuilder.ts:42](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/BlockBuilder.ts#L42) diff --git a/packages/vm/docs/type-aliases/DeepCopyError.md b/packages/vm/docs/type-aliases/DeepCopyError.md new file mode 100644 index 0000000000..b140eafa4d --- /dev/null +++ b/packages/vm/docs/type-aliases/DeepCopyError.md @@ -0,0 +1,15 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / DeepCopyError + +# Type Alias: DeepCopyError + +> **DeepCopyError**\<\>: `MisconfiguredClientError` + +## Type Parameters + +## Defined in + +[packages/vm/src/actions/deepCopy.js:8](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/deepCopy.js#L8) diff --git a/packages/vm/docs/type-aliases/RunBlock.md b/packages/vm/docs/type-aliases/RunBlock.md index 72514943c0..eee8efd1cf 100644 --- a/packages/vm/docs/type-aliases/RunBlock.md +++ b/packages/vm/docs/type-aliases/RunBlock.md @@ -18,4 +18,4 @@ ## Defined in -[packages/vm/src/actions/runBlock.ts:40](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L40) +[packages/vm/src/actions/runBlock.ts:12](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/runBlock.ts#L12) diff --git a/packages/vm/docs/variables/DAOConfig.md b/packages/vm/docs/variables/DAOConfig.md new file mode 100644 index 0000000000..f175823567 --- /dev/null +++ b/packages/vm/docs/variables/DAOConfig.md @@ -0,0 +1,23 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / DAOConfig + +# Variable: DAOConfig + +> `const` **DAOConfig**: `object` + +## Type declaration + +### DAOAccounts + +> `readonly` **DAOAccounts**: readonly [`"d4fe7bc31cedb7bfb8a345f31e668033056b2728"`, `"b3fb0e5aba0e20e5c49d252dfd30e102b171a425"`, `"2c19c7f9ae8b751e37aeb2d93a699722395ae18f"`, `"ecd135fa4f61a655311e86238c92adcd779555d2"`, `"1975bd06d486162d5dc297798dfc41edd5d160a7"`, `"a3acf3a1e16b1d7c315e23510fdd7847b48234f6"`, `"319f70bab6845585f412ec7724b744fec6095c85"`, `"06706dd3f2c9abf0a21ddcc6941d9b86f0596936"`, `"5c8536898fbb74fc7445814902fd08422eac56d0"`, `"6966ab0d485353095148a2155858910e0965b6f9"`, `"779543a0491a837ca36ce8c635d6154e3c4911a6"`, `"2a5ed960395e2a49b1c758cef4aa15213cfd874c"`, `"5c6e67ccd5849c0d29219c4f95f1a7a93b3f5dc5"`, `"9c50426be05db97f5d64fc54bf89eff947f0a321"`, `"200450f06520bdd6c527622a273333384d870efb"`, `"be8539bfe837b67d1282b2b1d61c3f723966f049"`, `"6b0c4d41ba9ab8d8cfb5d379c69a612f2ced8ecb"`, `"f1385fb24aad0cd7432824085e42aff90886fef5"`, `"d1ac8b1ef1b69ff51d1d401a476e7e612414f091"`, `"8163e7fb499e90f8544ea62bbf80d21cd26d9efd"`, `"51e0ddd9998364a2eb38588679f0d2c42653e4a6"`, `"627a0a960c079c21c34f7612d5d230e01b4ad4c7"`, `"f0b1aa0eb660754448a7937c022e30aa692fe0c5"`, `"24c4d950dfd4dd1902bbed3508144a54542bba94"`, `"9f27daea7aca0aa0446220b98d028715e3bc803d"`, `"a5dc5acd6a7968a4554d89d65e59b7fd3bff0f90"`, `"d9aef3a1e38a39c16b31d1ace71bca8ef58d315b"`, `"63ed5a272de2f6d968408b4acb9024f4cc208ebf"`, `"6f6704e5a10332af6672e50b3d9754dc460dfa4d"`, `"77ca7b50b6cd7e2f3fa008e24ab793fd56cb15f6"`, `"492ea3bb0f3315521c31f273e565b868fc090f17"`, `"0ff30d6de14a8224aa97b78aea5388d1c51c1f00"`, `"9ea779f907f0b315b364b0cfc39a0fde5b02a416"`, `"ceaeb481747ca6c540a000c1f3641f8cef161fa7"`, `"cc34673c6c40e791051898567a1222daf90be287"`, `"579a80d909f346fbfb1189493f521d7f48d52238"`, `"e308bd1ac5fda103967359b2712dd89deffb7973"`, `"4cb31628079fb14e4bc3cd5e30c2f7489b00960c"`, `"ac1ecab32727358dba8962a0f3b261731aad9723"`, `"4fd6ace747f06ece9c49699c7cabc62d02211f75"`, `"440c59b325d2997a134c2c7c60a8c61611212bad"`, `"4486a3d68fac6967006d7a517b889fd3f98c102b"`, `"9c15b54878ba618f494b38f0ae7443db6af648ba"`, `"27b137a85656544b1ccb5a0f2e561a5703c6a68f"`, `"21c7fdb9ed8d291d79ffd82eb2c4356ec0d81241"`, `"23b75c2f6791eef49c69684db4c6c1f93bf49a50"`, `"1ca6abd14d30affe533b24d7a21bff4c2d5e1f3b"`, `"b9637156d330c0d605a791f1c31ba5890582fe1c"`, `"6131c42fa982e56929107413a9d526fd99405560"`, `"1591fc0f688c81fbeb17f5426a162a7024d430c2"`, `"542a9515200d14b68e934e9830d91645a980dd7a"`, `"c4bbd073882dd2add2424cf47d35213405b01324"`, `"782495b7b3355efb2833d56ecb34dc22ad7dfcc4"`, `"58b95c9a9d5d26825e70a82b6adb139d3fd829eb"`, `"3ba4d81db016dc2890c81f3acec2454bff5aada5"`, `"b52042c8ca3f8aa246fa79c3feaa3d959347c0ab"`, `"e4ae1efdfc53b73893af49113d8694a057b9c0d1"`, `"3c02a7bc0391e86d91b7d144e61c2c01a25a79c5"`, `"0737a6b837f97f46ebade41b9bc3e1c509c85c53"`, `"97f43a37f595ab5dd318fb46e7a155eae057317a"`, `"52c5317c848ba20c7504cb2c8052abd1fde29d03"`, `"4863226780fe7c0356454236d3b1c8792785748d"`, `"5d2b2e6fcbe3b11d26b525e085ff818dae332479"`, `"5f9f3392e9f62f63b8eac0beb55541fc8627f42c"`, `"057b56736d32b86616a10f619859c6cd6f59092a"`, `"9aa008f65de0b923a2a4f02012ad034a5e2e2192"`, `"304a554a310c7e546dfe434669c62820b7d83490"`, `"914d1b8b43e92723e64fd0a06f5bdb8dd9b10c79"`, `"4deb0033bb26bc534b197e61d19e0733e5679784"`, `"07f5c1e1bc2c93e0402f23341973a0e043f7bf8a"`, `"35a051a0010aba705c9008d7a7eff6fb88f6ea7b"`, `"4fa802324e929786dbda3b8820dc7834e9134a2a"`, `"9da397b9e80755301a3b32173283a91c0ef6c87e"`, `"8d9edb3054ce5c5774a420ac37ebae0ac02343c6"`, `"0101f3be8ebb4bbd39a2e3b9a3639d4259832fd9"`, `"5dc28b15dffed94048d73806ce4b7a4612a1d48f"`, `"bcf899e6c7d9d5a215ab1e3444c86806fa854c76"`, `"12e626b0eebfe86a56d633b9864e389b45dcb260"`, `"a2f1ccba9395d7fcb155bba8bc92db9bafaeade7"`, `"ec8e57756626fdc07c63ad2eafbd28d08e7b0ca5"`, `"d164b088bd9108b60d0ca3751da4bceb207b0782"`, `"6231b6d0d5e77fe001c2a460bd9584fee60d409b"`, `"1cba23d343a983e9b5cfd19496b9a9701ada385f"`, `"a82f360a8d3455c5c41366975bde739c37bfeb8a"`, `"9fcd2deaff372a39cc679d5c5e4de7bafb0b1339"`, `"005f5cee7a43331d5a3d3eec71305925a62f34b6"`, `"0e0da70933f4c7849fc0d203f5d1d43b9ae4532d"`, `"d131637d5275fd1a68a3200f4ad25c71a2a9522e"`, `"bc07118b9ac290e4622f5e77a0853539789effbe"`, `"47e7aa56d6bdf3f36be34619660de61275420af8"`, `"acd87e28b0c9d1254e868b81cba4cc20d9a32225"`, `"adf80daec7ba8dcf15392f1ac611fff65d94f880"`, `"5524c55fb03cf21f549444ccbecb664d0acad706"`, `"40b803a9abce16f50f36a77ba41180eb90023925"`, `"fe24cdd8648121a43a7c86d289be4dd2951ed49f"`, `"17802f43a0137c506ba92291391a8a8f207f487d"`, `"253488078a4edf4d6f42f113d1e62836a942cf1a"`, `"86af3e9626fce1957c82e88cbf04ddf3a2ed7915"`, `"b136707642a4ea12fb4bae820f03d2562ebff487"`, `"dbe9b615a3ae8709af8b93336ce9b477e4ac0940"`, `"f14c14075d6c4ed84b86798af0956deef67365b5"`, `"ca544e5c4687d109611d0f8f928b53a25af72448"`, `"aeeb8ff27288bdabc0fa5ebb731b6f409507516c"`, `"cbb9d3703e651b0d496cdefb8b92c25aeb2171f7"`, `"6d87578288b6cb5549d5076a207456a1f6a63dc0"`, `"b2c6f0dfbb716ac562e2d85d6cb2f8d5ee87603e"`, `"accc230e8a6e5be9160b8cdf2864dd2a001c28b6"`, `"2b3455ec7fedf16e646268bf88846bd7a2319bb2"`, `"4613f3bca5c44ea06337a9e439fbc6d42e501d0a"`, `"d343b217de44030afaa275f54d31a9317c7f441e"`, `"84ef4b2357079cd7a7c69fd7a37cd0609a679106"`, `"da2fef9e4a3230988ff17df2165440f37e8b1708"`, `"f4c64518ea10f995918a454158c6b61407ea345c"`, `"7602b46df5390e432ef1c307d4f2c9ff6d65cc97"`, `"bb9bc244d798123fde783fcc1c72d3bb8c189413"`, `"807640a13483f8ac783c557fcdf27be11ea4ac7a"`] + +### DAORefundContract + +> `readonly` **DAORefundContract**: `"bf4ed7b27f1d666546e30d74d50d173d20bca754"` = `'bf4ed7b27f1d666546e30d74d50d173d20bca754'` + +## Defined in + +[packages/vm/src/actions/DAOConfig.ts:1](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/DAOConfig.ts#L1) diff --git a/packages/vm/docs/variables/KECCAK256_NULL.md b/packages/vm/docs/variables/KECCAK256_NULL.md new file mode 100644 index 0000000000..0fb615bd19 --- /dev/null +++ b/packages/vm/docs/variables/KECCAK256_NULL.md @@ -0,0 +1,13 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / KECCAK256\_NULL + +# Variable: KECCAK256\_NULL + +> `const` **KECCAK256\_NULL**: `Uint8Array` + +## Defined in + +[packages/vm/src/actions/constants.js:5](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/constants.js#L5) diff --git a/packages/vm/docs/variables/parentBeaconBlockRootAddress.md b/packages/vm/docs/variables/parentBeaconBlockRootAddress.md new file mode 100644 index 0000000000..f48f738e27 --- /dev/null +++ b/packages/vm/docs/variables/parentBeaconBlockRootAddress.md @@ -0,0 +1,13 @@ +[**@tevm/vm**](../README.md) • **Docs** + +*** + +[@tevm/vm](../globals.md) / parentBeaconBlockRootAddress + +# Variable: parentBeaconBlockRootAddress + +> `const` **parentBeaconBlockRootAddress**: `Address` + +## Defined in + +[packages/vm/src/actions/parentBeaconBlockRootAddress.ts:3](https://github.com/evmts/tevm-monorepo/blob/main/packages/vm/src/actions/parentBeaconBlockRootAddress.ts#L3) diff --git a/packages/vm/package.json b/packages/vm/package.json index 87677ef8c5..dd4826c407 100644 --- a/packages/vm/package.json +++ b/packages/vm/package.json @@ -75,6 +75,7 @@ "@tevm/utils": "workspace:^" }, "devDependencies": { + "@tevm/contract": "1.1.0-next.91", "@tevm/tsconfig": "workspace:^", "@tevm/tsupconfig": "workspace:^" }, diff --git a/packages/vm/src/actions/BlockBuilder.ts b/packages/vm/src/actions/BlockBuilder.ts index 6ef2bca1ae..76899850a3 100644 --- a/packages/vm/src/actions/BlockBuilder.ts +++ b/packages/vm/src/actions/BlockBuilder.ts @@ -16,15 +16,9 @@ import { zeros, } from '@tevm/utils' -import { - accumulateParentBeaconBlockRoot, - accumulateParentBlockHash, - calculateMinerReward, - encodeReceipt, - rewardAccount, -} from './runBlock.js' - -import { Bloom } from '@ethereumjs/vm' +import {} from './runBlock.js' + +import { Bloom, encodeReceipt } from '@ethereumjs/vm' import type { HeaderData } from '@tevm/block' import { BlockGasLimitExceededError, @@ -39,6 +33,10 @@ import type { BaseVm } from '../BaseVm.js' import type { BuildBlockOpts, BuilderOpts, RunTxResult, SealBlockOpts } from '../utils/index.js' import type { BlockStatus } from './BlockStatus.js' import { BuildStatus } from './BuildStatus.js' +import { accumulateParentBeaconBlockRoot } from './accumulateParentBeaconBlockRoot.js' +import { accumulateParentBlockHash } from './accumulateParentBlockHash.js' +import { calculateMinerReward } from './calculateMinerReward.js' +import { rewardAccount } from './rewardAccount.js' import { runTx } from './runTx.js' export type AddTransactionError = InvalidGasLimitError | EipNotEnabledError | BlockGasLimitExceededError diff --git a/packages/vm/src/actions/DAOConfig.ts b/packages/vm/src/actions/DAOConfig.ts new file mode 100644 index 0000000000..f68d12485b --- /dev/null +++ b/packages/vm/src/actions/DAOConfig.ts @@ -0,0 +1,121 @@ +export const DAOConfig = { + DAOAccounts: [ + 'd4fe7bc31cedb7bfb8a345f31e668033056b2728', + 'b3fb0e5aba0e20e5c49d252dfd30e102b171a425', + '2c19c7f9ae8b751e37aeb2d93a699722395ae18f', + 'ecd135fa4f61a655311e86238c92adcd779555d2', + '1975bd06d486162d5dc297798dfc41edd5d160a7', + 'a3acf3a1e16b1d7c315e23510fdd7847b48234f6', + '319f70bab6845585f412ec7724b744fec6095c85', + '06706dd3f2c9abf0a21ddcc6941d9b86f0596936', + '5c8536898fbb74fc7445814902fd08422eac56d0', + '6966ab0d485353095148a2155858910e0965b6f9', + '779543a0491a837ca36ce8c635d6154e3c4911a6', + '2a5ed960395e2a49b1c758cef4aa15213cfd874c', + '5c6e67ccd5849c0d29219c4f95f1a7a93b3f5dc5', + '9c50426be05db97f5d64fc54bf89eff947f0a321', + '200450f06520bdd6c527622a273333384d870efb', + 'be8539bfe837b67d1282b2b1d61c3f723966f049', + '6b0c4d41ba9ab8d8cfb5d379c69a612f2ced8ecb', + 'f1385fb24aad0cd7432824085e42aff90886fef5', + 'd1ac8b1ef1b69ff51d1d401a476e7e612414f091', + '8163e7fb499e90f8544ea62bbf80d21cd26d9efd', + '51e0ddd9998364a2eb38588679f0d2c42653e4a6', + '627a0a960c079c21c34f7612d5d230e01b4ad4c7', + 'f0b1aa0eb660754448a7937c022e30aa692fe0c5', + '24c4d950dfd4dd1902bbed3508144a54542bba94', + '9f27daea7aca0aa0446220b98d028715e3bc803d', + 'a5dc5acd6a7968a4554d89d65e59b7fd3bff0f90', + 'd9aef3a1e38a39c16b31d1ace71bca8ef58d315b', + '63ed5a272de2f6d968408b4acb9024f4cc208ebf', + '6f6704e5a10332af6672e50b3d9754dc460dfa4d', + '77ca7b50b6cd7e2f3fa008e24ab793fd56cb15f6', + '492ea3bb0f3315521c31f273e565b868fc090f17', + '0ff30d6de14a8224aa97b78aea5388d1c51c1f00', + '9ea779f907f0b315b364b0cfc39a0fde5b02a416', + 'ceaeb481747ca6c540a000c1f3641f8cef161fa7', + 'cc34673c6c40e791051898567a1222daf90be287', + '579a80d909f346fbfb1189493f521d7f48d52238', + 'e308bd1ac5fda103967359b2712dd89deffb7973', + '4cb31628079fb14e4bc3cd5e30c2f7489b00960c', + 'ac1ecab32727358dba8962a0f3b261731aad9723', + '4fd6ace747f06ece9c49699c7cabc62d02211f75', + '440c59b325d2997a134c2c7c60a8c61611212bad', + '4486a3d68fac6967006d7a517b889fd3f98c102b', + '9c15b54878ba618f494b38f0ae7443db6af648ba', + '27b137a85656544b1ccb5a0f2e561a5703c6a68f', + '21c7fdb9ed8d291d79ffd82eb2c4356ec0d81241', + '23b75c2f6791eef49c69684db4c6c1f93bf49a50', + '1ca6abd14d30affe533b24d7a21bff4c2d5e1f3b', + 'b9637156d330c0d605a791f1c31ba5890582fe1c', + '6131c42fa982e56929107413a9d526fd99405560', + '1591fc0f688c81fbeb17f5426a162a7024d430c2', + '542a9515200d14b68e934e9830d91645a980dd7a', + 'c4bbd073882dd2add2424cf47d35213405b01324', + '782495b7b3355efb2833d56ecb34dc22ad7dfcc4', + '58b95c9a9d5d26825e70a82b6adb139d3fd829eb', + '3ba4d81db016dc2890c81f3acec2454bff5aada5', + 'b52042c8ca3f8aa246fa79c3feaa3d959347c0ab', + 'e4ae1efdfc53b73893af49113d8694a057b9c0d1', + '3c02a7bc0391e86d91b7d144e61c2c01a25a79c5', + '0737a6b837f97f46ebade41b9bc3e1c509c85c53', + '97f43a37f595ab5dd318fb46e7a155eae057317a', + '52c5317c848ba20c7504cb2c8052abd1fde29d03', + '4863226780fe7c0356454236d3b1c8792785748d', + '5d2b2e6fcbe3b11d26b525e085ff818dae332479', + '5f9f3392e9f62f63b8eac0beb55541fc8627f42c', + '057b56736d32b86616a10f619859c6cd6f59092a', + '9aa008f65de0b923a2a4f02012ad034a5e2e2192', + '304a554a310c7e546dfe434669c62820b7d83490', + '914d1b8b43e92723e64fd0a06f5bdb8dd9b10c79', + '4deb0033bb26bc534b197e61d19e0733e5679784', + '07f5c1e1bc2c93e0402f23341973a0e043f7bf8a', + '35a051a0010aba705c9008d7a7eff6fb88f6ea7b', + '4fa802324e929786dbda3b8820dc7834e9134a2a', + '9da397b9e80755301a3b32173283a91c0ef6c87e', + '8d9edb3054ce5c5774a420ac37ebae0ac02343c6', + '0101f3be8ebb4bbd39a2e3b9a3639d4259832fd9', + '5dc28b15dffed94048d73806ce4b7a4612a1d48f', + 'bcf899e6c7d9d5a215ab1e3444c86806fa854c76', + '12e626b0eebfe86a56d633b9864e389b45dcb260', + 'a2f1ccba9395d7fcb155bba8bc92db9bafaeade7', + 'ec8e57756626fdc07c63ad2eafbd28d08e7b0ca5', + 'd164b088bd9108b60d0ca3751da4bceb207b0782', + '6231b6d0d5e77fe001c2a460bd9584fee60d409b', + '1cba23d343a983e9b5cfd19496b9a9701ada385f', + 'a82f360a8d3455c5c41366975bde739c37bfeb8a', + '9fcd2deaff372a39cc679d5c5e4de7bafb0b1339', + '005f5cee7a43331d5a3d3eec71305925a62f34b6', + '0e0da70933f4c7849fc0d203f5d1d43b9ae4532d', + 'd131637d5275fd1a68a3200f4ad25c71a2a9522e', + 'bc07118b9ac290e4622f5e77a0853539789effbe', + '47e7aa56d6bdf3f36be34619660de61275420af8', + 'acd87e28b0c9d1254e868b81cba4cc20d9a32225', + 'adf80daec7ba8dcf15392f1ac611fff65d94f880', + '5524c55fb03cf21f549444ccbecb664d0acad706', + '40b803a9abce16f50f36a77ba41180eb90023925', + 'fe24cdd8648121a43a7c86d289be4dd2951ed49f', + '17802f43a0137c506ba92291391a8a8f207f487d', + '253488078a4edf4d6f42f113d1e62836a942cf1a', + '86af3e9626fce1957c82e88cbf04ddf3a2ed7915', + 'b136707642a4ea12fb4bae820f03d2562ebff487', + 'dbe9b615a3ae8709af8b93336ce9b477e4ac0940', + 'f14c14075d6c4ed84b86798af0956deef67365b5', + 'ca544e5c4687d109611d0f8f928b53a25af72448', + 'aeeb8ff27288bdabc0fa5ebb731b6f409507516c', + 'cbb9d3703e651b0d496cdefb8b92c25aeb2171f7', + '6d87578288b6cb5549d5076a207456a1f6a63dc0', + 'b2c6f0dfbb716ac562e2d85d6cb2f8d5ee87603e', + 'accc230e8a6e5be9160b8cdf2864dd2a001c28b6', + '2b3455ec7fedf16e646268bf88846bd7a2319bb2', + '4613f3bca5c44ea06337a9e439fbc6d42e501d0a', + 'd343b217de44030afaa275f54d31a9317c7f441e', + '84ef4b2357079cd7a7c69fd7a37cd0609a679106', + 'da2fef9e4a3230988ff17df2165440f37e8b1708', + 'f4c64518ea10f995918a454158c6b61407ea345c', + '7602b46df5390e432ef1c307d4f2c9ff6d65cc97', + 'bb9bc244d798123fde783fcc1c72d3bb8c189413', + '807640a13483f8ac783c557fcdf27be11ea4ac7a', + ], + DAORefundContract: 'bf4ed7b27f1d666546e30d74d50d173d20bca754', +} as const diff --git a/packages/vm/src/actions/__snapshots__/deepCopy.spec.ts.snap b/packages/vm/src/actions/__snapshots__/deepCopy.spec.ts.snap new file mode 100644 index 0000000000..72b6d7083b --- /dev/null +++ b/packages/vm/src/actions/__snapshots__/deepCopy.spec.ts.snap @@ -0,0 +1,6 @@ +// Bun Snapshot v1, https://goo.gl/fbAQLP + +exports[`deepCopy should throw MisconfiguredClientError if stateManager does not support deepCopy 1`] = `[MisconfiguredClientError: StateManager does not support deepCopy. Was a Tevm state manager used? + +Docs: https://tevm.sh/reference/tevm/errors/classes/internalerror/ +Version: 1.1.0.next-73]`; diff --git a/packages/vm/src/actions/__snapshots__/runTx.spec.ts.snap b/packages/vm/src/actions/__snapshots__/runTx.spec.ts.snap new file mode 100644 index 0000000000..0220861825 --- /dev/null +++ b/packages/vm/src/actions/__snapshots__/runTx.spec.ts.snap @@ -0,0 +1,2313 @@ +// Bun Snapshot v1, https://goo.gl/fbAQLP + +exports[`runTx should execute a transaction successfully 1`] = ` +{ + "amountSpent": 168000n, + "bloom": Bloom { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "keccakFunction": [Function], + }, + "execResult": { + "exceptionError": undefined, + "executionGasUsed": 0n, + "gasRefund": 0n, + "returnValue": Uint8Array [], + }, + "gasRefund": 0n, + "minerValue": 21000n, + "receipt": { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "cumulativeBlockGasUsed": 21000n, + "logs": [], + "status": 1, + }, + "totalGasSpent": 21000n, +} +`; + +exports[`runTx should execute a contract call successfully 1`] = `Uint8Array []`; + +exports[`runTx should execute a contract call successfully 2`] = ` +[ + [ + Uint8Array [ + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + ], + [ + Uint8Array [ + 1, + 44, + 120, + 226, + 184, + 67, + 37, + 135, + 139, + 27, + 217, + 210, + 80, + 215, + 114, + 207, + 229, + 189, + 167, + 114, + 45, + 121, + 95, + 69, + 3, + 111, + 165, + 225, + 230, + 227, + 3, + 252, + ], + ], + Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 20, + ], + ], +] +`; + +exports[`runTx should execute a contract call successfully 3`] = ` +Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 20, +] +`; + +exports[`runTx should execute a contract call successfully 4`] = `[]`; + +exports[`runTx should throw error for invalid block parameter 1`] = `[InsufficientFundsError: sender doesn't have enough funds to send tx. The upfront cost is: 168513 and the sender's account (0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266) only has: 0 -> block number=0 hash=0xc13e3e758cfce75830f0e2800937e1f172e0d8ab8f41508debc829168c4e535a hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x30150fa581c7b6766b48ea665b4051ee71967b1bcc2387c4b7bf1c481f953cad nonce=0 value=1 signed=true hf=cancun maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/insufficientfundserror/ +Version: 1.1.0.next-73]`; + +exports[`runTx should throw InsufficientFundsError 1`] = `[InsufficientFundsError: sender doesn't have enough funds to send tx. The upfront cost is: 1000000000000000000168512 and the sender's account (0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266) only has: 0 -> block number=0 hash=0xc13e3e758cfce75830f0e2800937e1f172e0d8ab8f41508debc829168c4e535a hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x039eeafaefd19b89ad985c0b9d77c12eb678210672e376ebd1ed29dd89a99b39 nonce=0 value=1000000000000000000000000 signed=true hf=cancun maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/insufficientfundserror/ +Version: 1.1.0.next-73]`; + +exports[`runTx should throw NonceTooLowError 1`] = `[NonceTooLowError: the tx doesn't have the correct nonce. account has nonce of: 5 tx has nonce of: 0 -> block number=0 hash=0xc13e3e758cfce75830f0e2800937e1f172e0d8ab8f41508debc829168c4e535a hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x30150fa581c7b6766b48ea665b4051ee71967b1bcc2387c4b7bf1c481f953cad nonce=0 value=1 signed=true hf=cancun maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/noncetoolowerror/ +Version: 1.1.0.next-73]`; + +exports[`runTx should report access list 1`] = ` +{ + "accessList": [], + "amountSpent": 168000n, + "bloom": Bloom { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "keccakFunction": [Function], + }, + "execResult": { + "exceptionError": undefined, + "executionGasUsed": 0n, + "gasRefund": 0n, + "returnValue": Uint8Array [], + }, + "gasRefund": 0n, + "minerValue": 21000n, + "receipt": { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "cumulativeBlockGasUsed": 21000n, + "logs": [], + "status": 1, + }, + "totalGasSpent": 21000n, +} +`; + +exports[`runTx should handle EIP-1559 transactions 1`] = ` +{ + "amountSpent": 10500147000n, + "bloom": Bloom { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "keccakFunction": [Function], + }, + "execResult": { + "exceptionError": undefined, + "executionGasUsed": 0n, + "gasRefund": 0n, + "returnValue": Uint8Array [], + }, + "gasRefund": 0n, + "minerValue": 10500000000n, + "receipt": { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "cumulativeBlockGasUsed": 21000n, + "logs": [], + "status": 1, + }, + "totalGasSpent": 21000n, +} +`; + +exports[`runTx should generate transaction receipt correctly 1`] = ` +{ + "amountSpent": 168000n, + "bloom": Bloom { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "keccakFunction": [Function], + }, + "execResult": { + "exceptionError": undefined, + "executionGasUsed": 0n, + "gasRefund": 0n, + "returnValue": Uint8Array [], + }, + "gasRefund": 0n, + "minerValue": 21000n, + "receipt": { + "bitvector": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + ], + "cumulativeBlockGasUsed": 21000n, + "logs": [], + "status": 1, + }, + "totalGasSpent": 21000n, +} +`; diff --git a/packages/vm/src/actions/__snapshots__/validateRunTx.spec.ts.snap b/packages/vm/src/actions/__snapshots__/validateRunTx.spec.ts.snap new file mode 100644 index 0000000000..4f1b93b966 --- /dev/null +++ b/packages/vm/src/actions/__snapshots__/validateRunTx.spec.ts.snap @@ -0,0 +1,46 @@ +// Bun Snapshot v1, https://goo.gl/fbAQLP + +exports[`validateRunTx should throw MisconfiguredClientError if no preMerge hardfork is found 1`] = `[MisconfiguredClientError: no preMerge hardfork found -> block number=0 hash=0x505d1a81ef6ebbe82c3b0e669d237bd885abe85b9720d4350d192e95696d9c9b hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x080c04e4589f4b33d25453d7df933093014b4114ac307fa4020d2214560a12f7 nonce=0 value=0 signed=true hf=shanghai maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/internalerror/ +Version: 1.1.0.next-73]`; + +exports[`validateRunTx should throw BlockGasLimitExceededError if tx gas limit exceeds block gas limit 1`] = `[BlockGasLimitExceededError: tx has a higher gas limit than the block -> block number=0 hash=0x7cab6a01424065383830f0994f3981d795835c06f1780c44e083e37537c77085 hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x080c04e4589f4b33d25453d7df933093014b4114ac307fa4020d2214560a12f7 nonce=0 value=0 signed=true hf=cancun maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/blockgaslimitexceedederror/ +Version: 1.1.0.next-73]`; + +exports[`validateRunTx should throw EipNotEnabledError if EIP 2930 is not activated for Access List transaction 1`] = `[EipNotEnabledError: Cannot run transaction: EIP 2930 is not activated. -> block number=0 hash=0xc13e3e758cfce75830f0e2800937e1f172e0d8ab8f41508debc829168c4e535a hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x080c04e4589f4b33d25453d7df933093014b4114ac307fa4020d2214560a12f7 nonce=0 value=0 signed=true hf=cancun maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/eipnotenablederror/ +Version: 1.1.0.next-73]`; + +exports[`validateRunTx should throw EipNotEnabledError if EIP 1559 is not activated for Fee Market transaction 1`] = `[EipNotEnabledError: Cannot run transaction: EIP 1559 is not activated. -> block number=0 hash=0xc13e3e758cfce75830f0e2800937e1f172e0d8ab8f41508debc829168c4e535a hf=cancun baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0xd927b750e60fd928bdd343ee0b9883acf2d01b84cf076e361419884c03d56c55 nonce=0 value=0 signed=true hf=cancun maxFeePerGas=10 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/eipnotenablederror/ +Version: 1.1.0.next-73]`; + +exports[`validateRunTx should validate options successfully with no block 1`] = `0n`; + +exports[`validateRunTx should validate options successfully with no block 2`] = `[Function: hash]`; + +exports[`validateRunTx should validate options successfully with no block 3`] = ` +{ + "tx": { + "type": "0x2", + "nonce": "0x0", + "gasLimit": "0x5248", + "value": "0x0", + "data": "0x", + "chainId": "0x1", + "maxPriorityFeePerGas": "0x1", + "maxFeePerGas": "0x8", + "accessList": [] +}, +} +`; + +exports[`validateRunTx should throw if hardfork doesn not match 1`] = `[MisconfiguredClientError: block has a different hardfork than the vm -> block number=0 hash=0x505d1a81ef6ebbe82c3b0e669d237bd885abe85b9720d4350d192e95696d9c9b hf=shanghai baseFeePerGas=7 txs=0 uncles=0 -> tx type=2 hash=0x080c04e4589f4b33d25453d7df933093014b4114ac307fa4020d2214560a12f7 nonce=0 value=0 signed=true hf=shanghai maxFeePerGas=8 maxPriorityFeePerGas=1) + +Docs: https://tevm.sh/reference/tevm/errors/classes/internalerror/ +Version: 1.1.0.next-73]`; diff --git a/packages/vm/src/actions/accumulateParentBeaconBlockRoot.ts b/packages/vm/src/actions/accumulateParentBeaconBlockRoot.ts new file mode 100644 index 0000000000..b161ce7ce8 --- /dev/null +++ b/packages/vm/src/actions/accumulateParentBeaconBlockRoot.ts @@ -0,0 +1,37 @@ +import { EthjsAccount, setLengthLeft, toBytes } from '@tevm/utils' + +import { EipNotEnabledError } from '@tevm/errors' +import type { BaseVm } from '../BaseVm.js' +import { parentBeaconBlockRootAddress } from './parentBeaconBlockRootAddress.js' + +export const accumulateParentBeaconBlockRoot = (vm: BaseVm) => async (root: Uint8Array, timestamp: bigint) => { + if (!vm.common.ethjsCommon.isActivatedEIP(4788)) { + throw new EipNotEnabledError('Cannot call `accumulateParentBeaconBlockRoot`: EIP 4788 is not active') + } + // Save the parentBeaconBlockRoot to the beaconroot stateful precompile ring buffers + const historicalRootsLength = BigInt(vm.common.ethjsCommon.param('vm', 'historicalRootsLength')) + const timestampIndex = timestamp % historicalRootsLength + const timestampExtended = timestampIndex + historicalRootsLength + + /** + * Note: (by Jochem) + * If we don't do this (put account if undefined / non-existant), block runner crashes because the beacon root address does not exist + * This is hence (for me) again a reason why it should /not/ throw if the address does not exist + * All ethereum accounts have empty storage by default + */ + + if ((await vm.stateManager.getAccount(parentBeaconBlockRootAddress)) === undefined) { + await vm.evm.journal.putAccount(parentBeaconBlockRootAddress, new EthjsAccount()) + } + + await vm.stateManager.putContractStorage( + parentBeaconBlockRootAddress, + setLengthLeft(toBytes(timestampIndex), 32), + toBytes(timestamp), + ) + await vm.stateManager.putContractStorage( + parentBeaconBlockRootAddress, + setLengthLeft(toBytes(timestampExtended), 32), + root, + ) +} diff --git a/packages/vm/src/actions/accumulateParentBlockHash.ts b/packages/vm/src/actions/accumulateParentBlockHash.ts new file mode 100644 index 0000000000..ea29fcdef9 --- /dev/null +++ b/packages/vm/src/actions/accumulateParentBlockHash.ts @@ -0,0 +1,56 @@ +import { EthjsAccount, EthjsAddress, numberToHex, setLengthLeft, toBytes } from '@tevm/utils' + +import { EipNotEnabledError } from '@tevm/errors' +import type { BaseVm } from '../BaseVm.js' + +/** + * This method runs the logic of EIP 2935 (save blockhashes to state) + * It will put the `parentHash` of the block to the storage slot of `block.number - 1` of the history storage contract. + * This contract is used to retrieve BLOCKHASHes in EVM if EIP 2935 is activated. + * In case that the previous block of `block` is pre-EIP-2935 (so we are on the EIP 2935 fork block), additionally + * also add the currently available past blockhashes which are available by BLOCKHASH (so, the past 256 block hashes) + * @param this The VM to run on + * @param block The current block to save the parent block hash of + */ +export const accumulateParentBlockHash = (vm: BaseVm) => async (currentBlockNumber: bigint, parentHash: Uint8Array) => { + if (!vm.common.ethjsCommon.isActivatedEIP(2935)) { + throw new EipNotEnabledError('Cannot call `accumulateParentBlockHash`: EIP 2935 is not active') + } + const historyAddress = EthjsAddress.fromString( + numberToHex(vm.common.ethjsCommon.param('vm', 'historyStorageAddress')), + ) + const historyServeWindow = vm.common.ethjsCommon.param('vm', 'historyServeWindow') + + // Is this the fork block? + const forkTime = vm.common.ethjsCommon.eipTimestamp(2935) + if (forkTime === null) { + throw new EipNotEnabledError('EIP 2935 should be activated by timestamp') + } + + if ((await vm.stateManager.getAccount(historyAddress)) === undefined) { + await vm.evm.journal.putAccount(historyAddress, new EthjsAccount()) + } + + async function putBlockHash(vm: BaseVm, hash: Uint8Array, number: bigint) { + // ringKey is the key the hash is actually put in (it is a ring buffer) + const ringKey = number % historyServeWindow + const key = setLengthLeft(toBytes(ringKey), 32) + await vm.stateManager.putContractStorage(historyAddress, key, hash) + } + await putBlockHash(vm, parentHash, currentBlockNumber - 1n) + + const parentBlock = await vm.blockchain.getBlock(parentHash) + + // If on the fork block, store the old block hashes as well + if (parentBlock.header.timestamp < forkTime) { + let ancestor = parentBlock + for (let i = 0; i < Number(historyServeWindow) - 1; i++) { + if (ancestor.header.number === 0n) { + break + } + + ancestor = await vm.blockchain.getBlock(ancestor.header.parentHash) + await putBlockHash(vm, ancestor.hash(), ancestor.header.number) + } + } +} diff --git a/packages/vm/src/actions/applyBlock.ts b/packages/vm/src/actions/applyBlock.ts new file mode 100644 index 0000000000..2379dd7df7 --- /dev/null +++ b/packages/vm/src/actions/applyBlock.ts @@ -0,0 +1,93 @@ +import { Block } from '@tevm/block' +import { ConsensusType } from '@tevm/common' +import { bytesToHex } from '@tevm/utils' + +import { InternalError, MisconfiguredClientError } from '@tevm/errors' +import type { BaseVm } from '../BaseVm.js' +import type { ApplyBlockResult, RunBlockOpts } from '../utils/index.js' +import { accumulateParentBeaconBlockRoot } from './accumulateParentBeaconBlockRoot.js' +import { accumulateParentBlockHash } from './accumulateParentBlockHash.js' +import { applyTransactions } from './applyTransactions.js' +import { assignBlockRewards } from './assignBlockRewards.js' +import { assignWithdrawals } from './assignWithdrawals.js' +import { errorMsg } from './errorMsg.js' + +/** + * Validates and applies a block, computing the results of + * applying its transactions. This method doesn't modify the + * block itself. It computes the block rewards and puts + * them on state (but doesn't persist the changes). + * @param {Block} block + * @param {RunBlockOpts} opts + */ +export const applyBlock = + (vm: BaseVm) => + async (block: Block, opts: RunBlockOpts): Promise => { + // Validate block + if (opts.skipBlockValidation !== true) { + if (block.header.gasLimit >= BigInt('0x8000000000000000')) { + const msg = errorMsg('Invalid block with gas limit greater than (2^63 - 1)', vm, block) + // todo make InvalidBlockError + throw new InternalError(msg) + } + // TODO: decide what block validation method is appropriate here + if (opts.skipHeaderValidation !== true) { + if (typeof (vm.blockchain).validateHeader === 'function') { + await (vm.blockchain).validateHeader(block.header) + } else { + throw new InternalError('cannot validate header: blockchain has no `validateHeader` method') + } + } + await block.validateData() + } + if (vm.common.ethjsCommon.isActivatedEIP(4788)) { + await accumulateParentBeaconBlockRoot(vm)( + block.header.parentBeaconBlockRoot as Uint8Array, + block.header.timestamp, + ) + } + if (vm.common.ethjsCommon.isActivatedEIP(2935)) { + await accumulateParentBlockHash(vm)(block.header.number, block.header.parentHash) + } + + const blockResults = await applyTransactions(vm)(block, opts) + + // Add txResult preimages to the blockResults preimages + // Also add the coinbase preimage + + if (opts.reportPreimages === true) { + if (vm.evm.stateManager.getAppliedKey === undefined) { + throw new MisconfiguredClientError( + 'applyBlock: evm.stateManager.getAppliedKey can not be undefined if reportPreimages is true', + ) + } + blockResults.preimages.set( + bytesToHex(vm.evm.stateManager.getAppliedKey(block.header.coinbase.toBytes())), + block.header.coinbase.toBytes(), + ) + for (const txResult of blockResults.results) { + if (txResult.preimages !== undefined) { + for (const [key, preimage] of txResult.preimages) { + blockResults.preimages.set(key, preimage) + } + } + } + } + + if (vm.common.ethjsCommon.isActivatedEIP(4895)) { + if (opts.reportPreimages === true) vm.evm.journal.startReportingPreimages?.() + await assignWithdrawals(vm)(block) + if (opts.reportPreimages === true && vm.evm.journal.preimages !== undefined) { + for (const [key, preimage] of vm.evm.journal.preimages) { + blockResults.preimages.set(key, preimage) + } + } + await vm.evm.journal.cleanup() + } + // Pay ommers and miners + if (block.common.ethjsCommon.consensusType() === ConsensusType.ProofOfWork) { + await assignBlockRewards(vm)(block) + } + + return blockResults as any + } diff --git a/packages/vm/src/actions/applyDAOHardfork.ts b/packages/vm/src/actions/applyDAOHardfork.ts new file mode 100644 index 0000000000..0e57140f4d --- /dev/null +++ b/packages/vm/src/actions/applyDAOHardfork.ts @@ -0,0 +1,40 @@ +import { EthjsAccount, EthjsAddress, type Hex, hexToBytes } from '@tevm/utils' + +import type { Evm } from '@tevm/evm' +import { DAOConfig } from './DAOConfig.js' + +/** + * Apply the DAO fork changes to the VM + */ +export async function applyDAOHardfork(evm: Evm) { + const state = evm.stateManager + + /* DAO account list */ + const DAOAccountList = DAOConfig.DAOAccounts + const DAORefundContract = DAOConfig.DAORefundContract + + const DAORefundContractAddress = new EthjsAddress(hexToBytes(`0x${DAORefundContract}`)) + if ((await state.getAccount(DAORefundContractAddress)) === undefined) { + await evm.journal.putAccount(DAORefundContractAddress, new EthjsAccount()) + } + let DAORefundAccount = await state.getAccount(DAORefundContractAddress) + if (DAORefundAccount === undefined) { + DAORefundAccount = new EthjsAccount() + } + + for (const addr of DAOAccountList) { + // retrieve the account and add it to the DAO's Refund accounts' balance. + const address = new EthjsAddress(hexToBytes(addr as Hex)) + let account = await state.getAccount(address) + if (account === undefined) { + account = new EthjsAccount() + } + DAORefundAccount.balance += account.balance + // clear the accounts' balance + account.balance = 0n + await evm.journal.putAccount(address, account) + } + + // finally, put the Refund Account + await evm.journal.putAccount(DAORefundContractAddress, DAORefundAccount) +} diff --git a/packages/vm/src/actions/applyTransactions.ts b/packages/vm/src/actions/applyTransactions.ts new file mode 100644 index 0000000000..959303b80f --- /dev/null +++ b/packages/vm/src/actions/applyTransactions.ts @@ -0,0 +1,84 @@ +import { Block } from '@tevm/block' +import { Rlp } from '@tevm/rlp' +import { Trie } from '@tevm/trie' +import { type TypedTransaction } from '@tevm/tx' + +import { Bloom, encodeReceipt } from '@ethereumjs/vm' +import { GasLimitExceededError } from '@tevm/errors' +import { KECCAK256_RLP } from '@tevm/utils' +import type { BaseVm } from '../BaseVm.js' +import type { RunBlockOpts, RunTxResult, TxReceipt } from '../utils/index.js' +import { errorMsg } from './errorMsg.js' +import { runTx } from './runTx.js' + +/** + * Applies the transactions in a block, computing the receipts + * as well as gas usage and some relevant data. This method is + * side-effect free (it doesn't modify the block nor the state). + */ +export const applyTransactions = (vm: BaseVm) => async (block: Block, opts: RunBlockOpts) => { + const bloom = new Bloom(undefined, vm.common.ethjsCommon) + // the total amount of gas used processing these transactions + let gasUsed = 0n + + let receiptTrie: Trie | undefined = undefined + if (block.transactions.length !== 0) { + receiptTrie = new Trie({ common: vm.common.ethjsCommon }) + } + + const receipts: TxReceipt[] = [] + const txResults: RunTxResult[] = [] + + /* + * Process transactions + */ + for (let txIdx = 0; txIdx < block.transactions.length; txIdx++) { + const tx = block.transactions[txIdx] as TypedTransaction + + let maxGasLimit: bigint + if (vm.common.ethjsCommon.isActivatedEIP(1559) === true) { + maxGasLimit = block.header.gasLimit * vm.common.ethjsCommon.param('gasConfig', 'elasticityMultiplier') + } else { + maxGasLimit = block.header.gasLimit + } + const gasLimitIsHigherThanBlock = maxGasLimit < tx.gasLimit + gasUsed + if (gasLimitIsHigherThanBlock) { + const msg = errorMsg('tx has a higher gas limit than the block', vm, block) + throw new GasLimitExceededError(msg) + } + + // Run the tx through the VM + const { skipBalance = false, skipNonce = false, skipHardForkValidation = true, reportPreimages = false } = opts + + const txRes = await runTx(vm)({ + tx, + block, + skipBalance, + skipNonce, + skipHardForkValidation, + blockGasUsed: gasUsed, + reportPreimages, + }) + txResults.push(txRes) + // Add to total block gas usage + gasUsed += txRes.totalGasSpent + // Combine blooms via bitwise OR + bloom.or(txRes.bloom) + + // Add receipt to trie to later calculate receipt root + receipts.push(txRes.receipt) + const encodedReceipt = encodeReceipt(txRes.receipt, tx.type) + await receiptTrie?.put(Rlp.encode(txIdx), encodedReceipt) + } + + const receiptsRoot = receiptTrie !== undefined ? receiptTrie.root() : KECCAK256_RLP + + return { + bloom, + gasUsed, + preimages: new Map(), + receiptsRoot, + receipts, + results: txResults, + } +} diff --git a/packages/vm/src/actions/assignBlockRewards.ts b/packages/vm/src/actions/assignBlockRewards.ts new file mode 100644 index 0000000000..a8d6329d3e --- /dev/null +++ b/packages/vm/src/actions/assignBlockRewards.ts @@ -0,0 +1,24 @@ +import { Block } from '@tevm/block' +import type { BaseVm } from '../BaseVm.js' +import { calculateMinerReward } from './calculateMinerReward.js' +import { calculateOmmerReward } from './calculateOmmerReward.js' +import { rewardAccount } from './rewardAccount.js' + +/** + * Calculates block rewards for miner and ommers and puts + * the updated balances of their accounts to state. + */ +export const assignBlockRewards = + (vm: BaseVm) => + async (block: Block): Promise => { + const minerReward = vm.common.ethjsCommon.param('pow', 'minerReward') + const ommers = block.uncleHeaders + // Reward ommers + for (const ommer of ommers) { + const reward = calculateOmmerReward(ommer.number, block.header.number, minerReward) + await rewardAccount(vm.evm, ommer.coinbase, reward) + } + // Reward miner + const reward = calculateMinerReward(minerReward, ommers.length) + await rewardAccount(vm.evm, block.header.coinbase, reward) + } diff --git a/packages/vm/src/actions/assignWithdrawals.ts b/packages/vm/src/actions/assignWithdrawals.ts new file mode 100644 index 0000000000..fdb73231d6 --- /dev/null +++ b/packages/vm/src/actions/assignWithdrawals.ts @@ -0,0 +1,19 @@ +import { Block } from '@tevm/block' +import { Withdrawal, parseGwei } from '@tevm/utils' + +import type { BaseVm } from '../BaseVm.js' +import { rewardAccount } from './rewardAccount.js' + +export const assignWithdrawals = + (vm: BaseVm) => + async (block: Block): Promise => { + const withdrawals = block.withdrawals as Withdrawal[] + for (const withdrawal of withdrawals) { + const { address, amount } = withdrawal + // Withdrawal amount is represented in Gwei so needs to be + // converted to wei + // Note: event if amount is 0, still reward the account + // such that the account is touched and marked for cleanup if it is empty + await rewardAccount(vm.evm, address, parseGwei(amount.toString())) + } + } diff --git a/packages/vm/src/actions/calculateMinerReward.ts b/packages/vm/src/actions/calculateMinerReward.ts new file mode 100644 index 0000000000..a724491a42 --- /dev/null +++ b/packages/vm/src/actions/calculateMinerReward.ts @@ -0,0 +1,7 @@ +export function calculateMinerReward(minerReward: bigint, ommersNum: number): bigint { + // calculate nibling reward + const niblingReward = minerReward / BigInt(32) + const totalNiblingReward = niblingReward * BigInt(ommersNum) + const reward = minerReward + totalNiblingReward + return reward +} diff --git a/packages/vm/src/actions/calculateOmmerReward.ts b/packages/vm/src/actions/calculateOmmerReward.ts new file mode 100644 index 0000000000..85e91d5d72 --- /dev/null +++ b/packages/vm/src/actions/calculateOmmerReward.ts @@ -0,0 +1,8 @@ +export function calculateOmmerReward(ommerBlockNumber: bigint, blockNumber: bigint, minerReward: bigint): bigint { + const heightDiff = blockNumber - ommerBlockNumber + let reward = ((8n - heightDiff) * minerReward) / 8n + if (reward < 0n) { + reward = 0n + } + return reward +} diff --git a/packages/vm/src/actions/deepCopy.spec.ts b/packages/vm/src/actions/deepCopy.spec.ts new file mode 100644 index 0000000000..0586456f85 --- /dev/null +++ b/packages/vm/src/actions/deepCopy.spec.ts @@ -0,0 +1,61 @@ +import { beforeEach, describe, expect, it, jest } from 'bun:test' +import { createChain } from '@tevm/blockchain' +import { type Common, mainnet } from '@tevm/common' +import { createCommon } from '@tevm/common' +import { MisconfiguredClientError } from '@tevm/errors' +import { createEvm } from '@tevm/evm' +import { createStateManager } from '@tevm/state' +import type { BaseVm } from '../BaseVm.js' +import { createBaseVm } from '../createBaseVm.js' +import { deepCopy } from './deepCopy.js' + +describe('deepCopy', () => { + let baseVm: BaseVm + let common: Common + + beforeEach(async () => { + common = createCommon({ ...mainnet, hardfork: 'cancun', loggingLevel: 'warn' }) + const stateManager = createStateManager({}) + const blockchain = await createChain({ common }) + const evm = await createEvm({ common, stateManager, blockchain }) + baseVm = createBaseVm({ + common, + stateManager, + blockchain, + evm, + activatePrecompiles: false, + }) + }) + + it('should create a deep copy of the VM', async () => { + const deepCopyVm = await deepCopy(baseVm)() + expect(deepCopyVm).toBeDefined() + expect(deepCopyVm.common.ethjsCommon.hardfork()).toBe(baseVm.common.ethjsCommon.hardfork()) + expect(deepCopyVm.blockchain).toBeDefined() + expect(deepCopyVm.stateManager).toBeDefined() + expect(deepCopyVm.evm).toBeDefined() + }) + + it('should throw MisconfiguredClientError if stateManager does not support deepCopy', async () => { + delete (baseVm as any).stateManager.deepCopy + const err = await deepCopy(baseVm)().catch((err) => err) + console.log(err) + expect(err).toBeInstanceOf(Error) + expect(err).toBeInstanceOf(MisconfiguredClientError) + expect(err).toMatchSnapshot() + }) + + it.skip('should retain custom EVM configurations', async () => { + const anyEvm = baseVm.evm as any + anyEvm.allowUnlimitedContractSize = true + anyEvm._customPrecompiles = [{ mock: 'object' }] + anyEvm.DEBUG = true + anyEvm._debug = jest.fn() + + const deepCopyVm = await deepCopy(baseVm)() + expect(deepCopyVm.evm.allowUnlimitedContractSize).toBe(true) + expect((deepCopyVm.evm as any)._customPrecompiles).toEqual([{ mock: 'object' }]) + expect(deepCopyVm.evm.DEBUG).toBe(true) + expect((deepCopyVm.evm as any)._debug).toBeDefined() + }) +}) diff --git a/packages/vm/src/actions/errorMsg.ts b/packages/vm/src/actions/errorMsg.ts new file mode 100644 index 0000000000..e54230324f --- /dev/null +++ b/packages/vm/src/actions/errorMsg.ts @@ -0,0 +1,15 @@ +import type { Block } from '@tevm/block' +import type { BaseVm } from '../BaseVm.js' + +/** + * Internal helper function to create an annotated error message + * + * @param msg Base error message + * @hidden + */ +export function errorMsg(msg: string, vm: BaseVm, block: Block) { + const blockErrorStr = 'errorStr' in block ? block.errorStr() : 'block' + + const errorMsg = `${msg} (${vm.common.ethjsCommon.hardfork.name} -> ${blockErrorStr})` + return errorMsg +} diff --git a/packages/vm/src/actions/execHardfork.spec.ts b/packages/vm/src/actions/execHardfork.spec.ts new file mode 100644 index 0000000000..249834e7d5 --- /dev/null +++ b/packages/vm/src/actions/execHardfork.spec.ts @@ -0,0 +1,54 @@ +import { describe, expect, it } from 'bun:test' +import type { Hardfork } from '@tevm/common' +import { execHardfork } from './execHardfork.js' + +describe('execHardfork', () => { + it('should return the same hardfork if it is not "paris"', () => { + const hardfork: Hardfork = 'london' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(hardfork) + }) + + it('should return the preMergeHf if the hardfork is "paris"', () => { + const hardfork: Hardfork = 'paris' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(preMergeHf) + }) + + it('should handle strings correctly if hardfork is not "paris"', () => { + const hardfork: Hardfork = 'istanbul' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(hardfork) + }) + + it('should handle strings correctly if hardfork is "paris"', () => { + const hardfork: Hardfork = 'paris' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(preMergeHf) + }) + + it('should return the preMergeHf if the hardfork is "paris" even if preMergeHf is a string', () => { + const hardfork: Hardfork = 'paris' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(preMergeHf) + }) + + it('should return the hardfork if it is not "paris" even if preMergeHf is a string', () => { + const hardfork: Hardfork = 'london' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(hardfork) + }) + + it('should handle strings correctly if hardfork is "paris" and preMergeHf is a string', () => { + const hardfork: Hardfork = 'paris' + const preMergeHf: Hardfork = 'berlin' + const result = execHardfork(hardfork, preMergeHf) + expect(result).toBe(preMergeHf) + }) +}) diff --git a/packages/vm/src/actions/genTxTrie.ts b/packages/vm/src/actions/genTxTrie.ts new file mode 100644 index 0000000000..7b9704f2d4 --- /dev/null +++ b/packages/vm/src/actions/genTxTrie.ts @@ -0,0 +1,15 @@ +import { Block } from '@tevm/block' +import { Rlp } from '@tevm/rlp' +import { Trie } from '@tevm/trie' +import { KECCAK256_RLP } from '@tevm/utils' + +export async function genTxTrie(block: Block) { + if (block.transactions.length === 0) { + return KECCAK256_RLP + } + const trie = new Trie({ common: block.common.ethjsCommon }) + for (const [i, tx] of block.transactions.entries()) { + await trie.put(Rlp.encode(i), tx.serialize()) + } + return trie.root() +} diff --git a/packages/vm/src/actions/index.ts b/packages/vm/src/actions/index.ts index 0aa3dd0c0d..95cf8c6d6a 100644 --- a/packages/vm/src/actions/index.ts +++ b/packages/vm/src/actions/index.ts @@ -1,12 +1,26 @@ export * from './BlockBuilder.js' export * from './BlockStatus.js' export * from './BuildStatus.js' +export * from './DAOConfig.js' +export * from './accumulateParentBlockHash.js' +export * from './accumulateParentBeaconBlockRoot.js' +export * from './applyBlock.js' +export * from './applyDAOHardfork.js' +export * from './applyTransactions.js' +export * from './assignBlockRewards.js' +export * from './assignWithdrawals.js' export * from './buildBlock.js' +export * from './calculateMinerReward.js' +export * from './calculateOmmerReward.js' export * from './constants.js' export * from './deepCopy.js' -export * from './errorMessage.js' export * from './execHardfork.js' +export * from './genTxTrie.js' export * from './generateTxResult.js' +export * from './parentBeaconBlockRootAddress.js' +export * from './rewardAccount.js' export * from './runBlock.js' export * from './runTx.js' export * from './txLogsBloom.js' +export * from './validateRunTx.js' +export * from './warmAddresses2929.js' diff --git a/packages/vm/src/actions/parentBeaconBlockRootAddress.ts b/packages/vm/src/actions/parentBeaconBlockRootAddress.ts new file mode 100644 index 0000000000..9e04cb98e7 --- /dev/null +++ b/packages/vm/src/actions/parentBeaconBlockRootAddress.ts @@ -0,0 +1,3 @@ +import { EthjsAddress } from '@tevm/utils' + +export const parentBeaconBlockRootAddress = EthjsAddress.fromString('0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02') diff --git a/packages/vm/src/actions/rewardAccount.ts b/packages/vm/src/actions/rewardAccount.ts new file mode 100644 index 0000000000..f911ec4b6c --- /dev/null +++ b/packages/vm/src/actions/rewardAccount.ts @@ -0,0 +1,14 @@ +import { EthjsAccount, EthjsAddress } from '@tevm/utils' + +import type { Evm } from '@tevm/evm' + +export async function rewardAccount(evm: Evm, address: EthjsAddress, reward: bigint): Promise { + let account = await evm.stateManager.getAccount(address) + if (account === undefined) { + account = new EthjsAccount() + } + account.balance += reward + await evm.journal.putAccount(address, account) + + return account +} diff --git a/packages/vm/src/actions/runBlock.ts b/packages/vm/src/actions/runBlock.ts index a6c97a6adc..97ed39d243 100644 --- a/packages/vm/src/actions/runBlock.ts +++ b/packages/vm/src/actions/runBlock.ts @@ -1,41 +1,13 @@ import { Block } from '@tevm/block' -import { ConsensusType } from '@tevm/common' -import { Rlp } from '@tevm/rlp' -import { Trie } from '@tevm/trie' -import { TransactionType, type TypedTransaction } from '@tevm/tx' -import { - EthjsAccount, - EthjsAddress, - type Hex, - KECCAK256_RLP, - Withdrawal, - bytesToHex, - concatBytes, - equalsBytes, - hexToBytes, - numberToHex, - parseGwei, - setLengthLeft, - toBytes, -} from '@tevm/utils' +import { bytesToHex, equalsBytes } from '@tevm/utils' -import { Bloom } from '@ethereumjs/vm' -import { EipNotEnabledError, GasLimitExceededError, InternalError, MisconfiguredClientError } from '@tevm/errors' -import type { Evm } from '@tevm/evm' +import { InternalError } from '@tevm/errors' import type { BaseVm } from '../BaseVm.js' -import type { - AfterBlockEvent, - ApplyBlockResult, - PostByzantiumTxReceipt, - PreByzantiumTxReceipt, - RunBlockOpts, - RunBlockResult, - RunTxResult, - TxReceipt, -} from '../utils/index.js' -import { runTx } from './runTx.js' - -const parentBeaconBlockRootAddress = EthjsAddress.fromString('0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02') +import type { AfterBlockEvent, ApplyBlockResult, RunBlockOpts, RunBlockResult } from '../utils/index.js' +import { applyBlock } from './applyBlock.js' +import { applyDAOHardfork } from './applyDAOHardfork.js' +import { errorMsg } from './errorMsg.js' +import { genTxTrie } from './genTxTrie.js' export type RunBlock = (opts: RunBlockOpts) => Promise @@ -73,7 +45,7 @@ export const runBlock = block.header.number === vm.common.ethjsCommon.hardforkBlock('dao') ) { await vm.evm.journal.checkpoint() - await _applyDAOHardfork(vm.evm) + await applyDAOHardfork(vm.evm) await vm.evm.journal.commit() } @@ -103,7 +75,7 @@ export const runBlock = const bloom = result.bloom.bitvector const gasUsed = result.gasUsed const receiptTrie = result.receiptsRoot - const transactionsTrie = await _genTxTrie(block) + const transactionsTrie = await genTxTrie(block) const generatedFields = { stateRoot, bloom, gasUsed, receiptTrie, transactionsTrie } const blockData = { ...block, @@ -114,19 +86,19 @@ export const runBlock = } else if (vm.common.ethjsCommon.isActivatedEIP(6800) === false) { // Only validate the following headers if verkle blocks aren't activated if (equalsBytes(result.receiptsRoot, block.header.receiptTrie) === false) { - const msg = _errorMsg('invalid receiptTrie', vm, block) + const msg = errorMsg('invalid receiptTrie', vm, block) throw new InternalError(msg) } if (!(equalsBytes(result.bloom.bitvector, block.header.logsBloom) === true)) { - const msg = _errorMsg('invalid bloom', vm, block) + const msg = errorMsg('invalid bloom', vm, block) throw new InternalError(msg) } if (result.gasUsed !== block.header.gasUsed) { - const msg = _errorMsg('invalid gasUsed', vm, block) + const msg = errorMsg('invalid gasUsed', vm, block) throw new InternalError(msg) } if (!(equalsBytes(stateRoot, block.header.stateRoot) === true)) { - const msg = _errorMsg( + const msg = errorMsg( `invalid block stateRoot, got: ${bytesToHex(stateRoot)}, want: ${bytesToHex(block.header.stateRoot)}`, vm, block, @@ -157,503 +129,3 @@ export const runBlock = await vm._emit('afterBlock', afterBlockEvent) return results } - -/** - * Validates and applies a block, computing the results of - * applying its transactions. This method doesn't modify the - * block itself. It computes the block rewards and puts - * them on state (but doesn't persist the changes). - * @param {Block} block - * @param {RunBlockOpts} opts - */ -const applyBlock = - (vm: BaseVm) => - async (block: Block, opts: RunBlockOpts): Promise => { - // Validate block - if (opts.skipBlockValidation !== true) { - if (block.header.gasLimit >= BigInt('0x8000000000000000')) { - const msg = _errorMsg('Invalid block with gas limit greater than (2^63 - 1)', vm, block) - // todo make InvalidBlockError - throw new InternalError(msg) - } - // TODO: decide what block validation method is appropriate here - if (opts.skipHeaderValidation !== true) { - if (typeof (vm.blockchain).validateHeader === 'function') { - await (vm.blockchain).validateHeader(block.header) - } else { - throw new InternalError('cannot validate header: blockchain has no `validateHeader` method') - } - } - await block.validateData() - } - if (vm.common.ethjsCommon.isActivatedEIP(4788)) { - await accumulateParentBeaconBlockRoot(vm)( - block.header.parentBeaconBlockRoot as Uint8Array, - block.header.timestamp, - ) - } - if (vm.common.ethjsCommon.isActivatedEIP(2935)) { - await accumulateParentBlockHash(vm)(block.header.number, block.header.parentHash) - } - - const blockResults = await applyTransactions(vm)(block, opts) - - // Add txResult preimages to the blockResults preimages - // Also add the coinbase preimage - - if (opts.reportPreimages === true) { - if (vm.evm.stateManager.getAppliedKey === undefined) { - throw new MisconfiguredClientError( - 'applyBlock: evm.stateManager.getAppliedKey can not be undefined if reportPreimages is true', - ) - } - blockResults.preimages.set( - bytesToHex(vm.evm.stateManager.getAppliedKey(block.header.coinbase.toBytes())), - block.header.coinbase.toBytes(), - ) - for (const txResult of blockResults.results) { - if (txResult.preimages !== undefined) { - for (const [key, preimage] of txResult.preimages) { - blockResults.preimages.set(key, preimage) - } - } - } - } - - if (vm.common.ethjsCommon.isActivatedEIP(4895)) { - if (opts.reportPreimages === true) vm.evm.journal.startReportingPreimages?.() - await assignWithdrawals(vm)(block) - if (opts.reportPreimages === true && vm.evm.journal.preimages !== undefined) { - for (const [key, preimage] of vm.evm.journal.preimages) { - blockResults.preimages.set(key, preimage) - } - } - await vm.evm.journal.cleanup() - } - // Pay ommers and miners - if (block.common.ethjsCommon.consensusType() === ConsensusType.ProofOfWork) { - await assignBlockRewards(vm)(block) - } - - return blockResults as any - } - -/** - * This method runs the logic of EIP 2935 (save blockhashes to state) - * It will put the `parentHash` of the block to the storage slot of `block.number - 1` of the history storage contract. - * This contract is used to retrieve BLOCKHASHes in EVM if EIP 2935 is activated. - * In case that the previous block of `block` is pre-EIP-2935 (so we are on the EIP 2935 fork block), additionally - * also add the currently available past blockhashes which are available by BLOCKHASH (so, the past 256 block hashes) - * @param this The VM to run on - * @param block The current block to save the parent block hash of - */ -export const accumulateParentBlockHash = (vm: BaseVm) => async (currentBlockNumber: bigint, parentHash: Uint8Array) => { - if (!vm.common.ethjsCommon.isActivatedEIP(2935)) { - throw new EipNotEnabledError('Cannot call `accumulateParentBlockHash`: EIP 2935 is not active') - } - const historyAddress = EthjsAddress.fromString( - numberToHex(vm.common.ethjsCommon.param('vm', 'historyStorageAddress')), - ) - const historyServeWindow = vm.common.ethjsCommon.param('vm', 'historyServeWindow') - - // Is this the fork block? - const forkTime = vm.common.ethjsCommon.eipTimestamp(2935) - if (forkTime === null) { - throw new EipNotEnabledError('EIP 2935 should be activated by timestamp') - } - - if ((await vm.stateManager.getAccount(historyAddress)) === undefined) { - await vm.evm.journal.putAccount(historyAddress, new EthjsAccount()) - } - - async function putBlockHash(vm: BaseVm, hash: Uint8Array, number: bigint) { - // ringKey is the key the hash is actually put in (it is a ring buffer) - const ringKey = number % historyServeWindow - const key = setLengthLeft(toBytes(ringKey), 32) - await vm.stateManager.putContractStorage(historyAddress, key, hash) - } - await putBlockHash(vm, parentHash, currentBlockNumber - 1n) - - const parentBlock = await vm.blockchain.getBlock(parentHash) - - // If on the fork block, store the old block hashes as well - if (parentBlock.header.timestamp < forkTime) { - let ancestor = parentBlock - for (let i = 0; i < Number(historyServeWindow) - 1; i++) { - if (ancestor.header.number === 0n) { - break - } - - ancestor = await vm.blockchain.getBlock(ancestor.header.parentHash) - await putBlockHash(vm, ancestor.hash(), ancestor.header.number) - } - } -} - -export const accumulateParentBeaconBlockRoot = (vm: BaseVm) => async (root: Uint8Array, timestamp: bigint) => { - if (!vm.common.ethjsCommon.isActivatedEIP(4788)) { - throw new EipNotEnabledError('Cannot call `accumulateParentBeaconBlockRoot`: EIP 4788 is not active') - } - // Save the parentBeaconBlockRoot to the beaconroot stateful precompile ring buffers - const historicalRootsLength = BigInt(vm.common.ethjsCommon.param('vm', 'historicalRootsLength')) - const timestampIndex = timestamp % historicalRootsLength - const timestampExtended = timestampIndex + historicalRootsLength - - /** - * Note: (by Jochem) - * If we don't do this (put account if undefined / non-existant), block runner crashes because the beacon root address does not exist - * This is hence (for me) again a reason why it should /not/ throw if the address does not exist - * All ethereum accounts have empty storage by default - */ - - if ((await vm.stateManager.getAccount(parentBeaconBlockRootAddress)) === undefined) { - await vm.evm.journal.putAccount(parentBeaconBlockRootAddress, new EthjsAccount()) - } - - await vm.stateManager.putContractStorage( - parentBeaconBlockRootAddress, - setLengthLeft(toBytes(timestampIndex), 32), - toBytes(timestamp), - ) - await vm.stateManager.putContractStorage( - parentBeaconBlockRootAddress, - setLengthLeft(toBytes(timestampExtended), 32), - root, - ) -} - -/** - * Applies the transactions in a block, computing the receipts - * as well as gas usage and some relevant data. This method is - * side-effect free (it doesn't modify the block nor the state). - */ -const applyTransactions = (vm: BaseVm) => async (block: Block, opts: RunBlockOpts) => { - const bloom = new Bloom(undefined, vm.common.ethjsCommon) - // the total amount of gas used processing these transactions - let gasUsed = 0n - - let receiptTrie: Trie | undefined = undefined - if (block.transactions.length !== 0) { - receiptTrie = new Trie({ common: vm.common.ethjsCommon }) - } - - const receipts: TxReceipt[] = [] - const txResults: RunTxResult[] = [] - - /* - * Process transactions - */ - for (let txIdx = 0; txIdx < block.transactions.length; txIdx++) { - const tx = block.transactions[txIdx] as TypedTransaction - - let maxGasLimit: bigint - if (vm.common.ethjsCommon.isActivatedEIP(1559) === true) { - maxGasLimit = block.header.gasLimit * vm.common.ethjsCommon.param('gasConfig', 'elasticityMultiplier') - } else { - maxGasLimit = block.header.gasLimit - } - const gasLimitIsHigherThanBlock = maxGasLimit < tx.gasLimit + gasUsed - if (gasLimitIsHigherThanBlock) { - const msg = _errorMsg('tx has a higher gas limit than the block', vm, block) - throw new GasLimitExceededError(msg) - } - - // Run the tx through the VM - const { skipBalance = false, skipNonce = false, skipHardForkValidation = true, reportPreimages = false } = opts - - const txRes = await runTx(vm)({ - tx, - block, - skipBalance, - skipNonce, - skipHardForkValidation, - blockGasUsed: gasUsed, - reportPreimages, - }) - txResults.push(txRes) - // Add to total block gas usage - gasUsed += txRes.totalGasSpent - // Combine blooms via bitwise OR - bloom.or(txRes.bloom) - - // Add receipt to trie to later calculate receipt root - receipts.push(txRes.receipt) - const encodedReceipt = encodeReceipt(txRes.receipt, tx.type) - await receiptTrie?.put(Rlp.encode(txIdx), encodedReceipt) - } - - const receiptsRoot = receiptTrie !== undefined ? receiptTrie.root() : KECCAK256_RLP - - return { - bloom, - gasUsed, - preimages: new Map(), - receiptsRoot, - receipts, - results: txResults, - } -} - -const assignWithdrawals = - (vm: BaseVm) => - async (block: Block): Promise => { - const withdrawals = block.withdrawals as Withdrawal[] - for (const withdrawal of withdrawals) { - const { address, amount } = withdrawal - // Withdrawal amount is represented in Gwei so needs to be - // converted to wei - // Note: event if amount is 0, still reward the account - // such that the account is touched and marked for cleanup if it is empty - await rewardAccount(vm.evm, address, parseGwei(amount.toString())) - } - } - -/** - * Calculates block rewards for miner and ommers and puts - * the updated balances of their accounts to state. - */ -const assignBlockRewards = - (vm: BaseVm) => - async (block: Block): Promise => { - const minerReward = vm.common.ethjsCommon.param('pow', 'minerReward') - const ommers = block.uncleHeaders - // Reward ommers - for (const ommer of ommers) { - const reward = calculateOmmerReward(ommer.number, block.header.number, minerReward) - await rewardAccount(vm.evm, ommer.coinbase, reward) - } - // Reward miner - const reward = calculateMinerReward(minerReward, ommers.length) - await rewardAccount(vm.evm, block.header.coinbase, reward) - } - -function calculateOmmerReward(ommerBlockNumber: bigint, blockNumber: bigint, minerReward: bigint): bigint { - const heightDiff = blockNumber - ommerBlockNumber - let reward = ((8n - heightDiff) * minerReward) / 8n - if (reward < 0n) { - reward = 0n - } - return reward -} - -export function calculateMinerReward(minerReward: bigint, ommersNum: number): bigint { - // calculate nibling reward - const niblingReward = minerReward / BigInt(32) - const totalNiblingReward = niblingReward * BigInt(ommersNum) - const reward = minerReward + totalNiblingReward - return reward -} - -export async function rewardAccount(evm: Evm, address: EthjsAddress, reward: bigint): Promise { - let account = await evm.stateManager.getAccount(address) - if (account === undefined) { - account = new EthjsAccount() - } - account.balance += reward - await evm.journal.putAccount(address, account) - - return account -} - -/** - * Returns the encoded tx receipt. - */ -export function encodeReceipt(receipt: TxReceipt, txType: TransactionType) { - const encoded = Rlp.encode([ - (receipt as PreByzantiumTxReceipt).stateRoot ?? - ((receipt as PostByzantiumTxReceipt).status === 0 ? Uint8Array.from([]) : hexToBytes('0x01')), - toBytes(receipt.cumulativeBlockGasUsed), - receipt.bitvector, - receipt.logs, - ]) - - if (txType === TransactionType.Legacy) { - return encoded - } - - // Serialize receipt according to EIP-2718: - // `typed-receipt = tx-type || receipt-data` - return concatBytes(toBytes(txType), encoded) -} - -/** - * Apply the DAO fork changes to the VM - */ -async function _applyDAOHardfork(evm: Evm) { - const state = evm.stateManager - - /* DAO account list */ - const DAOAccountList = DAOConfig.DAOAccounts - const DAORefundContract = DAOConfig.DAORefundContract - - const DAORefundContractAddress = new EthjsAddress(hexToBytes(`0x${DAORefundContract}`)) - if ((await state.getAccount(DAORefundContractAddress)) === undefined) { - await evm.journal.putAccount(DAORefundContractAddress, new EthjsAccount()) - } - let DAORefundAccount = await state.getAccount(DAORefundContractAddress) - if (DAORefundAccount === undefined) { - DAORefundAccount = new EthjsAccount() - } - - for (const addr of DAOAccountList) { - // retrieve the account and add it to the DAO's Refund accounts' balance. - const address = new EthjsAddress(hexToBytes(addr as Hex)) - let account = await state.getAccount(address) - if (account === undefined) { - account = new EthjsAccount() - } - DAORefundAccount.balance += account.balance - // clear the accounts' balance - account.balance = 0n - await evm.journal.putAccount(address, account) - } - - // finally, put the Refund Account - await evm.journal.putAccount(DAORefundContractAddress, DAORefundAccount) -} - -async function _genTxTrie(block: Block) { - if (block.transactions.length === 0) { - return KECCAK256_RLP - } - const trie = new Trie({ common: block.common.ethjsCommon }) - for (const [i, tx] of block.transactions.entries()) { - await trie.put(Rlp.encode(i), tx.serialize()) - } - return trie.root() -} - -/** - * Internal helper function to create an annotated error message - * - * @param msg Base error message - * @hidden - */ -function _errorMsg(msg: string, vm: BaseVm, block: Block) { - const blockErrorStr = 'errorStr' in block ? block.errorStr() : 'block' - - const errorMsg = `${msg} (${vm.common.ethjsCommon.hardfork.name} -> ${blockErrorStr})` - return errorMsg -} - -const DAOConfig = { - DAOAccounts: [ - 'd4fe7bc31cedb7bfb8a345f31e668033056b2728', - 'b3fb0e5aba0e20e5c49d252dfd30e102b171a425', - '2c19c7f9ae8b751e37aeb2d93a699722395ae18f', - 'ecd135fa4f61a655311e86238c92adcd779555d2', - '1975bd06d486162d5dc297798dfc41edd5d160a7', - 'a3acf3a1e16b1d7c315e23510fdd7847b48234f6', - '319f70bab6845585f412ec7724b744fec6095c85', - '06706dd3f2c9abf0a21ddcc6941d9b86f0596936', - '5c8536898fbb74fc7445814902fd08422eac56d0', - '6966ab0d485353095148a2155858910e0965b6f9', - '779543a0491a837ca36ce8c635d6154e3c4911a6', - '2a5ed960395e2a49b1c758cef4aa15213cfd874c', - '5c6e67ccd5849c0d29219c4f95f1a7a93b3f5dc5', - '9c50426be05db97f5d64fc54bf89eff947f0a321', - '200450f06520bdd6c527622a273333384d870efb', - 'be8539bfe837b67d1282b2b1d61c3f723966f049', - '6b0c4d41ba9ab8d8cfb5d379c69a612f2ced8ecb', - 'f1385fb24aad0cd7432824085e42aff90886fef5', - 'd1ac8b1ef1b69ff51d1d401a476e7e612414f091', - '8163e7fb499e90f8544ea62bbf80d21cd26d9efd', - '51e0ddd9998364a2eb38588679f0d2c42653e4a6', - '627a0a960c079c21c34f7612d5d230e01b4ad4c7', - 'f0b1aa0eb660754448a7937c022e30aa692fe0c5', - '24c4d950dfd4dd1902bbed3508144a54542bba94', - '9f27daea7aca0aa0446220b98d028715e3bc803d', - 'a5dc5acd6a7968a4554d89d65e59b7fd3bff0f90', - 'd9aef3a1e38a39c16b31d1ace71bca8ef58d315b', - '63ed5a272de2f6d968408b4acb9024f4cc208ebf', - '6f6704e5a10332af6672e50b3d9754dc460dfa4d', - '77ca7b50b6cd7e2f3fa008e24ab793fd56cb15f6', - '492ea3bb0f3315521c31f273e565b868fc090f17', - '0ff30d6de14a8224aa97b78aea5388d1c51c1f00', - '9ea779f907f0b315b364b0cfc39a0fde5b02a416', - 'ceaeb481747ca6c540a000c1f3641f8cef161fa7', - 'cc34673c6c40e791051898567a1222daf90be287', - '579a80d909f346fbfb1189493f521d7f48d52238', - 'e308bd1ac5fda103967359b2712dd89deffb7973', - '4cb31628079fb14e4bc3cd5e30c2f7489b00960c', - 'ac1ecab32727358dba8962a0f3b261731aad9723', - '4fd6ace747f06ece9c49699c7cabc62d02211f75', - '440c59b325d2997a134c2c7c60a8c61611212bad', - '4486a3d68fac6967006d7a517b889fd3f98c102b', - '9c15b54878ba618f494b38f0ae7443db6af648ba', - '27b137a85656544b1ccb5a0f2e561a5703c6a68f', - '21c7fdb9ed8d291d79ffd82eb2c4356ec0d81241', - '23b75c2f6791eef49c69684db4c6c1f93bf49a50', - '1ca6abd14d30affe533b24d7a21bff4c2d5e1f3b', - 'b9637156d330c0d605a791f1c31ba5890582fe1c', - '6131c42fa982e56929107413a9d526fd99405560', - '1591fc0f688c81fbeb17f5426a162a7024d430c2', - '542a9515200d14b68e934e9830d91645a980dd7a', - 'c4bbd073882dd2add2424cf47d35213405b01324', - '782495b7b3355efb2833d56ecb34dc22ad7dfcc4', - '58b95c9a9d5d26825e70a82b6adb139d3fd829eb', - '3ba4d81db016dc2890c81f3acec2454bff5aada5', - 'b52042c8ca3f8aa246fa79c3feaa3d959347c0ab', - 'e4ae1efdfc53b73893af49113d8694a057b9c0d1', - '3c02a7bc0391e86d91b7d144e61c2c01a25a79c5', - '0737a6b837f97f46ebade41b9bc3e1c509c85c53', - '97f43a37f595ab5dd318fb46e7a155eae057317a', - '52c5317c848ba20c7504cb2c8052abd1fde29d03', - '4863226780fe7c0356454236d3b1c8792785748d', - '5d2b2e6fcbe3b11d26b525e085ff818dae332479', - '5f9f3392e9f62f63b8eac0beb55541fc8627f42c', - '057b56736d32b86616a10f619859c6cd6f59092a', - '9aa008f65de0b923a2a4f02012ad034a5e2e2192', - '304a554a310c7e546dfe434669c62820b7d83490', - '914d1b8b43e92723e64fd0a06f5bdb8dd9b10c79', - '4deb0033bb26bc534b197e61d19e0733e5679784', - '07f5c1e1bc2c93e0402f23341973a0e043f7bf8a', - '35a051a0010aba705c9008d7a7eff6fb88f6ea7b', - '4fa802324e929786dbda3b8820dc7834e9134a2a', - '9da397b9e80755301a3b32173283a91c0ef6c87e', - '8d9edb3054ce5c5774a420ac37ebae0ac02343c6', - '0101f3be8ebb4bbd39a2e3b9a3639d4259832fd9', - '5dc28b15dffed94048d73806ce4b7a4612a1d48f', - 'bcf899e6c7d9d5a215ab1e3444c86806fa854c76', - '12e626b0eebfe86a56d633b9864e389b45dcb260', - 'a2f1ccba9395d7fcb155bba8bc92db9bafaeade7', - 'ec8e57756626fdc07c63ad2eafbd28d08e7b0ca5', - 'd164b088bd9108b60d0ca3751da4bceb207b0782', - '6231b6d0d5e77fe001c2a460bd9584fee60d409b', - '1cba23d343a983e9b5cfd19496b9a9701ada385f', - 'a82f360a8d3455c5c41366975bde739c37bfeb8a', - '9fcd2deaff372a39cc679d5c5e4de7bafb0b1339', - '005f5cee7a43331d5a3d3eec71305925a62f34b6', - '0e0da70933f4c7849fc0d203f5d1d43b9ae4532d', - 'd131637d5275fd1a68a3200f4ad25c71a2a9522e', - 'bc07118b9ac290e4622f5e77a0853539789effbe', - '47e7aa56d6bdf3f36be34619660de61275420af8', - 'acd87e28b0c9d1254e868b81cba4cc20d9a32225', - 'adf80daec7ba8dcf15392f1ac611fff65d94f880', - '5524c55fb03cf21f549444ccbecb664d0acad706', - '40b803a9abce16f50f36a77ba41180eb90023925', - 'fe24cdd8648121a43a7c86d289be4dd2951ed49f', - '17802f43a0137c506ba92291391a8a8f207f487d', - '253488078a4edf4d6f42f113d1e62836a942cf1a', - '86af3e9626fce1957c82e88cbf04ddf3a2ed7915', - 'b136707642a4ea12fb4bae820f03d2562ebff487', - 'dbe9b615a3ae8709af8b93336ce9b477e4ac0940', - 'f14c14075d6c4ed84b86798af0956deef67365b5', - 'ca544e5c4687d109611d0f8f928b53a25af72448', - 'aeeb8ff27288bdabc0fa5ebb731b6f409507516c', - 'cbb9d3703e651b0d496cdefb8b92c25aeb2171f7', - '6d87578288b6cb5549d5076a207456a1f6a63dc0', - 'b2c6f0dfbb716ac562e2d85d6cb2f8d5ee87603e', - 'accc230e8a6e5be9160b8cdf2864dd2a001c28b6', - '2b3455ec7fedf16e646268bf88846bd7a2319bb2', - '4613f3bca5c44ea06337a9e439fbc6d42e501d0a', - 'd343b217de44030afaa275f54d31a9317c7f441e', - '84ef4b2357079cd7a7c69fd7a37cd0609a679106', - 'da2fef9e4a3230988ff17df2165440f37e8b1708', - 'f4c64518ea10f995918a454158c6b61407ea345c', - '7602b46df5390e432ef1c307d4f2c9ff6d65cc97', - 'bb9bc244d798123fde783fcc1c72d3bb8c189413', - '807640a13483f8ac783c557fcdf27be11ea4ac7a', - ], - DAORefundContract: 'bf4ed7b27f1d666546e30d74d50d173d20bca754', -} diff --git a/packages/vm/src/actions/runTx.spec.ts b/packages/vm/src/actions/runTx.spec.ts new file mode 100644 index 0000000000..cf6606207e --- /dev/null +++ b/packages/vm/src/actions/runTx.spec.ts @@ -0,0 +1,305 @@ +import { beforeEach, describe, expect, it } from 'bun:test' +import { Block } from '@tevm/block' +import { createChain } from '@tevm/blockchain' +import { mainnet } from '@tevm/common' +import { SimpleContract } from '@tevm/contract' +import { InsufficientFundsError, InvalidGasPriceError, NonceTooLowError } from '@tevm/errors' +import { createEvm } from '@tevm/evm' +import { createStateManager } from '@tevm/state' +import { BlobEIP4844Transaction, createImpersonatedTx } from '@tevm/tx' +import { + EthjsAccount, + EthjsAddress, + PREFUNDED_ACCOUNTS, + encodeFunctionData, + hexToBytes, + parseEther, + randomBytes, +} from '@tevm/utils' +import type { Vm } from '../Vm.js' +import { createVm } from '../createVm.js' +import { runTx } from './runTx.js' + +describe('runTx', () => { + let vm: Vm + + beforeEach(async () => { + const common = mainnet + const stateManager = createStateManager({}) + const blockchain = await createChain({ common }) + const evm = await createEvm({ common, stateManager, blockchain }) + vm = createVm({ + common, + evm, + stateManager, + blockchain, + activatePrecompiles: false, + }) + }) + + it('should execute a transaction successfully', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: 1n, + }) + const block = new Block({ common: mainnet }) + const result = await runTx(vm)({ + tx, + block, + skipNonce: true, + skipBalance: true, + }) + + expect(result.execResult.exceptionError).toBeUndefined() + + expect((await vm.stateManager.getAccount(EthjsAddress.fromString(`0x${'69'.repeat(20)}`)))?.balance).toBe(1n) + + expect(result).toMatchSnapshot() + }) + + it('should execute a contract call successfully', async () => { + const sender = EthjsAddress.fromString(`0x${'69'.repeat(20)}`) + + await vm.stateManager.putAccount( + sender, + EthjsAccount.fromAccountData({ + balance: parseEther('69'), + nonce: 3n, + }), + ) + + const contract = SimpleContract.withAddress(`0x${'02'.repeat(20)}`) + + await vm.stateManager.putContractCode( + EthjsAddress.fromString(contract.address), + hexToBytes(contract.deployedBytecode), + ) + + const setTx = createImpersonatedTx({ + impersonatedAddress: sender, + nonce: 3, + // This is exact + gasLimit: 44884, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(contract.address), + data: hexToBytes(encodeFunctionData(contract.write.set(20n))), + }) + const block = new Block({ common: mainnet }) + + const writeResult = await runTx(vm)({ + tx: setTx, + block, + skipNonce: false, + skipBalance: false, + }) + + expect(writeResult.execResult.exceptionError).toBeUndefined() + expect(writeResult.execResult.returnValue).toMatchSnapshot() + expect(writeResult.execResult.logs).toMatchSnapshot() + + const getTx = createImpersonatedTx({ + impersonatedAddress: sender, + nonce: 4, + gasLimit: 40000, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(contract.address), + data: hexToBytes(encodeFunctionData(contract.read.get())), + }) + const getResult = await runTx(vm)({ + tx: getTx, + block, + skipNonce: false, + skipBalance: false, + }) + + expect(getResult.execResult.exceptionError).toBeUndefined() + expect(getResult.execResult.returnValue).toMatchSnapshot() + expect(getResult.execResult.logs).toMatchSnapshot() + }) + + it('should throw error for invalid block parameter', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: 1n, + }) + const err = await runTx(vm)({ tx, block: undefined as any }).catch((e) => e) + expect(err).toBeInstanceOf(Error) + expect(err).toMatchSnapshot() + }) + + it('should throw InsufficientFundsError', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: parseEther('1000000'), // Exaggerated value + }) + const block = new Block({ common: mainnet }) + + const err = await runTx(vm)({ + tx, + block, + skipNonce: true, + skipBalance: false, + }).catch((e) => e) + + expect(err).toBeInstanceOf(InsufficientFundsError) + expect(err).toMatchSnapshot() + }) + + it('should throw NonceTooLowError', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: 1n, + }) + const block = new Block({ common: mainnet }) + await vm.stateManager.putAccount( + EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + EthjsAccount.fromAccountData({ + balance: parseEther('1'), + nonce: 5n, // Higher nonce + }), + ) + + const err = await runTx(vm)({ + tx, + block, + skipNonce: false, + skipBalance: true, + }).catch((e) => e) + + expect(err).toBeInstanceOf(NonceTooLowError) + expect(err).toMatchSnapshot() + }) + + it('should report access list', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: 1n, + }) + const block = new Block({ common: mainnet }) + + const result = await runTx(vm)({ + tx, + block, + skipNonce: true, + skipBalance: true, + reportAccessList: true, + }) + + expect(result.accessList).toBeDefined() + expect(result).toMatchSnapshot() + }) + + it.todo('should throw InvalidGasPriceError for blob transactions', async () => { + const sender = EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address) + + await vm.stateManager.putAccount( + sender, + EthjsAccount.fromAccountData({ + balance: parseEther('1000'), + nonce: 0n, + }), + ) + + const tx = BlobEIP4844Transaction.fromTxData( + { + blobVersionedHashes: [randomBytes(32)], + blobs: [randomBytes(32)], + kzgCommitments: [randomBytes(32)], + maxFeePerBlobGas: 1000000n, + gasLimit: 0xffffffn, + to: randomBytes(20), + }, + { common: mainnet.ethjsCommon }, + ).sign(randomBytes(32)) + + const block = new Block({ common: mainnet }) + const err = await runTx(vm)({ + tx, + block, + skipNonce: true, + skipBalance: false, + }).catch((e) => e) + + expect(err).toBeInstanceOf(InvalidGasPriceError) + expect(err).toMatchSnapshot() + }) + + it.todo('should throw EipNotEnabledError for blob transactions when EIP-4844 is not active', async () => {}) + + it('should handle EIP-1559 transactions', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 1000000n, + maxPriorityFeePerGas: 500000n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: 1n, + }) + const block = new Block({ common: mainnet }) + + const result = await runTx(vm)({ + tx, + block, + skipNonce: true, + skipBalance: true, + }) + + expect(result.execResult.exceptionError).toBeUndefined() + expect(result).toMatchSnapshot() + }) + + it.todo('should handle transactions with access list', async () => {}) + + it('should execute a transaction with selfdestruct', async () => {}) + + it('should generate transaction receipt correctly', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(PREFUNDED_ACCOUNTS[0].address), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + to: EthjsAddress.fromString(`0x${'69'.repeat(20)}`), + value: 1n, + }) + const block = new Block({ common: mainnet }) + + const result = await runTx(vm)({ + tx, + block, + skipNonce: true, + skipBalance: true, + }) + + expect(result.receipt).toBeDefined() + expect(result).toMatchSnapshot() + }) +}) diff --git a/packages/vm/src/actions/validateRunTx.js b/packages/vm/src/actions/validateRunTx.js index 1253674150..7bc97f177d 100644 --- a/packages/vm/src/actions/validateRunTx.js +++ b/packages/vm/src/actions/validateRunTx.js @@ -21,7 +21,7 @@ export const validateRunTx = (vm) => { ? opts : { ...opts, - block: opts.block ?? Block.fromBlockData({}, { common: vm.common }), + block: opts.block ?? Block.fromBlockData({ header: {} }, { common: vm.common }), } ) if (_opts.skipHardForkValidation !== true) { diff --git a/packages/vm/src/actions/validateRunTx.spec.ts b/packages/vm/src/actions/validateRunTx.spec.ts new file mode 100644 index 0000000000..5db4ef51e7 --- /dev/null +++ b/packages/vm/src/actions/validateRunTx.spec.ts @@ -0,0 +1,195 @@ +import { beforeEach, describe, expect, it, jest } from 'bun:test' +import { Block } from '@tevm/block' +import { createChain } from '@tevm/blockchain' +import { type Common, createCommon, mainnet, optimism } from '@tevm/common' +import { BlockGasLimitExceededError, EipNotEnabledError, MisconfiguredClientError } from '@tevm/errors' +import { createEvm } from '@tevm/evm' +import { createStateManager } from '@tevm/state' +import { createImpersonatedTx } from '@tevm/tx' +import { EthjsAddress } from '@tevm/utils' +import type { Vm } from '../Vm.js' +import { createVm } from '../createVm.js' +import { validateRunTx } from './validateRunTx.js' + +describe('validateRunTx', () => { + let vm: Vm + let common: Common + + beforeEach(async () => { + common = createCommon({ ...mainnet, hardfork: 'cancun', loggingLevel: 'warn' }) + const stateManager = createStateManager({}) + const blockchain = await createChain({ common }) + const evm = await createEvm({ common, stateManager, blockchain }) + vm = createVm({ + common, + evm, + stateManager, + blockchain, + activatePrecompiles: false, + }) + }) + + it('should throw MisconfiguredClientError if no preMerge hardfork is found', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + }) + + const block = Block.fromBlockData( + { + header: { + parentHash: `0x${'11'.repeat(32)}`, + }, + }, + { common }, + ) + + vm.common.ethjsCommon.hardforks = jest.fn().mockReturnValue([]) + + const err = await validateRunTx(vm)({ tx, block }).catch((e) => e) + expect(err).toBeInstanceOf(MisconfiguredClientError) + expect(err).toMatchSnapshot() + }) + + it('should throw BlockGasLimitExceededError if tx gas limit exceeds block gas limit', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + }) + + const block = Block.fromBlockData({ header: { gasLimit: 21000 } }, { common }) + + const err = await validateRunTx(vm)({ tx, block }).catch((e) => e) + expect(err).toBeInstanceOf(BlockGasLimitExceededError) + expect(err).toMatchSnapshot() + }) + + it('should throw EipNotEnabledError if EIP 2930 is not activated for Access List transaction', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + accessList: [], + }) + + const block = Block.fromBlockData( + { + header: {}, + }, + { common }, + ) + + vm.common.ethjsCommon.isActivatedEIP = jest.fn((eip) => eip !== 2930) + + const err = await validateRunTx(vm)({ tx, block }).catch((e) => e) + expect(err).toBeInstanceOf(EipNotEnabledError) + expect(err).toMatchSnapshot() + }) + + it('should throw EipNotEnabledError if EIP 1559 is not activated for Fee Market transaction', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxPriorityFeePerGas: 1n, + accessList: [], + maxFeePerGas: 10n, + }) + + const block = Block.fromBlockData({ header: {} }, { common }) + + vm.common.ethjsCommon.isActivatedEIP = jest.fn((eip) => eip !== 1559) + + const err = await validateRunTx(vm)({ tx, block }).catch((e) => e) + expect(err).toBeInstanceOf(EipNotEnabledError) + expect(err).toMatchSnapshot() + }) + + it('should validate options successfully', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + }) + + const block = Block.fromBlockData({ header: {} }, { common }) + + vm.common.ethjsCommon.isActivatedEIP = jest.fn(() => true) + + const opts = { tx, block } + const validate = validateRunTx(vm) + + const result = await validate(opts) + + expect(result).toEqual({ + ...opts, + block, + }) + }) + + it('should validate options successfully with no block', async () => { + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + }) + + vm.common.ethjsCommon.isActivatedEIP = jest.fn(() => true) + + const opts = { tx } + const validate = validateRunTx(vm) + + const { block, ...rest } = await validate(opts) + + expect(block.header.number).toMatchSnapshot() + expect(block.header.hash).toMatchSnapshot() + expect(rest).toMatchSnapshot() + }) + + it('should throw if hardfork doesn not match', async () => { + const mockCommon = optimism.copy() + ;(mockCommon.ethjsCommon as any)._hardfork = 'shanghai' + mockCommon.copy = () => mockCommon + const tx = createImpersonatedTx({ + impersonatedAddress: EthjsAddress.fromString(`0x${'11'.repeat(20)}`), + nonce: 0, + gasLimit: 21064, + maxFeePerGas: 8n, + maxPriorityFeePerGas: 1n, + }) + + const block = Block.fromBlockData( + { + header: { + parentHash: `0x${'11'.repeat(32)}`, + }, + }, + { common: mockCommon }, + ) + + const opts = { tx, block, skipHardforkValidation: false } + const validate = validateRunTx(vm) + + const err = await validate(opts).catch((e) => e) + + if (!(err instanceof Error)) { + throw new Error('Expected error to be an instance of Error') + } + + expect(err).toBeInstanceOf(Error) + expect(err).toBeInstanceOf(MisconfiguredClientError) + expect(err).toMatchSnapshot() + }) +}) diff --git a/packages/vm/src/actions/warmAddresses2929.spec.ts b/packages/vm/src/actions/warmAddresses2929.spec.ts new file mode 100644 index 0000000000..b48e33c03e --- /dev/null +++ b/packages/vm/src/actions/warmAddresses2929.spec.ts @@ -0,0 +1,81 @@ +import { type Mock, beforeEach, describe, expect, it, jest } from 'bun:test' +import { EthjsAddress, bytesToUnprefixedHex } from '@tevm/utils' +import type { Vm } from '../Vm.js' +import { warmAddresses2929 } from './warmAddresses2929.js' + +describe('warmAddresses2929', () => { + let vm: Vm + let caller: EthjsAddress + let to: EthjsAddress | undefined + let coinbase: EthjsAddress + + beforeEach(() => { + caller = EthjsAddress.fromString(`0x${'11'.repeat(20)}`) + to = EthjsAddress.fromString(`0x${'22'.repeat(20)}`) + coinbase = EthjsAddress.fromString(`0x${'33'.repeat(20)}`) + + vm = { + common: { + ethjsCommon: { + isActivatedEIP: jest.fn().mockReturnValue(false), + }, + }, + evm: { + precompiles: new Map([ + ['0x01', {}], + ['0x02', {}], + ]), + journal: { + addAlwaysWarmAddress: jest.fn(), + }, + }, + } as unknown as Vm + }) + + it('should not add any addresses if EIP 2929 is not activated', () => { + warmAddresses2929(vm, caller, to, coinbase) + expect(vm.evm.journal.addAlwaysWarmAddress).not.toHaveBeenCalled() + }) + + it('should add origin and precompiles to warm addresses if EIP 2929 is activated', () => { + ;(vm.common.ethjsCommon.isActivatedEIP as Mock).mockImplementation( + (eip) => eip === 2929, + ) + + warmAddresses2929(vm, caller, to, coinbase) + + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith('0x01') + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith('0x02') + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith(caller.toString()) + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith(bytesToUnprefixedHex(to?.bytes as any)) + expect(vm.evm.journal.addAlwaysWarmAddress).not.toHaveBeenCalledWith(coinbase.toString()) + }) + + it('should add coinbase to warm addresses if EIP 3651 is also activated', () => { + ;(vm.common.ethjsCommon.isActivatedEIP as Mock).mockImplementation( + (eip) => eip === 2929 || eip === 3651, + ) + + warmAddresses2929(vm, caller, to, coinbase) + + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith('0x01') + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith('0x02') + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith(caller.toString()) + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith(bytesToUnprefixedHex(to?.bytes as any)) + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith(bytesToUnprefixedHex(coinbase.bytes)) + }) + + it('should handle undefined "to" address correctly', () => { + ;(vm.common.ethjsCommon.isActivatedEIP as Mock).mockImplementation( + (eip) => eip === 2929, + ) + to = undefined + + warmAddresses2929(vm, caller, to, coinbase) + + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith('0x01') + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith('0x02') + expect(vm.evm.journal.addAlwaysWarmAddress).toHaveBeenCalledWith(caller.toString()) + expect(vm.evm.journal.addAlwaysWarmAddress).not.toHaveBeenCalledWith(coinbase.toString()) + }) +}) diff --git a/packages/vm/src/createBaseVm.spec.ts b/packages/vm/src/createBaseVm.spec.ts new file mode 100644 index 0000000000..a65703fdde --- /dev/null +++ b/packages/vm/src/createBaseVm.spec.ts @@ -0,0 +1,48 @@ +import { beforeEach, describe, expect, it, jest } from 'bun:test' +import { createChain } from '@tevm/blockchain' +import { mainnet } from '@tevm/common' +import { createEvm } from '@tevm/evm' +import { createStateManager } from '@tevm/state' +import { AsyncEventEmitter } from '@tevm/utils' +import { createBaseVm } from './createBaseVm.js' + +describe('createBaseVm', () => { + let opts: any + + beforeEach(async () => { + const common = mainnet + const stateManager = createStateManager({}) + const blockchain = await createChain({ common }) + const evm = await createEvm({ common, stateManager, blockchain }) + opts = { + stateManager, + evm, + blockchain, + common, + } + }) + + it('should create a BaseVm instance', () => { + const baseVm = createBaseVm(opts) + expect(baseVm).toBeDefined() + expect(baseVm.stateManager).toBe(opts.stateManager) + expect(baseVm.evm).toBe(opts.evm) + expect(baseVm.blockchain).toBe(opts.blockchain) + expect(baseVm.common).toBe(opts.common) + expect(baseVm.events).toBeInstanceOf(AsyncEventEmitter) + }) + + it('should emit events correctly', async () => { + const baseVm = createBaseVm(opts) + const mockCallback = jest.fn() + baseVm.events.on('afterTx', mockCallback) + const expectedData = { test: 'data' } + await baseVm._emit('afterTx', expectedData) + expect(mockCallback).toHaveBeenCalledWith(expectedData) + }) + + it('should call ready functions on stateManager and blockchain', async () => { + const baseVm = createBaseVm(opts) + expect(await baseVm.ready()).toBeTrue() + }) +}) diff --git a/packages/vm/src/index.ts b/packages/vm/src/index.ts index cbac73d2f4..8a7b10c3d2 100644 --- a/packages/vm/src/index.ts +++ b/packages/vm/src/index.ts @@ -1,28 +1,7 @@ export type { Vm } from './Vm.js' export { createVm } from './createVm.js' export { type CreateVmOptions } from './CreateVmOptions.js' -export {} from './actions/runBlock.js' -export { - type BuildBlock, - type RunBlock, - type BlockStatus, - type AddTransactionError, - type DeepCopy, - buildBlock, - BlockBuilder, - BuildStatus, - runTx, - generateTxReceipt, - runBlock, - txLogsBloom, - rewardAccount, - execHardfork, - encodeReceipt, - calculateMinerReward, - accumulateParentBeaconBlockRoot, - accumulateParentBlockHash, - deepCopy, -} from './actions/index.js' +export * from './actions/index.js' export type { VMOpts, RunTxOpts, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4cda5f05ab..20cfb0758d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -814,7 +814,7 @@ importers: dependencies: '@rainbow-me/rainbowkit': specifier: ^2.1.2 - version: 2.1.2(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(wagmi@2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8)) + version: 2.1.2(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(wagmi@2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8)) '@tanstack/react-query': specifier: ^5.48.0 version: 5.48.0(react@18.3.1) @@ -871,7 +871,7 @@ importers: version: 3.3.0(vite@5.3.1(@types/node@20.14.8)(terser@5.31.1)) wagmi: specifier: ^2.10.7 - version: 2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) + version: 2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) zod: specifier: ^3.23.8 version: 3.23.8 @@ -2168,6 +2168,9 @@ importers: specifier: ^2.14.2 version: 2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) devDependencies: + '@tevm/contract': + specifier: 1.1.0-next.91 + version: 1.1.0-next.91(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8))(zod@3.23.8) '@tevm/tsconfig': specifier: workspace:^ version: link:../../configs/tsconfig @@ -2206,7 +2209,7 @@ importers: version: 2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) wagmi: specifier: ^2.10.7 - version: 2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) + version: 2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) devDependencies: '@tevm/tsconfig': specifier: workspace:^ @@ -5892,6 +5895,19 @@ packages: '@types/react-dom': optional: true + '@tevm/contract@1.1.0-next.91': + resolution: {integrity: sha512-KmUspfN4Qvxzx/tkrt0nNrhi1qtmNxUJx6NVjwDKdG0LQoBSVGPaoF+3Iq5Dor3LRQvsB0/veXg9pg688q+b2A==} + + '@tevm/errors@1.0.0-next.86': + resolution: {integrity: sha512-WG0eJEWG82XIZggLGB0e966zC5OGa9E5YRxAmvLDfIgajUqpxv/heCfTDxJhE2HS4NTU9fWejQhFBUo0WGNlxA==} + peerDependencies: + viem: ^2.14.2 + + '@tevm/utils@1.1.0-next.91': + resolution: {integrity: sha512-pLrvVf/BG/ksSI/L6WeuNCaurxSOiZwPMVGJBkIlNwb3LVZZrNYzV6oEHV3miV7jK4M8JThyPtWhqaxpbqcxgA==} + peerDependencies: + viem: ^2.14.2 + '@tootallnate/quickjs-emscripten@0.23.0': resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} @@ -7176,7 +7192,6 @@ packages: bun@1.1.18: resolution: {integrity: sha512-bv1wLYtmkn6GCqYFsVO9xZzPvNaDlA3xHbtePGHMtXMqq8N/vo+L6b19LB4+I5RKXFAsSmgzonyh2oMExaaWcQ==} - cpu: [arm64, x64] os: [darwin, linux, win32] hasBin: true @@ -16643,14 +16658,13 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-native: 0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1) - '@metamask/sdk-install-modal-web@0.26.0(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)': + '@metamask/sdk-install-modal-web@0.26.0(i18next@22.5.1)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)': dependencies: i18next: 22.5.1 qr-code-styling: 1.6.0-rc.1 - react-i18next: 14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1) + react-i18next: 14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1) optionalDependencies: react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) react-native: 0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1) '@metamask/sdk@0.26.3(bufferutil@4.0.8)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)': @@ -16689,12 +16703,12 @@ snapshots: - supports-color - utf-8-validate - '@metamask/sdk@0.26.3(bufferutil@4.0.8)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)': + '@metamask/sdk@0.26.3(bufferutil@4.0.8)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)': dependencies: '@metamask/onboarding': 1.0.1 '@metamask/providers': 15.0.0 '@metamask/sdk-communication-layer': 0.26.2(cross-fetch@4.0.0)(eciesjs@0.3.19)(eventemitter2@6.4.9)(readable-stream@3.6.2)(socket.io-client@4.7.5(bufferutil@4.0.8)) - '@metamask/sdk-install-modal-web': 0.26.0(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1) + '@metamask/sdk-install-modal-web': 0.26.0(i18next@22.5.1)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1) '@types/dom-screen-wake-lock': 1.0.3 bowser: 2.11.0 cross-fetch: 4.0.0 @@ -16715,7 +16729,6 @@ snapshots: uuid: 8.3.2 optionalDependencies: react: 18.3.1 - react-dom: 18.3.1(react@18.3.1) transitivePeerDependencies: - bufferutil - encoding @@ -17678,7 +17691,7 @@ snapshots: '@radix-ui/rect@1.1.0': {} - '@rainbow-me/rainbowkit@2.1.2(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(wagmi@2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8))': + '@rainbow-me/rainbowkit@2.1.2(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(wagmi@2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8))': dependencies: '@tanstack/react-query': 5.48.0(react@18.3.1) '@vanilla-extract/css': 1.14.0 @@ -17691,7 +17704,7 @@ snapshots: react-remove-scroll: 2.5.7(@types/react@18.3.3)(react@18.3.1) ua-parser-js: 1.0.38 viem: 2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) - wagmi: 2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) + wagmi: 2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@22.5.1)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) transitivePeerDependencies: - '@types/react' @@ -18553,6 +18566,34 @@ snapshots: '@types/react': 18.3.3 '@types/react-dom': 18.3.0 + '@tevm/contract@1.1.0-next.91(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8))(zod@3.23.8)': + dependencies: + '@tevm/utils': 1.1.0-next.91(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8))(zod@3.23.8) + transitivePeerDependencies: + - supports-color + - typescript + - viem + - zod + + '@tevm/errors@1.0.0-next.86(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8))': + dependencies: + '@ethereumjs/evm': 3.0.0 + viem: 2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) + transitivePeerDependencies: + - supports-color + + '@tevm/utils@1.1.0-next.91(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8))(zod@3.23.8)': + dependencies: + '@ethereumjs/evm': 3.0.0 + '@ethereumjs/util': 9.0.3 + '@tevm/errors': 1.0.0-next.86(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8)) + abitype: 1.0.4(typescript@5.5.2)(zod@3.23.8) + viem: 2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) + transitivePeerDependencies: + - supports-color + - typescript + - zod + '@tootallnate/quickjs-emscripten@0.23.0': {} '@types/acorn@4.0.6': @@ -19239,10 +19280,10 @@ snapshots: - utf-8-validate - zod - '@wagmi/connectors@5.0.19(@types/react@18.3.3)(@wagmi/core@2.11.5(@tanstack/query-core@5.48.0)(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8)': + '@wagmi/connectors@5.0.19(@types/react@18.3.3)(@wagmi/core@2.11.5(@tanstack/query-core@5.48.0)(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(ioredis@5.4.1)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8)': dependencies: '@coinbase/wallet-sdk': 4.0.3 - '@metamask/sdk': 0.26.3(bufferutil@4.0.8)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0) + '@metamask/sdk': 0.26.3(bufferutil@4.0.8)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0) '@safe-global/safe-apps-provider': 0.18.1(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) '@safe-global/safe-apps-sdk': 8.1.0(bufferutil@4.0.8)(typescript@5.5.2)(utf-8-validate@6.0.4)(zod@3.23.8) '@wagmi/core': 2.11.5(@tanstack/query-core@5.48.0)(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) @@ -23924,7 +23965,7 @@ snapshots: dependencies: ws: 8.13.0(bufferutil@4.0.8)(utf-8-validate@6.0.4) - isows@1.0.4(ws@8.17.1(bufferutil@4.0.8)): + isows@1.0.4(ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4)): dependencies: ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4) @@ -26481,14 +26522,13 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-native: 0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1) - react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1): + react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.24.7 html-parse-stringify: 3.0.1 i18next: 23.11.5 react: 18.3.1 optionalDependencies: - react-dom: 18.3.1(react@18.3.1) react-native: 0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1) react-is@16.13.1: {} @@ -28842,7 +28882,7 @@ snapshots: '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 abitype: 1.0.0(typescript@5.5.2)(zod@3.23.8) - isows: 1.0.4(ws@8.17.1(bufferutil@4.0.8)) + isows: 1.0.4(ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4)) ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4) optionalDependencies: typescript: 5.5.2 @@ -28859,7 +28899,7 @@ snapshots: '@scure/bip32': 1.3.2 '@scure/bip39': 1.2.1 abitype: 1.0.4(typescript@5.5.2)(zod@3.23.8) - isows: 1.0.4(ws@8.17.1(bufferutil@4.0.8)) + isows: 1.0.4(ws@8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4)) ws: 8.17.1(bufferutil@4.0.8)(utf-8-validate@6.0.4) optionalDependencies: typescript: 5.5.2 @@ -29277,10 +29317,10 @@ snapshots: - utf-8-validate - zod - wagmi@2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8): + wagmi@2.10.7(@tanstack/query-core@5.48.0)(@tanstack/react-query@5.48.0(react@18.3.1))(@types/react@18.3.3)(bufferutil@4.0.8)(ioredis@5.4.1)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8): dependencies: '@tanstack/react-query': 5.48.0(react@18.3.1) - '@wagmi/connectors': 5.0.19(@types/react@18.3.3)(@wagmi/core@2.11.5(@tanstack/query-core@5.48.0)(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(ioredis@5.4.1)(react-dom@18.3.1(react@18.3.1))(react-i18next@14.1.2(i18next@23.11.5)(react-dom@18.3.1(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) + '@wagmi/connectors': 5.0.19(@types/react@18.3.3)(@wagmi/core@2.11.5(@tanstack/query-core@5.48.0)(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8))(bufferutil@4.0.8)(ioredis@5.4.1)(react-i18next@14.1.2(i18next@23.11.5)(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1))(react-native@0.74.2(@babel/core@7.24.7)(@babel/preset-env@7.24.7(@babel/core@7.24.7))(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1))(react@18.3.1)(rollup@4.18.0)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) '@wagmi/core': 2.11.5(@tanstack/query-core@5.48.0)(@types/react@18.3.3)(bufferutil@4.0.8)(react@18.3.1)(typescript@5.5.2)(viem@2.16.2(bufferutil@4.0.8)(typescript@5.5.2)(zod@3.23.8))(zod@3.23.8) react: 18.3.1 use-sync-external-store: 1.2.0(react@18.3.1) diff --git a/tevm/docs/utils/README.md b/tevm/docs/utils/README.md index 61f3dcc72a..a3d577e142 100644 --- a/tevm/docs/utils/README.md +++ b/tevm/docs/utils/README.md @@ -51,6 +51,7 @@ ### Variables +- [GWEI\_TO\_WEI](variables/GWEI_TO_WEI.md) - [KECCAK256\_RLP](variables/KECCAK256_RLP.md) - [KECCAK256\_RLP\_ARRAY](variables/KECCAK256_RLP_ARRAY.md) @@ -65,6 +66,7 @@ - [fetchFromProvider](functions/fetchFromProvider.md) - [getProvider](functions/getProvider.md) - [invariant](functions/invariant.md) +- [randomBytes](functions/randomBytes.md) - [serializeTransaction](functions/serializeTransaction.md) - [setLengthLeft](functions/setLengthLeft.md) - [toType](functions/toType.md) diff --git a/tevm/docs/utils/functions/randomBytes.md b/tevm/docs/utils/functions/randomBytes.md new file mode 100644 index 0000000000..b1f8b8d552 --- /dev/null +++ b/tevm/docs/utils/functions/randomBytes.md @@ -0,0 +1,25 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [utils](../README.md) / randomBytes + +# Function: randomBytes() + +> **randomBytes**(`length`): `Uint8Array` + +## Parameters + +• **length**: `number` + +The length of the Uint8Array. + +## Returns + +`Uint8Array` + +A Uint8Array of random bytes of specified length. + +## Defined in + +node\_modules/.pnpm/@ethereumjs+util@9.0.3/node\_modules/@ethereumjs/util/dist/esm/bytes.d.ts:186 diff --git a/tevm/docs/utils/variables/GWEI_TO_WEI.md b/tevm/docs/utils/variables/GWEI_TO_WEI.md new file mode 100644 index 0000000000..4f1fe669d9 --- /dev/null +++ b/tevm/docs/utils/variables/GWEI_TO_WEI.md @@ -0,0 +1,15 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [utils](../README.md) / GWEI\_TO\_WEI + +# Variable: GWEI\_TO\_WEI + +> `const` **GWEI\_TO\_WEI**: `bigint` + +Easy conversion from Gwei to wei + +## Defined in + +node\_modules/.pnpm/@ethereumjs+util@9.0.3/node\_modules/@ethereumjs/util/dist/esm/units.d.ts:2 diff --git a/tevm/docs/vm/README.md b/tevm/docs/vm/README.md index 11fd45caf2..0caaea2279 100644 --- a/tevm/docs/vm/README.md +++ b/tevm/docs/vm/README.md @@ -41,6 +41,7 @@ - [BuildBlock](type-aliases/BuildBlock.md) - [CreateVmOptions](type-aliases/CreateVmOptions.md) - [DeepCopy](type-aliases/DeepCopy.md) +- [DeepCopyError](type-aliases/DeepCopyError.md) - [EVMProfilerOpts](type-aliases/EVMProfilerOpts.md) - [RunBlock](type-aliases/RunBlock.md) - [TxReceipt](type-aliases/TxReceipt.md) @@ -48,16 +49,30 @@ - [VMProfilerOpts](type-aliases/VMProfilerOpts.md) - [Vm](type-aliases/Vm.md) +### Variables + +- [DAOConfig](variables/DAOConfig.md) +- [KECCAK256\_NULL](variables/KECCAK256_NULL.md) +- [parentBeaconBlockRootAddress](variables/parentBeaconBlockRootAddress.md) + ### Functions - [accumulateParentBeaconBlockRoot](functions/accumulateParentBeaconBlockRoot.md) - [accumulateParentBlockHash](functions/accumulateParentBlockHash.md) +- [applyBlock](functions/applyBlock.md) +- [applyDAOHardfork](functions/applyDAOHardfork.md) +- [applyTransactions](functions/applyTransactions.md) +- [assignBlockRewards](functions/assignBlockRewards.md) +- [assignWithdrawals](functions/assignWithdrawals.md) - [buildBlock](functions/buildBlock.md) - [calculateMinerReward](functions/calculateMinerReward.md) +- [calculateOmmerReward](functions/calculateOmmerReward.md) - [createVm](functions/createVm.md) - [deepCopy](functions/deepCopy.md) -- [encodeReceipt](functions/encodeReceipt.md) - [execHardfork](functions/execHardfork.md) +- [genTxTrie](functions/genTxTrie.md) - [generateTxReceipt](functions/generateTxReceipt.md) - [rewardAccount](functions/rewardAccount.md) - [txLogsBloom](functions/txLogsBloom.md) +- [validateRunTx](functions/validateRunTx.md) +- [warmAddresses2929](functions/warmAddresses2929.md) diff --git a/tevm/docs/vm/functions/accumulateParentBeaconBlockRoot.md b/tevm/docs/vm/functions/accumulateParentBeaconBlockRoot.md index 91ddc6a66f..92dc24971d 100644 --- a/tevm/docs/vm/functions/accumulateParentBeaconBlockRoot.md +++ b/tevm/docs/vm/functions/accumulateParentBeaconBlockRoot.md @@ -28,4 +28,4 @@ ## Defined in -packages/vm/types/actions/runBlock.d.ts:21 +packages/vm/types/actions/accumulateParentBeaconBlockRoot.d.ts:2 diff --git a/tevm/docs/vm/functions/accumulateParentBlockHash.md b/tevm/docs/vm/functions/accumulateParentBlockHash.md index a1383577a8..636de20684 100644 --- a/tevm/docs/vm/functions/accumulateParentBlockHash.md +++ b/tevm/docs/vm/functions/accumulateParentBlockHash.md @@ -34,4 +34,4 @@ also add the currently available past blockhashes which are available by BLOCKHA ## Defined in -packages/vm/types/actions/runBlock.d.ts:20 +packages/vm/types/actions/accumulateParentBlockHash.d.ts:11 diff --git a/tevm/docs/vm/functions/applyBlock.md b/tevm/docs/vm/functions/applyBlock.md new file mode 100644 index 0000000000..c944f53010 --- /dev/null +++ b/tevm/docs/vm/functions/applyBlock.md @@ -0,0 +1,36 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / applyBlock + +# Function: applyBlock() + +> **applyBlock**(`vm`): (`block`, `opts`) => `Promise`\<[`ApplyBlockResult`](../interfaces/ApplyBlockResult.md)\> + +Validates and applies a block, computing the results of +applying its transactions. This method doesn't modify the +block itself. It computes the block rewards and puts +them on state (but doesn't persist the changes). + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: [`Block`](../../block/classes/Block.md) + +• **opts**: [`RunBlockOpts`](../interfaces/RunBlockOpts.md) + +### Returns + +`Promise`\<[`ApplyBlockResult`](../interfaces/ApplyBlockResult.md)\> + +## Defined in + +packages/vm/types/actions/applyBlock.d.ts:12 diff --git a/tevm/docs/vm/functions/applyDAOHardfork.md b/tevm/docs/vm/functions/applyDAOHardfork.md new file mode 100644 index 0000000000..c868a3cfaa --- /dev/null +++ b/tevm/docs/vm/functions/applyDAOHardfork.md @@ -0,0 +1,23 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / applyDAOHardfork + +# Function: applyDAOHardfork() + +> **applyDAOHardfork**(`evm`): `Promise`\<`void`\> + +Apply the DAO fork changes to the VM + +## Parameters + +• **evm**: [`Evm`](../../evm/classes/Evm.md) + +## Returns + +`Promise`\<`void`\> + +## Defined in + +packages/vm/types/actions/applyDAOHardfork.d.ts:5 diff --git a/tevm/docs/vm/functions/applyTransactions.md b/tevm/docs/vm/functions/applyTransactions.md new file mode 100644 index 0000000000..9671de9702 --- /dev/null +++ b/tevm/docs/vm/functions/applyTransactions.md @@ -0,0 +1,59 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / applyTransactions + +# Function: applyTransactions() + +> **applyTransactions**(`vm`): (`block`, `opts`) => `Promise`\<`object`\> + +Applies the transactions in a block, computing the receipts +as well as gas usage and some relevant data. This method is +side-effect free (it doesn't modify the block nor the state). + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: [`Block`](../../block/classes/Block.md) + +• **opts**: [`RunBlockOpts`](../interfaces/RunBlockOpts.md) + +### Returns + +`Promise`\<`object`\> + +#### bloom + +> **bloom**: `Bloom` + +#### gasUsed + +> **gasUsed**: `bigint` + +#### preimages + +> **preimages**: `Map`\<`string`, `Uint8Array`\> + +#### receipts + +> **receipts**: [`TxReceipt`](../type-aliases/TxReceipt.md)[] + +#### receiptsRoot + +> **receiptsRoot**: `Uint8Array` + +#### results + +> **results**: [`RunTxResult`](../interfaces/RunTxResult.md)[] + +## Defined in + +packages/vm/types/actions/applyTransactions.d.ts:10 diff --git a/tevm/docs/vm/functions/assignBlockRewards.md b/tevm/docs/vm/functions/assignBlockRewards.md new file mode 100644 index 0000000000..e5accdf2e2 --- /dev/null +++ b/tevm/docs/vm/functions/assignBlockRewards.md @@ -0,0 +1,32 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / assignBlockRewards + +# Function: assignBlockRewards() + +> **assignBlockRewards**(`vm`): (`block`) => `Promise`\<`void`\> + +Calculates block rewards for miner and ommers and puts +the updated balances of their accounts to state. + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: [`Block`](../../block/classes/Block.md) + +### Returns + +`Promise`\<`void`\> + +## Defined in + +packages/vm/types/actions/assignBlockRewards.d.ts:7 diff --git a/tevm/docs/vm/functions/assignWithdrawals.md b/tevm/docs/vm/functions/assignWithdrawals.md new file mode 100644 index 0000000000..8cfc48cccc --- /dev/null +++ b/tevm/docs/vm/functions/assignWithdrawals.md @@ -0,0 +1,29 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / assignWithdrawals + +# Function: assignWithdrawals() + +> **assignWithdrawals**(`vm`): (`block`) => `Promise`\<`void`\> + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **block**: [`Block`](../../block/classes/Block.md) + +### Returns + +`Promise`\<`void`\> + +## Defined in + +packages/vm/types/actions/assignWithdrawals.d.ts:3 diff --git a/tevm/docs/vm/functions/calculateMinerReward.md b/tevm/docs/vm/functions/calculateMinerReward.md index a8aea1707d..a93986b941 100644 --- a/tevm/docs/vm/functions/calculateMinerReward.md +++ b/tevm/docs/vm/functions/calculateMinerReward.md @@ -20,4 +20,4 @@ ## Defined in -packages/vm/types/actions/runBlock.d.ts:22 +packages/vm/types/actions/calculateMinerReward.d.ts:1 diff --git a/tevm/docs/vm/functions/calculateOmmerReward.md b/tevm/docs/vm/functions/calculateOmmerReward.md new file mode 100644 index 0000000000..437bee2b4a --- /dev/null +++ b/tevm/docs/vm/functions/calculateOmmerReward.md @@ -0,0 +1,25 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / calculateOmmerReward + +# Function: calculateOmmerReward() + +> **calculateOmmerReward**(`ommerBlockNumber`, `blockNumber`, `minerReward`): `bigint` + +## Parameters + +• **ommerBlockNumber**: `bigint` + +• **blockNumber**: `bigint` + +• **minerReward**: `bigint` + +## Returns + +`bigint` + +## Defined in + +packages/vm/types/actions/calculateOmmerReward.d.ts:1 diff --git a/tevm/docs/vm/functions/encodeReceipt.md b/tevm/docs/vm/functions/encodeReceipt.md deleted file mode 100644 index ea7e95fc13..0000000000 --- a/tevm/docs/vm/functions/encodeReceipt.md +++ /dev/null @@ -1,25 +0,0 @@ -[**tevm**](../../README.md) • **Docs** - -*** - -[tevm](../../modules.md) / [vm](../README.md) / encodeReceipt - -# Function: encodeReceipt() - -> **encodeReceipt**(`receipt`, `txType`): `Uint8Array` - -Returns the encoded tx receipt. - -## Parameters - -• **receipt**: [`TxReceipt`](../type-aliases/TxReceipt.md) - -• **txType**: [`TransactionType`](../../tx/enumerations/TransactionType.md) - -## Returns - -`Uint8Array` - -## Defined in - -packages/vm/types/actions/runBlock.d.ts:27 diff --git a/tevm/docs/vm/functions/genTxTrie.md b/tevm/docs/vm/functions/genTxTrie.md new file mode 100644 index 0000000000..15b400146d --- /dev/null +++ b/tevm/docs/vm/functions/genTxTrie.md @@ -0,0 +1,21 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / genTxTrie + +# Function: genTxTrie() + +> **genTxTrie**(`block`): `Promise`\<`Uint8Array`\> + +## Parameters + +• **block**: [`Block`](../../block/classes/Block.md) + +## Returns + +`Promise`\<`Uint8Array`\> + +## Defined in + +packages/vm/types/actions/genTxTrie.d.ts:2 diff --git a/tevm/docs/vm/functions/rewardAccount.md b/tevm/docs/vm/functions/rewardAccount.md index 1047230eb6..4d13f78c09 100644 --- a/tevm/docs/vm/functions/rewardAccount.md +++ b/tevm/docs/vm/functions/rewardAccount.md @@ -22,4 +22,4 @@ ## Defined in -packages/vm/types/actions/runBlock.d.ts:23 +packages/vm/types/actions/rewardAccount.d.ts:3 diff --git a/tevm/docs/vm/functions/validateRunTx.md b/tevm/docs/vm/functions/validateRunTx.md new file mode 100644 index 0000000000..90044e3b1c --- /dev/null +++ b/tevm/docs/vm/functions/validateRunTx.md @@ -0,0 +1,29 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / validateRunTx + +# Function: validateRunTx() + +> **validateRunTx**(`vm`): (`opts`) => `Promise`\<`RunTxOpts` & `Required`\<`Pick`\<`RunTxOpts`, `"block"`\>\>\> + +## Parameters + +• **vm**: `BaseVm` + +## Returns + +`Function` + +### Parameters + +• **opts**: `RunTxOpts` + +### Returns + +`Promise`\<`RunTxOpts` & `Required`\<`Pick`\<`RunTxOpts`, `"block"`\>\>\> + +## Defined in + +packages/vm/types/actions/validateRunTx.d.ts:1 diff --git a/tevm/docs/vm/functions/warmAddresses2929.md b/tevm/docs/vm/functions/warmAddresses2929.md new file mode 100644 index 0000000000..0a1d1c0a80 --- /dev/null +++ b/tevm/docs/vm/functions/warmAddresses2929.md @@ -0,0 +1,27 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / warmAddresses2929 + +# Function: warmAddresses2929() + +> **warmAddresses2929**(`vm`, `caller`, `to`, `coinbase`): `void` + +## Parameters + +• **vm**: `BaseVm` + +• **caller**: [`EthjsAddress`](../../utils/classes/EthjsAddress.md) + +• **to**: `undefined` \| [`EthjsAddress`](../../utils/classes/EthjsAddress.md) + +• **coinbase**: [`EthjsAddress`](../../utils/classes/EthjsAddress.md) + +## Returns + +`void` + +## Defined in + +packages/vm/types/actions/warmAddresses2929.d.ts:1 diff --git a/tevm/docs/vm/interfaces/ApplyBlockResult.md b/tevm/docs/vm/interfaces/ApplyBlockResult.md index 8fc4a73018..316eabded0 100644 --- a/tevm/docs/vm/interfaces/ApplyBlockResult.md +++ b/tevm/docs/vm/interfaces/ApplyBlockResult.md @@ -6,7 +6,7 @@ # Interface: ApplyBlockResult -Result of applyBlock +Result of [applyBlock](../functions/applyBlock.md) ## Properties diff --git a/tevm/docs/vm/type-aliases/DeepCopyError.md b/tevm/docs/vm/type-aliases/DeepCopyError.md new file mode 100644 index 0000000000..e37f5f2fe6 --- /dev/null +++ b/tevm/docs/vm/type-aliases/DeepCopyError.md @@ -0,0 +1,13 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / DeepCopyError + +# Type Alias: DeepCopyError + +> **DeepCopyError**: [`MisconfiguredClientError`](../../errors/classes/MisconfiguredClientError.md) + +## Defined in + +packages/vm/types/actions/deepCopy.d.ts:2 diff --git a/tevm/docs/vm/type-aliases/RunBlock.md b/tevm/docs/vm/type-aliases/RunBlock.md index 807030bdc9..ae2aba7ca8 100644 --- a/tevm/docs/vm/type-aliases/RunBlock.md +++ b/tevm/docs/vm/type-aliases/RunBlock.md @@ -18,4 +18,4 @@ ## Defined in -packages/vm/types/actions/runBlock.d.ts:6 +packages/vm/types/actions/runBlock.d.ts:3 diff --git a/tevm/docs/vm/variables/DAOConfig.md b/tevm/docs/vm/variables/DAOConfig.md new file mode 100644 index 0000000000..dd3f22782e --- /dev/null +++ b/tevm/docs/vm/variables/DAOConfig.md @@ -0,0 +1,23 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / DAOConfig + +# Variable: DAOConfig + +> `const` **DAOConfig**: `object` + +## Type declaration + +### DAOAccounts + +> `readonly` **DAOAccounts**: readonly [`"d4fe7bc31cedb7bfb8a345f31e668033056b2728"`, `"b3fb0e5aba0e20e5c49d252dfd30e102b171a425"`, `"2c19c7f9ae8b751e37aeb2d93a699722395ae18f"`, `"ecd135fa4f61a655311e86238c92adcd779555d2"`, `"1975bd06d486162d5dc297798dfc41edd5d160a7"`, `"a3acf3a1e16b1d7c315e23510fdd7847b48234f6"`, `"319f70bab6845585f412ec7724b744fec6095c85"`, `"06706dd3f2c9abf0a21ddcc6941d9b86f0596936"`, `"5c8536898fbb74fc7445814902fd08422eac56d0"`, `"6966ab0d485353095148a2155858910e0965b6f9"`, `"779543a0491a837ca36ce8c635d6154e3c4911a6"`, `"2a5ed960395e2a49b1c758cef4aa15213cfd874c"`, `"5c6e67ccd5849c0d29219c4f95f1a7a93b3f5dc5"`, `"9c50426be05db97f5d64fc54bf89eff947f0a321"`, `"200450f06520bdd6c527622a273333384d870efb"`, `"be8539bfe837b67d1282b2b1d61c3f723966f049"`, `"6b0c4d41ba9ab8d8cfb5d379c69a612f2ced8ecb"`, `"f1385fb24aad0cd7432824085e42aff90886fef5"`, `"d1ac8b1ef1b69ff51d1d401a476e7e612414f091"`, `"8163e7fb499e90f8544ea62bbf80d21cd26d9efd"`, `"51e0ddd9998364a2eb38588679f0d2c42653e4a6"`, `"627a0a960c079c21c34f7612d5d230e01b4ad4c7"`, `"f0b1aa0eb660754448a7937c022e30aa692fe0c5"`, `"24c4d950dfd4dd1902bbed3508144a54542bba94"`, `"9f27daea7aca0aa0446220b98d028715e3bc803d"`, `"a5dc5acd6a7968a4554d89d65e59b7fd3bff0f90"`, `"d9aef3a1e38a39c16b31d1ace71bca8ef58d315b"`, `"63ed5a272de2f6d968408b4acb9024f4cc208ebf"`, `"6f6704e5a10332af6672e50b3d9754dc460dfa4d"`, `"77ca7b50b6cd7e2f3fa008e24ab793fd56cb15f6"`, `"492ea3bb0f3315521c31f273e565b868fc090f17"`, `"0ff30d6de14a8224aa97b78aea5388d1c51c1f00"`, `"9ea779f907f0b315b364b0cfc39a0fde5b02a416"`, `"ceaeb481747ca6c540a000c1f3641f8cef161fa7"`, `"cc34673c6c40e791051898567a1222daf90be287"`, `"579a80d909f346fbfb1189493f521d7f48d52238"`, `"e308bd1ac5fda103967359b2712dd89deffb7973"`, `"4cb31628079fb14e4bc3cd5e30c2f7489b00960c"`, `"ac1ecab32727358dba8962a0f3b261731aad9723"`, `"4fd6ace747f06ece9c49699c7cabc62d02211f75"`, `"440c59b325d2997a134c2c7c60a8c61611212bad"`, `"4486a3d68fac6967006d7a517b889fd3f98c102b"`, `"9c15b54878ba618f494b38f0ae7443db6af648ba"`, `"27b137a85656544b1ccb5a0f2e561a5703c6a68f"`, `"21c7fdb9ed8d291d79ffd82eb2c4356ec0d81241"`, `"23b75c2f6791eef49c69684db4c6c1f93bf49a50"`, `"1ca6abd14d30affe533b24d7a21bff4c2d5e1f3b"`, `"b9637156d330c0d605a791f1c31ba5890582fe1c"`, `"6131c42fa982e56929107413a9d526fd99405560"`, `"1591fc0f688c81fbeb17f5426a162a7024d430c2"`, `"542a9515200d14b68e934e9830d91645a980dd7a"`, `"c4bbd073882dd2add2424cf47d35213405b01324"`, `"782495b7b3355efb2833d56ecb34dc22ad7dfcc4"`, `"58b95c9a9d5d26825e70a82b6adb139d3fd829eb"`, `"3ba4d81db016dc2890c81f3acec2454bff5aada5"`, `"b52042c8ca3f8aa246fa79c3feaa3d959347c0ab"`, `"e4ae1efdfc53b73893af49113d8694a057b9c0d1"`, `"3c02a7bc0391e86d91b7d144e61c2c01a25a79c5"`, `"0737a6b837f97f46ebade41b9bc3e1c509c85c53"`, `"97f43a37f595ab5dd318fb46e7a155eae057317a"`, `"52c5317c848ba20c7504cb2c8052abd1fde29d03"`, `"4863226780fe7c0356454236d3b1c8792785748d"`, `"5d2b2e6fcbe3b11d26b525e085ff818dae332479"`, `"5f9f3392e9f62f63b8eac0beb55541fc8627f42c"`, `"057b56736d32b86616a10f619859c6cd6f59092a"`, `"9aa008f65de0b923a2a4f02012ad034a5e2e2192"`, `"304a554a310c7e546dfe434669c62820b7d83490"`, `"914d1b8b43e92723e64fd0a06f5bdb8dd9b10c79"`, `"4deb0033bb26bc534b197e61d19e0733e5679784"`, `"07f5c1e1bc2c93e0402f23341973a0e043f7bf8a"`, `"35a051a0010aba705c9008d7a7eff6fb88f6ea7b"`, `"4fa802324e929786dbda3b8820dc7834e9134a2a"`, `"9da397b9e80755301a3b32173283a91c0ef6c87e"`, `"8d9edb3054ce5c5774a420ac37ebae0ac02343c6"`, `"0101f3be8ebb4bbd39a2e3b9a3639d4259832fd9"`, `"5dc28b15dffed94048d73806ce4b7a4612a1d48f"`, `"bcf899e6c7d9d5a215ab1e3444c86806fa854c76"`, `"12e626b0eebfe86a56d633b9864e389b45dcb260"`, `"a2f1ccba9395d7fcb155bba8bc92db9bafaeade7"`, `"ec8e57756626fdc07c63ad2eafbd28d08e7b0ca5"`, `"d164b088bd9108b60d0ca3751da4bceb207b0782"`, `"6231b6d0d5e77fe001c2a460bd9584fee60d409b"`, `"1cba23d343a983e9b5cfd19496b9a9701ada385f"`, `"a82f360a8d3455c5c41366975bde739c37bfeb8a"`, `"9fcd2deaff372a39cc679d5c5e4de7bafb0b1339"`, `"005f5cee7a43331d5a3d3eec71305925a62f34b6"`, `"0e0da70933f4c7849fc0d203f5d1d43b9ae4532d"`, `"d131637d5275fd1a68a3200f4ad25c71a2a9522e"`, `"bc07118b9ac290e4622f5e77a0853539789effbe"`, `"47e7aa56d6bdf3f36be34619660de61275420af8"`, `"acd87e28b0c9d1254e868b81cba4cc20d9a32225"`, `"adf80daec7ba8dcf15392f1ac611fff65d94f880"`, `"5524c55fb03cf21f549444ccbecb664d0acad706"`, `"40b803a9abce16f50f36a77ba41180eb90023925"`, `"fe24cdd8648121a43a7c86d289be4dd2951ed49f"`, `"17802f43a0137c506ba92291391a8a8f207f487d"`, `"253488078a4edf4d6f42f113d1e62836a942cf1a"`, `"86af3e9626fce1957c82e88cbf04ddf3a2ed7915"`, `"b136707642a4ea12fb4bae820f03d2562ebff487"`, `"dbe9b615a3ae8709af8b93336ce9b477e4ac0940"`, `"f14c14075d6c4ed84b86798af0956deef67365b5"`, `"ca544e5c4687d109611d0f8f928b53a25af72448"`, `"aeeb8ff27288bdabc0fa5ebb731b6f409507516c"`, `"cbb9d3703e651b0d496cdefb8b92c25aeb2171f7"`, `"6d87578288b6cb5549d5076a207456a1f6a63dc0"`, `"b2c6f0dfbb716ac562e2d85d6cb2f8d5ee87603e"`, `"accc230e8a6e5be9160b8cdf2864dd2a001c28b6"`, `"2b3455ec7fedf16e646268bf88846bd7a2319bb2"`, `"4613f3bca5c44ea06337a9e439fbc6d42e501d0a"`, `"d343b217de44030afaa275f54d31a9317c7f441e"`, `"84ef4b2357079cd7a7c69fd7a37cd0609a679106"`, `"da2fef9e4a3230988ff17df2165440f37e8b1708"`, `"f4c64518ea10f995918a454158c6b61407ea345c"`, `"7602b46df5390e432ef1c307d4f2c9ff6d65cc97"`, `"bb9bc244d798123fde783fcc1c72d3bb8c189413"`, `"807640a13483f8ac783c557fcdf27be11ea4ac7a"`] + +### DAORefundContract + +> `readonly` **DAORefundContract**: `"bf4ed7b27f1d666546e30d74d50d173d20bca754"` + +## Defined in + +packages/vm/types/actions/DAOConfig.d.ts:1 diff --git a/tevm/docs/vm/variables/KECCAK256_NULL.md b/tevm/docs/vm/variables/KECCAK256_NULL.md new file mode 100644 index 0000000000..dfe49111de --- /dev/null +++ b/tevm/docs/vm/variables/KECCAK256_NULL.md @@ -0,0 +1,13 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / KECCAK256\_NULL + +# Variable: KECCAK256\_NULL + +> `const` **KECCAK256\_NULL**: `Uint8Array` + +## Defined in + +packages/vm/types/actions/constants.d.ts:1 diff --git a/tevm/docs/vm/variables/parentBeaconBlockRootAddress.md b/tevm/docs/vm/variables/parentBeaconBlockRootAddress.md new file mode 100644 index 0000000000..27290ba2b9 --- /dev/null +++ b/tevm/docs/vm/variables/parentBeaconBlockRootAddress.md @@ -0,0 +1,13 @@ +[**tevm**](../../README.md) • **Docs** + +*** + +[tevm](../../modules.md) / [vm](../README.md) / parentBeaconBlockRootAddress + +# Variable: parentBeaconBlockRootAddress + +> `const` **parentBeaconBlockRootAddress**: [`EthjsAddress`](../../utils/classes/EthjsAddress.md) + +## Defined in + +packages/vm/types/actions/parentBeaconBlockRootAddress.d.ts:2