From bfa2da62c3bea27684eb2885cc22ceb822e54499 Mon Sep 17 00:00:00 2001 From: Jochem Brouwer Date: Mon, 12 Aug 2024 13:25:19 +0200 Subject: [PATCH] common/tx/vm: export access lists / authority lists from tx --- packages/common/src/interfaces.ts | 40 -------------------- packages/tx/src/types.ts | 61 +++++++++++++++++++++---------- packages/tx/src/util.ts | 3 +- packages/vm/src/runTx.ts | 4 +- 4 files changed, 46 insertions(+), 62 deletions(-) diff --git a/packages/common/src/interfaces.ts b/packages/common/src/interfaces.ts index 29c7b259df..a6b5967131 100644 --- a/packages/common/src/interfaces.ts +++ b/packages/common/src/interfaces.ts @@ -49,46 +49,6 @@ export type Proof = { storageProof: StorageProof[] } -/* - * Access List types - */ - -export type AccessListItem = { - address: PrefixedHexString - storageKeys: PrefixedHexString[] -} - -/* - * An Access List as a tuple of [address: Uint8Array, storageKeys: Uint8Array[]] - */ -export type AccessListBytesItem = [Uint8Array, Uint8Array[]] -export type AccessListBytes = AccessListBytesItem[] -export type AccessList = AccessListItem[] - -/** - * Authorization list types - */ -export type AuthorizationListItem = { - chainId: PrefixedHexString - address: PrefixedHexString - nonce: PrefixedHexString[] - yParity: PrefixedHexString - r: PrefixedHexString - s: PrefixedHexString -} - -// Tuple of [chain_id, address, [nonce], y_parity, r, s] -export type AuthorizationListBytesItem = [ - Uint8Array, - Uint8Array, - Uint8Array[], - Uint8Array, - Uint8Array, - Uint8Array, -] -export type AuthorizationListBytes = AuthorizationListBytesItem[] -export type AuthorizationList = AuthorizationListItem[] - /** * Verkle related * diff --git a/packages/tx/src/types.ts b/packages/tx/src/types.ts index 960fbc7719..348122124f 100644 --- a/packages/tx/src/types.ts +++ b/packages/tx/src/types.ts @@ -5,15 +5,7 @@ import type { AccessListEIP2930Transaction } from './2930/tx.js' import type { BlobEIP4844Transaction } from './4844/tx.js' import type { EOACodeEIP7702Transaction } from './7702/tx.js' import type { LegacyTransaction } from './legacy/tx.js' -import type { - AccessList, - AccessListBytes, - AuthorizationList, - AuthorizationListBytes, - Common, - Hardfork, - ParamsDict, -} from '@ethereumjs/common' +import type { Common, Hardfork, ParamsDict } from '@ethereumjs/common' import type { Address, AddressLike, @@ -21,17 +13,6 @@ import type { BytesLike, PrefixedHexString, } from '@ethereumjs/util' -export type { - AccessList, - AccessListBytes, - AccessListBytesItem, - AccessListItem, - AuthorizationList, - AuthorizationListBytes, - AuthorizationListBytesItem, - AuthorizationListItem, -} from '@ethereumjs/common' - /** * Can be used in conjunction with {@link Transaction[TransactionType].supports} * to query on tx capabilities @@ -596,3 +577,43 @@ export interface JsonRpcTx { blobVersionedHashes?: string[] // DATA - array of 32 byte versioned hashes for blob transactions yParity?: string // DATA - parity of the y-coordinate of the public key } + +/* + * Access List types + */ + +export type AccessListItem = { + address: PrefixedHexString + storageKeys: PrefixedHexString[] +} + +/* + * An Access List as a tuple of [address: Uint8Array, storageKeys: Uint8Array[]] + */ +export type AccessListBytesItem = [Uint8Array, Uint8Array[]] +export type AccessListBytes = AccessListBytesItem[] +export type AccessList = AccessListItem[] + +/** + * Authorization list types + */ +export type AuthorizationListItem = { + chainId: PrefixedHexString + address: PrefixedHexString + nonce: PrefixedHexString[] + yParity: PrefixedHexString + r: PrefixedHexString + s: PrefixedHexString +} + +// Tuple of [chain_id, address, [nonce], y_parity, r, s] +export type AuthorizationListBytesItem = [ + Uint8Array, + Uint8Array, + Uint8Array[], + Uint8Array, + Uint8Array, + Uint8Array, +] +export type AuthorizationListBytes = AuthorizationListBytesItem[] +export type AuthorizationList = AuthorizationListItem[] diff --git a/packages/tx/src/util.ts b/packages/tx/src/util.ts index 2079045428..591c0aa853 100644 --- a/packages/tx/src/util.ts +++ b/packages/tx/src/util.ts @@ -14,9 +14,10 @@ import type { AccessListItem, AuthorizationList, AuthorizationListBytes, + AuthorizationListItem, TransactionType, } from './types.js' -import type { AuthorizationListItem, Common } from '@ethereumjs/common' +import type { Common } from '@ethereumjs/common' export function checkMaxInitCodeSize(common: Common, length: number) { const maxInitCodeSize = common.param('maxInitCodeSize') diff --git a/packages/vm/src/runTx.ts b/packages/vm/src/runTx.ts index 8da4658a25..6832b64028 100644 --- a/packages/vm/src/runTx.ts +++ b/packages/vm/src/runTx.ts @@ -37,10 +37,12 @@ import type { } from './types.js' import type { VM } from './vm.js' import type { Block } from '@ethereumjs/block' -import type { AccessList, AccessListItem, Common } from '@ethereumjs/common' +import type { Common } from '@ethereumjs/common' import type { EVM } from '@ethereumjs/evm' import type { + AccessList, AccessListEIP2930Transaction, + AccessListItem, EIP7702CompatibleTx, FeeMarketEIP1559Transaction, LegacyTransaction,