Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tx: Update eip4844 txs to decoupled blobs spec #2567

Merged
merged 35 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6ea9dba
`Buffer` to `Uint8Array` conversion (#2566)
acolytec3 Mar 27, 2023
d9c020c
Devp2p status fix
acolytec3 Mar 28, 2023
da78efe
Remove buffer detritus
acolytec3 Mar 29, 2023
71e3a3a
Switch db to view
acolytec3 Mar 29, 2023
f35554d
buffer cleanup
acolytec3 Mar 29, 2023
f16ebde
Correctly parse heads from DB
acolytec3 Mar 29, 2023
20f41b1
Fix encodings
acolytec3 Mar 29, 2023
61894c6
Cast db values to uint8array
acolytec3 Mar 29, 2023
b43ab51
Fix db bug in ethash
acolytec3 Mar 29, 2023
3e70fd7
Remove unused peerId check
acolytec3 Mar 30, 2023
047e916
Add pow miner test
acolytec3 Mar 31, 2023
9bcd6dc
Finish test
acolytec3 Mar 31, 2023
a23e6fa
Move pow test to integration tests
acolytec3 Mar 31, 2023
20d8d8c
client: lint
jochem-brouwer Mar 31, 2023
fdf8a79
rename test helper
acolytec3 Mar 31, 2023
cd6f431
Add timeout to PoW test
acolytec3 Mar 31, 2023
9ec318b
Merge remote-tracking branch 'origin/develop-v7' into devp2p-fixes
acolytec3 Apr 4, 2023
f157898
Update eip4844 txs to decoupled blobs spec
g11tech Mar 4, 2023
add6591
fix sharding spec and blobtx
g11tech Mar 7, 2023
b253353
fix the sharding muli client run
g11tech Mar 8, 2023
ea57e81
fix args
g11tech Mar 18, 2023
1f61178
fix compatibility with latest lodestar branch
g11tech Mar 18, 2023
1f8be03
update test help
g11tech Mar 25, 2023
622cef4
Fix fee market test
acolytec3 Mar 25, 2023
964a678
lint
acolytec3 Mar 25, 2023
4fd3a61
Move all kzg stuff to util
acolytec3 Mar 28, 2023
c464362
Various cleanup
acolytec3 Apr 3, 2023
ab85918
Merge remote-tracking branch 'origin/develop-v7' into g11tech/decoupl…
acolytec3 Apr 4, 2023
81bebd0
Update to latest c-kzg
acolytec3 Apr 4, 2023
25d43bb
Fix utils
acolytec3 Apr 4, 2023
a3c4871
Remove outdated kzg references
acolytec3 Apr 4, 2023
7bfe2e5
Fix client tests
acolytec3 Apr 4, 2023
2fb8d06
Update c-kzg dep
acolytec3 Apr 10, 2023
f26ad81
Fix karma, remove Buffer references
acolytec3 Apr 11, 2023
03fac27
Merge branch 'develop-v7' into g11tech/decoupled-blobs
acolytec3 Apr 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/block/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function (config) {
acornOptions: {
ecmaVersion: 12,
},
ignore: ['c-kzg'],
},
},
concurrency: 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@types/lru-cache": "^5.1.0",
"c-kzg": "^1.0.8"
"c-kzg": "^2.0.4"
},
"engines": {
"node": ">=14"
Expand Down
7 changes: 4 additions & 3 deletions packages/block/test/eip4844block.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { BlobEIP4844Transaction, initKZG } from '@ethereumjs/tx'
import { BlobEIP4844Transaction } from '@ethereumjs/tx'
import {
blobsToCommitments,
commitmentsToVersionedHashes,
getBlobs,
} from '@ethereumjs/tx/dist/utils/blobHelpers'
import { randomBytes } from '@ethereumjs/util'
initKZG,
randomBytes,
} from '@ethereumjs/util'
import * as kzg from 'c-kzg'
import * as tape from 'tape'

Expand Down
2 changes: 1 addition & 1 deletion packages/client/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Block } from '@ethereumjs/block'
import { Blockchain, parseGethGenesisState } from '@ethereumjs/blockchain'
import { Chain, Common, ConsensusAlgorithm, Hardfork } from '@ethereumjs/common'
import { RLP } from '@ethereumjs/rlp'
import { initKZG } from '@ethereumjs/tx'
import {
Address,
bytesToHex,
bytesToPrefixedHexString,
hexStringToBytes,
initKZG,
randomBytes,
short,
toBytes,
Expand Down
10 changes: 7 additions & 3 deletions packages/client/devnets/4844-interop/tools/txGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Adapted from - https://github.com/Inphi/eip4844-interop/blob/master/blob_tx_generator/blob.js
import { Common, Hardfork } from '@ethereumjs/common'
import { BlobEIP4844Transaction, initKZG } from '@ethereumjs/tx'
import { BlobEIP4844Transaction } from '@ethereumjs/tx'
import {
Address,
initKZG,
blobsToCommitments,
commitmentsToVersionedHashes,
getBlobs,
} from '@ethereumjs/tx/dist/utils/blobHelpers'
import { Address, bytesToPrefixedHexString, hexStringToBytes } from '@ethereumjs/util'
bytesToPrefixedHexString,
hexStringToBytes,
} from '@ethereumjs/util'

