Skip to content

Commit d46b971

Browse files
authored
Merge branch 'master' into chore/upgrade-noble-2.0.1
2 parents f52c026 + 6d6a6ba commit d46b971

File tree

8 files changed

+150
-49
lines changed

8 files changed

+150
-49
lines changed

packages/block/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
| Implements schema and functions related to Ethereum blocks. |
1010
| ----------------------------------------------------------- |
1111

12-
- 🦄 All block features till **Pectra**
12+
- 🦄 All block features till **Osaka**
1313
- 🌴 Tree-shakeable API
1414
- 👷🏼 Controlled dependency set (4 external + `@noble` crypto)
1515
- 🔮 `EIP-4844` Shard Blob Txs
16+
- 🔮 `EIP-7594` PeerDAS Blob Transactions
1617
- 💸 `EIP-4895` Beacon Chain Withdrawals
1718
- 📨 `EIP-7685` Consensus Layer Requests
1819
- 🛵 324KB bundle size (81KB gzipped)

packages/client/test/net/peer/rlpxpeer.spec.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ import { Event } from '../../../src/types.ts'
77
describe('[RlpxPeer]', async () => {
88
vi.mock('@ethereumjs/devp2p', async () => {
99
const devp2p = await vi.importActual<any>('@ethereumjs/devp2p')
10-
const RLPx = vi.fn().mockImplementation(() => {
11-
return {
12-
events: new EventEmitter(),
13-
connect: vi.fn(),
10+
11+
// Create a proper constructor mock for RLPx
12+
class RLPxMock {
13+
events = new EventEmitter()
14+
connect = vi.fn()
15+
constructor() {
16+
// Constructor can be empty, properties are initialized above
1417
}
15-
})
18+
}
1619

1720
return {
1821
...devp2p,
19-
RLPx,
22+
RLPx: RLPxMock,
2023
}
2124
})
2225

packages/evm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| TypeScript implementation of the Ethereum EVM. |
1010
| ---------------------------------------------- |
1111

12-
- 🦄 All hardforks up to **Pectra**
12+
- 🦄 All hardforks up to **Osaka**
1313
- 🌴 Tree-shakeable API
1414
- 👷🏼 Controlled dependency set (7 external + `@Noble` crypto)
1515
- 🧩 Flexible EIP on/off engine

packages/evm/src/evm.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,11 @@ export class EVM implements EVMInterface {
499499
if (this.DEBUG) {
500500
debug(`Start bytecode processing...`)
501501
}
502-
result = await this.runInterpreter({ ...message, gasLimit } as Message)
502+
result = await this.runInterpreter({
503+
...{ codeAddress: message.codeAddress },
504+
...message,
505+
gasLimit,
506+
} as Message)
503507
}
504508

505509
if (message.depth === 0) {

packages/evm/test/asyncEvents.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
2-
import { Address, hexToBytes } from '@ethereumjs/util'
2+
import { Address, createAddressFromBigInt, hexToBytes } from '@ethereumjs/util'
33
import { assert, describe, it } from 'vitest'
44

55
import { createEVM } from '../src/index.ts'
@@ -11,18 +11,25 @@ describe('async events', () => {
1111
const evm = await createEVM({
1212
common,
1313
})
14+
const to = createAddressFromBigInt(BigInt(123456))
15+
await evm.stateManager.putCode(to, hexToBytes('0x6001'))
16+
let didTimeOut = false
1417
evm.events.on('step', async (event, next) => {
18+
assert.isTrue(event.codeAddress !== undefined)
1519
const startTime = Date.now()
1620
setTimeout(() => {
1721
assert.isTrue(Date.now() > startTime + 999, 'evm paused on step function for one second')
22+
didTimeOut = true
1823
next?.()
1924
}, 1000)
2025
})
2126
const runCallArgs = {
2227
caller, // call address
2328
gasLimit: BigInt(0xffffffffff),
2429
data: hexToBytes('0x600000'),
30+
to,
2531
}
2632
await evm.runCall(runCallArgs)
33+
assert.isTrue(didTimeOut)
2734
})
2835
})

packages/tx/README.md

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
| Implements schema and functions for the different Ethereum transaction types |
1010
| ---------------------------------------------------------------------------- |
1111

12-
- 🦄 All tx types up to **Pectra**
12+
- 🦄 All tx types up to **Osaka**
1313
- 🌴 Tree-shakeable API
1414
- 👷🏼 Controlled dependency set (1 external + `@Noble` crypto)
1515
- 🎼 Unified tx type API
1616
- 📲 New type for **EIP-7702** account abstraction
17+
- 🔮 `EIP-7594` PeerDAS Blob Transactions
1718
- 🛵 190KB bundle size (all tx types) (47KB gzipped)
1819
- 🏄🏾‍♂️ WASM-free default + Fully browser ready
1920

@@ -25,7 +26,7 @@
2526
- [Transaction Types](#transaction-types)
2627
- [Gas Fee Market Transactions (EIP-1559)](#gas-fee-market-transactions-eip-1559)
2728
- [Access List Transactions (EIP-2930)](#access-list-transactions-eip-2930)
28-
- [Blob Transactions (EIP-4844)](#blob-transactions-eip-4844)
29+
- [Blob Transactions (EIP-4844 / EIP-7594)](#blob-transactions-eip-4844--eip-7594)
2930
- [EOA Code Transaction (EIP-7702)](#eoa-code-transaction-eip-7702)
3031
- [Legacy Transactions](#legacy-transactions)
3132
- [Transaction Factory](#transaction-factory)
@@ -183,18 +184,25 @@ console.log(bytesToHex(tx.hash())) // 0x9150cdebad74e88b038e6c6b964d99af705f9c08
183184
For generating access lists from tx data based on a certain network state there is a `reportAccessList` option
184185
on the `VM.runTx()` method of the `@ethereumjs/vm` `TypeScript` VM implementation.
185186

186-
### Blob Transactions (EIP-4844)
187+
### Blob Transactions (EIP-4844 / EIP-7594)
187188

188189
- Class: `BlobEIP4844Tx`
189-
- EIP: [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844)
190-
- Activation: `cancun`
190+
- EIPs: [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844), [EIP-7594](https://eips.ethereum.org/EIPS/eip-7594)
191+
- Activation: `cancun` (EIP-4844), `osaka` (EIP-7594)
191192
- Type: `3`
192193

194+
#### Introduction
195+
193196
This library supports the blob transaction type introduced with [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844).
197+
Additionally it is able to process blobs in the "PeerDAS way" - introduced with [EIP-7594](https://eips.ethereum.org/EIPS/eip-7594) along the
198+
`osaka` hardfork and generate cell proofs instead of blob proofs.
194199

195200
**Note:** This functionality needs a manual KZG library installation and global initialization, see [KZG Setup](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx/README.md#kzg-setup) for instructions.
196201

197-
See the following code snippet for an example on how to instantiate:
202+
#### Example
203+
204+
See the following code snippet for an example on how to create a blob transaction, one for EIP-4844 only
205+
and one taking EIP-7594 into the mix:
198206

199207
```ts
200208
// ./examples/blobTx.ts
@@ -208,15 +216,46 @@ import { KZG as microEthKZG } from 'micro-eth-signer/kzg.js'
208216

209217
const main = async () => {
210218
const kzg = new microEthKZG(trustedSetup)
211-
const common = new Common({
219+
// EIP-4844 only
220+
const common4844 = new Common({
212221
chain: Mainnet,
213222
hardfork: Hardfork.Cancun,
214223
customCrypto: { kzg },
215224
})
216225

226+
// EIP-4844 and EIP-7594
227+
const common4844and7594 = new Common({
228+
chain: Mainnet,
229+
hardfork: Hardfork.Osaka,
230+
customCrypto: { kzg },
231+
})
232+
const setups = [
233+
{
234+
title: 'Blob transaction (EIP-4844 only)',
235+
common: common4844,
236+
proofAmountComment: 'one proof per blob'
237+
},
238+
{
239+
title: 'Blob transaction (EIP-4844 + EIP-7594)',
240+
common: common4844and7594,
241+
proofAmountComment: '128 cells per blob + one proof per cell -> NUM_BLOBS * 128 proofs'
242+
},
243+
]
244+
245+
for (const setup of setups) {
246+
console.log(`\n${setup.title}:`)
247+
console.log('---------------------------------------')
248+
249+
const blobsData = ['blob 1', 'blob 2', 'blob 3']
250+
console.log(`Blobs (Data) : "${blobsData.join('", "')}"`)
251+
// Final format, filled with a lot of 0s, added marker
252+
const blobs = getBlobs(blobsData)
253+
254+
console.log('Generating tx...')
255+
217256
const txData: BlobEIP4844TxData = {
218257
data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
219-
gasLimit: '0x02625a00',
258+
gasLimit: 16_000_000n,
220259
maxPriorityFeePerGas: '0x01',
221260
maxFeePerGas: '0xff',
222261
maxFeePerBlobGas: '0xfff',
@@ -229,18 +268,24 @@ const main = async () => {
229268
chainId: '0x01',
230269
accessList: [],
231270
type: '0x05',
232-
blobs: getBlobs(['blob 1', 'blob 2']),
271+
blobs,
233272
}
234273

235-
const tx = createBlob4844Tx(txData, { common })
274+
const tx = createBlob4844Tx(txData, { common: setup.common })
236275

237-
console.log(`Blob tx created with hash: ${bytesToHex(tx.hash())}`)
238-
console.log(`Tx contains ${tx.numBlobs()} blob`)
239-
console.log(`Blob versioned hashes: ${tx.blobVersionedHashes.join(', ')}`)
276+
console.log(`Tx hash : ${bytesToHex(tx.hash())}`)
277+
console.log(`Num blobs : ${tx.numBlobs()}`)
278+
console.log(`Blob versioned hashes : ${tx.blobVersionedHashes.join(', ')}`)
279+
console.log(`KZG commitments : ${tx.kzgCommitments!.join(', ')}`)
280+
console.log(`First KZG (cell) proof: ${tx.kzgProofs![0]}`)
281+
console.log(`Num KZG (cell) proofs : ${tx.kzgProofs!.length} (${setup.proofAmountComment})`)
282+
}
240283

241-
// To send a transaction via RPC, you can do something like this:
284+
// To send a transaction via RPC, you can something like this:
242285
// const rawTx = tx.sign(privateKeyBytes).serializeNetworkWrapper()
243286
// myRPCClient.request('eth_sendRawTransaction', [rawTx]) // submits a transaction via RPC
287+
//
288+
// Also see ./sendRawSepoliaTx.ts example
244289
}
245290

246291
void main()
@@ -249,15 +294,19 @@ void main()
249294

250295
**Note:** `versionedHashes` and `kzgCommitments` have a real length of 32 bytes, `blobs` have a real length of `4096` bytes and values are trimmed here for brevity.
251296

252-
You can either pass in blobs as the initial `blobsData` - and the final `blobs` format will be derived for you - or you can pass in the final `blobs` format directly as bytes. `versionedHashes`, `kzgCommitments` and `kzgProofs` are either derived or taken from the values passed in.
297+
You can either pass in blobs as the initial `blobsData` (the data you want to store in the blob) - and the final `blobs` format (filled with a lot of 0s, added marker) will be derived for you - or you can pass in the final `blobs` format directly as bytes. `versionedHashes`, `kzgCommitments` and `kzgProofs` are either derived or taken from the values passed in.
298+
299+
The `kzgProofs` field is used for both blob proofs (EIP-4844) and cell proofs (EIP-7594). Note that the amount of proofs increases by a factor of 128 when EIP-7594 is activated, since proofs are then computed per cell instead of per blob (128 cells per blob).
253300

254301
For manually deriving commitments, proofs and versioned hashes, there are dedicated helpers available in the [@ethereumjs/util](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/util) package.
255302

256303
#### Serialization
257304

258305
Blob transactions can be serialized in two ways.
259306
1) `tx.serialize()` - the standard serialization returns an RLP-encoded `Uint8Array` that conforms to the transaction as represented after it is included in a block
260-
2) `tx.serializeNetworkWrapper()` - this serialization format includes the `blobs` in the encoded data and is the format specified for transactions that are being submitted to/gossipped around the mempool. If you are constructing a transaction to submit via JSON-RPC, use this format.
307+
2) `tx.serializeNetworkWrapper()` - this serialization format includes the `blobs` in the encoded data and is the format specified for transactions that are being submitted to/gossipped around the mempool. **If you are constructing a transaction to submit via JSON-RPC, use this format.**
308+
309+
See the [Send Raw Sepolia Tx](./examples/sendRawSepoliaTx.ts) example for a detailed example on how to send a blob transaction via JSON-RPC.
261310

262311
See the [Blob Transaction Tests](./test/eip4844.spec.ts) for additional examples of usage in instantiating, serializing, and deserializing these transactions.
263312

packages/tx/examples/blobTx.ts

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,76 @@ import { KZG as microEthKZG } from 'micro-eth-signer/kzg.js'
77

88
const main = async () => {
99
const kzg = new microEthKZG(trustedSetup)
10-
const common = new Common({
10+
// EIP-4844 only
11+
const common4844 = new Common({
1112
chain: Mainnet,
1213
hardfork: Hardfork.Cancun,
1314
customCrypto: { kzg },
1415
})
1516

16-
const txData: BlobEIP4844TxData = {
17-
data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
18-
gasLimit: '0x02625a00',
19-
maxPriorityFeePerGas: '0x01',
20-
maxFeePerGas: '0xff',
21-
maxFeePerBlobGas: '0xfff',
22-
nonce: '0x00',
23-
to: '0xcccccccccccccccccccccccccccccccccccccccc',
24-
value: '0x0186a0',
25-
v: '0x01',
26-
r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',
27-
s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',
28-
chainId: '0x01',
29-
accessList: [],
30-
type: '0x05',
31-
blobs: getBlobs(['blob 1', 'blob 2']),
32-
}
17+
// EIP-4844 and EIP-7594
18+
const common4844and7594 = new Common({
19+
chain: Mainnet,
20+
hardfork: Hardfork.Osaka,
21+
customCrypto: { kzg },
22+
})
23+
const setups = [
24+
{
25+
title: 'Blob transaction (EIP-4844 only)',
26+
common: common4844,
27+
proofAmountComment: 'one proof per blob',
28+
},
29+
{
30+
title: 'Blob transaction (EIP-4844 + EIP-7594)',
31+
common: common4844and7594,
32+
proofAmountComment: '128 cells per blob + one proof per cell -> NUM_BLOBS * 128 proofs',
33+
},
34+
]
35+
36+
for (const setup of setups) {
37+
console.log(`\n${setup.title}:`)
38+
console.log('---------------------------------------')
3339

34-
const tx = createBlob4844Tx(txData, { common })
40+
const blobsData = ['blob 1', 'blob 2', 'blob 3']
41+
console.log(`Blobs (Data) : "${blobsData.join('", "')}"`)
42+
// Final format, filled with a lot of 0s, added marker
43+
const blobs = getBlobs(blobsData)
3544

36-
console.log(`Blob tx created with hash: ${bytesToHex(tx.hash())}`)
37-
console.log(`Tx contains ${tx.numBlobs()} blob`)
38-
console.log(`Blob versioned hashes: ${tx.blobVersionedHashes.join(', ')}`)
45+
console.log('Generating tx...')
46+
47+
const txData: BlobEIP4844TxData = {
48+
data: '0x1a8451e600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
49+
gasLimit: 16_000_000n,
50+
maxPriorityFeePerGas: '0x01',
51+
maxFeePerGas: '0xff',
52+
maxFeePerBlobGas: '0xfff',
53+
nonce: '0x00',
54+
to: '0xcccccccccccccccccccccccccccccccccccccccc',
55+
value: '0x0186a0',
56+
v: '0x01',
57+
r: '0xafb6e247b1c490e284053c87ab5f6b59e219d51f743f7a4d83e400782bc7e4b9',
58+
s: '0x479a268e0e0acd4de3f1e28e4fac2a6b32a4195e8dfa9d19147abe8807aa6f64',
59+
chainId: '0x01',
60+
accessList: [],
61+
type: '0x05',
62+
blobs,
63+
}
64+
65+
const tx = createBlob4844Tx(txData, { common: setup.common })
66+
67+
console.log(`Tx hash : ${bytesToHex(tx.hash())}`)
68+
console.log(`Num blobs : ${tx.numBlobs()}`)
69+
console.log(`Blob versioned hashes : ${tx.blobVersionedHashes.join(', ')}`)
70+
console.log(`KZG commitments : ${tx.kzgCommitments!.join(', ')}`)
71+
console.log(`First KZG (cell) proof: ${tx.kzgProofs![0]}`)
72+
console.log(`Num KZG (cell) proofs : ${tx.kzgProofs!.length} (${setup.proofAmountComment})`)
73+
}
3974

4075
// To send a transaction via RPC, you can something like this:
4176
// const rawTx = tx.sign(privateKeyBytes).serializeNetworkWrapper()
4277
// myRPCClient.request('eth_sendRawTransaction', [rawTx]) // submits a transaction via RPC
78+
//
79+
// Also see ./sendRawSepoliaTx.ts example
4380
}
4481

4582
void main()

packages/vm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Ethereum `mainnet` compatible execution context for
1313
[@ethereumjs/evm](https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/evm)
1414
to build and run blocks and txs and update state.
1515

16-
- 🦄 All hardforks up till **Pectra**
16+
- 🦄 All hardforks up till **Osaka**
1717
- 🌴 Tree-shakeable API
1818
- 👷🏼 Controlled dependency set (7 external + `@Noble` crypto)
1919
- 🧩 Flexible EIP on/off engine

0 commit comments

Comments
 (0)