Skip to content

Commit

Permalink
common/tx/vm: export access lists / authority lists from tx (#3577)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem-brouwer committed Aug 12, 2024
1 parent 6021203 commit e82ffec
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 62 deletions.
40 changes: 0 additions & 40 deletions packages/common/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
61 changes: 41 additions & 20 deletions packages/tx/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,14 @@ 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,
BigIntLike,
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
Expand Down Expand Up @@ -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[]
3 changes: 2 additions & 1 deletion packages/tx/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion packages/vm/src/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e82ffec

Please sign in to comment.