import * as kzg from 'c-kzg'
import { randomBytes } from '@ethereumjs/util'
import { Client } from 'jayson/promise'
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
"@ethereumjs/vm": "6.4.1",
"abstract-level": "^1.0.3",
"body-parser": "^1.19.2",
"c-kzg": "^2.0.4",
"chalk": "^4.1.2",
"connect": "^3.7.0",
"cors": "^2.8.5",
"c-kzg": "^1.0.8",
"debug": "^4.3.3",
"ethereum-cryptography": "^1.1.2",
"fs-extra": "^10.1.0",
Expand Down
20 changes: 8 additions & 12 deletions packages/client/test/miner/pendingBlock.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Block, BlockHeader } from '@ethereumjs/block'
import { Common, Chain as CommonChain, Hardfork } from '@ethereumjs/common'
import { BlobEIP4844Transaction, Transaction, initKZG } from '@ethereumjs/tx'
import {
blobsToCommitments,
commitmentsToVersionedHashes,
getBlobs,
} from '@ethereumjs/tx/dist/utils/blobHelpers'
import { BlobEIP4844Transaction, Transaction } from '@ethereumjs/tx'
import {
Account,
Address,
blobsToCommitments,
bytesToHex,
bytesToPrefixedHexString,
commitmentsToVersionedHashes,
equalsBytes,
getBlobs,
hexStringToBytes,
initKZG,
randomBytes,
} from '@ethereumjs/util'
import { VM } from '@ethereumjs/vm'
Expand Down Expand Up @@ -260,11 +259,9 @@ tape('[PendingBlock]', async (t) => {

t.test('construct blob bundles', async (st) => {
try {
kzg.freeTrustedSetup()
} catch {
/** ensure kzg is setup */
}
initKZG(kzg, __dirname + '/../../lib/trustedSetups/devnet4.txt')
initKZG(kzg, __dirname + '/../../lib/trustedSetups/devnet4.txt')
// eslint-disable-next-line
} catch {}
const gethGenesis = require('../../../block/test/testdata/4844-hardfork.json')
const common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
Expand Down Expand Up @@ -297,7 +294,6 @@ tape('[PendingBlock]', async (t) => {
await pendingBlock.build(payloadId)
const pendingBlob = pendingBlock.blobBundles.get(bytesToPrefixedHexString(payloadId))?.blobs[0]
st.ok(pendingBlob !== undefined && equalsBytes(pendingBlob, blobs[0]))
kzg.freeTrustedSetup()
st.end()
})
t.test('should reset td', (st) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/test/rpc/engine/getBlobsBundleV1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Hardfork } from '@ethereumjs/common'
import { DefaultStateManager } from '@ethereumjs/statemanager'
import { TransactionFactory, initKZG } from '@ethereumjs/tx'
import { Address, hexStringToBytes } from '@ethereumjs/util'
import { TransactionFactory } from '@ethereumjs/tx'
import { Address, hexStringToBytes, initKZG } from '@ethereumjs/util'
import * as kzg from 'c-kzg'
import * as tape from 'tape'

Expand Down
28 changes: 12 additions & 16 deletions packages/client/test/rpc/eth/sendRawTransaction.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { BlockHeader } from '@ethereumjs/block'
import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { DefaultStateManager } from '@ethereumjs/statemanager'
import {
BlobEIP4844Transaction,
FeeMarketEIP1559Transaction,
Transaction,
initKZG,
} from '@ethereumjs/tx'
import { BlobEIP4844Transaction, FeeMarketEIP1559Transaction, Transaction } from '@ethereumjs/tx'
import {
blobsToCommitments,
bytesToPrefixedHexString,
commitmentsToVersionedHashes,
getBlobs,
} from '@ethereumjs/tx/dist/utils/blobHelpers'
import { bytesToPrefixedHexString, hexStringToBytes, randomBytes } from '@ethereumjs/util'
hexStringToBytes,
initKZG,
randomBytes,
} from '@ethereumjs/util'
import * as kzg from 'c-kzg'
import * as tape from 'tape'

Expand Down Expand Up @@ -213,11 +211,9 @@ tape('blob EIP 4844 transaction', async (t) => {
const consensusFormatValidation = BlockHeader.prototype._consensusFormatValidation
BlockHeader.prototype._consensusFormatValidation = (): any => {}
try {
kzg.freeTrustedSetup()
} catch {
// NOOP - just verifying KZG is ready if not already
}
initKZG(kzg, __dirname + '/../../../lib/trustedSetups/devnet4.txt')
initKZG(kzg, __dirname + '/../../../lib/trustedSetups/devnet4.txt')
// eslint-disable-next-line
} catch {}
const gethGenesis = require('../../../../block/test/testdata/4844-hardfork.json')
const common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
Expand All @@ -232,14 +228,14 @@ tape('blob EIP 4844 transaction', async (t) => {
const blobs = getBlobs('hello world')
const commitments = blobsToCommitments(blobs)
const versionedHashes = commitmentsToVersionedHashes(commitments)
const proof = kzg.computeAggregateKzgProof(blobs.map((blob) => Uint8Array.from(blob)))
const proofs = blobs.map((blob, ctx) => kzg.computeBlobKzgProof(blob, commitments[ctx]))
const pk = randomBytes(32)
const tx = BlobEIP4844Transaction.fromTxData(
{
versionedHashes,
blobs,
kzgCommitments: commitments,
kzgProof: proof,
kzgProofs: proofs,
maxFeePerDataGas: 1000000n,
gasLimit: 0xffffn,
maxFeePerGas: 10000000n,
Expand All @@ -254,7 +250,7 @@ tape('blob EIP 4844 transaction', async (t) => {
versionedHashes,
blobs,
kzgCommitments: commitments,
kzgProof: proof,
kzgProofs: proofs,
maxFeePerDataGas: 1000000n,
gasLimit: 0xfffffn,
maxFeePerGas: 100000000n,
Expand Down
28 changes: 21 additions & 7 deletions packages/client/test/sim/4844.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,36 @@ Note: All commands should be run from the `client` package directory root (so so

## Running a local devnet

To run a single EthereumJS client <> Lodestar CL client for testing, run the following command:
`NETWORK=sharding EXTRA_CL_PARAMS="--params.CAPELLA_FORK_EPOCH 0 --params.EIP4844_FORK_EPOCH 0" LODE_IMAGE=g11tech/lodestar:4844-ae177e DATADIR=path/to/your/data/directory test/sim/./single-run.sh`
Step 1. To run a single EthereumJS client <> Lodestar CL client for testing, run the following command:
`NETWORK=sharding EXTRA_CL_PARAMS="--params.CAPELLA_FORK_EPOCH 0 --params.DENEB_FORK_EPOCH 0" LODE_IMAGE=g11tech/lodestar:decoupled DATADIR=path/to/your/data/directory test/sim/./single-run.sh`

To run a second EthereumJS <> Lodestar pair, use this command:
`MULTIPEER=syncpeer NETWORK=sharding EXTRA_CL_PARAMS="--params.CAPELLA_FORK_EPOCH 0 --params.EIP4844_FORK_EPOCH 0" LODE_IMAGE=g11tech/lodestar:4844-ae177e DATADIR=path/to/your/data/directory test/sim/./single-run.sh`
Step 2. (Optional) To run a second EthereumJS <> Lodestar pair, use this command:
`MULTIPEER=syncpeer NETWORK=sharding EXTRA_CL_PARAMS="--params.CAPELLA_FORK_EPOCH 0 --params.DENEB_FORK_EPOCH 0" LODE_IMAGE=g11tech/lodestar:decoupled DATADIR=path/to/your/data/directory test/sim/./single-run.sh`

To send a single blob transaction to the network, you can use the `txGenerator.ts` script as follows:
Step 3. To send a single blob transaction to the network, you may just run spec test:
`EXTERNAL_RUN=true npm run tape -- test/sim/sharding.spec.ts`

OR, you can use the `txGenerator.ts` script as follows:

`ts-node test/sim/txGenerator 8545 'hello'`. The first argument is the port number of the EthereumJS client you which to submit the transaction to and the second is any data to include in the blob.

This script was adapted from the [interop repo blob script](https://github.com/Inphi/eip4844-interop/blob/master/blob_tx_generator/blob.js)


## EIP-4844 spec tests

To run the 4844 spec tests contained in `test/sim/sharding.spec.ts`, use the following command:
You don't need to externally start the nodes, the sim tests will do all that for you as well as run the tests against it.

Run Step 1 & 3 together:

`LODE_IMAGE=g11tech/lodestar:decoupled DATADIR=path/to/your/data/directory npm run tape --
test/sim/sharding.spec.ts`


### Run Step 1, 2 & 3 together


`EXTRA_CL_PARAMS="--params.CAPELLA_FORK_EPOCH 0 --params.EIP4844_FORK_EPOCH 0" LODE_IMAGE=g11tech/lodestar:4844-ae177e DATADIR=/absolute/path/to/your/data/dir npm run tape -- test/sim/sharding.spec.ts`
`WITH_PEER=syncpeer LODE_IMAGE=g11tech/lodestar:decoupled DATADIR=path/to/your/data/directory npm run tape --
test/sim/sharding.spec.ts`

Note, these tests are adapted from the specification tests contained in the [EIP-4844 Interop repo](https://github.com/Inphi/eip4844-interop)
Loading