-
Notifications
You must be signed in to change notification settings - Fork 756
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
pectra devnet4: implement pectra devnet4 spec #3706
Changes from 32 commits
bcb48d2
1c30c2a
73003e7
7cd91a2
b4c704b
420a7aa
1b65e0c
6d39f31
7d023c4
2998547
5d2ede2
5fe681b
613c900
9b5caf2
a62ed49
7e898d4
a5aa2db
3eafb13
638acc3
965eb86
2fea7ae
8b641de
dae997e
bef2f34
860c621
a6dde76
e7ba8b9
ee9a33d
239a63d
4f9ae46
f0b5acc
d7a33f8
676b93b
b1bae17
9d3652f
ea935e7
7e1c382
9d5822f
dc93f8f
9c64353
328cd53
c7f4640
a973b43
000839d
d91b666
84f40e3
d3e6cca
802145d
88eb200
adff539
46ec57d
5446fb8
152ae16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { createBlock, genRequestsTrieRoot } from '@ethereumjs/block' | ||
import { createBlock, genRequestsRoot } from '@ethereumjs/block' | ||
import { Common, Hardfork, Mainnet } from '@ethereumjs/common' | ||
import { | ||
type CLRequest, | ||
type CLRequestType, | ||
bytesToBigInt, | ||
createDepositRequest, | ||
CLRequestType, | ||
bytesToHex, | ||
createCLRequest, | ||
randomBytes, | ||
} from '@ethereumjs/util' | ||
import { sha256 } from 'ethereum-cryptography/sha256.js' | ||
|
||
const main = async () => { | ||
const common = new Common({ | ||
|
@@ -17,26 +18,29 @@ const main = async () => { | |
const depositRequestData = { | ||
pubkey: randomBytes(48), | ||
withdrawalCredentials: randomBytes(32), | ||
amount: bytesToBigInt(randomBytes(8)), | ||
amount: randomBytes(8), | ||
signature: randomBytes(96), | ||
index: bytesToBigInt(randomBytes(8)), | ||
index: randomBytes(8), | ||
} | ||
const request = createDepositRequest(depositRequestData) as CLRequest<CLRequestType> | ||
// flatten request bytes as per EIP-7685 | ||
const depositRequestBytes = new Uint8Array( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the deposit request example, this should now also be edited because it does not match the spec anymore. Deploy the deposit contract, and then in a Prague block perform a deposit. The request should now contain the related LOG of the deposit data. |
||
Object.values(depositRequestData) | ||
.map((arr) => Array.from(arr)) // Convert Uint8Arrays to regular arrays | ||
.reduce((acc, curr) => acc.concat(curr), []), // Concatenate arrays | ||
) | ||
const request = createCLRequest( | ||
new Uint8Array([CLRequestType.Deposit, ...depositRequestBytes]), | ||
) as CLRequest<CLRequestType.Deposit> | ||
const requests = [request] | ||
const requestsRoot = await genRequestsTrieRoot(requests) | ||
const requestsRoot = genRequestsRoot(requests, sha256) | ||
|
||
const block = createBlock( | ||
{ | ||
requests, | ||
header: { requestsRoot }, | ||
header: { requestsHash: requestsRoot }, | ||
}, | ||
{ common }, | ||
) | ||
console.log( | ||
`Instantiated block with ${ | ||
block.requests?.length | ||
} deposit request, requestTrieValid=${await block.requestsTrieIsValid()}`, | ||
) | ||
console.log(`Instantiated block ${block}, requestsHash=${bytesToHex(block.header.requestsHash!)}`) | ||
} | ||
|
||
void main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createBlock, genRequestsTrieRoot } from '@ethereumjs/block' | ||
import { createBlock, genRequestsRoot } from '@ethereumjs/block' | ||
import { Common, Hardfork, Mainnet } from '@ethereumjs/common' | ||
import { | ||
type CLRequest, | ||
|
@@ -7,6 +7,7 @@ import { | |
createWithdrawalRequest, | ||
randomBytes, | ||
} from '@ethereumjs/util' | ||
import { sha256 } from 'ethereum-cryptography/keccak.js' | ||
|
||
const main = async () => { | ||
const common = new Common({ | ||
|
@@ -21,7 +22,7 @@ const main = async () => { | |
} | ||
const request = createWithdrawalRequest(withdrawalRequestData) as CLRequest<CLRequestType> | ||
const requests = [request] | ||
const requestsRoot = await genRequestsTrieRoot(requests) | ||
const requestsRoot = genRequestsRoot(requests, sha256) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this example can be deleted. If we want a minimal example, then the steps are:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example can be found in |
||
const block = createBlock( | ||
{ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this example can be deleted. If we want a minimal example, then the steps are: Ensure the consolidations contract is deployed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs update, now uses
sha256
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the example and will push updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 7002 example in the block package fails still, but since ssz isn't supported, we would have to provide a very minimal example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SSZ support is a misunderstanding: we do not need to import SSZ. The contract (which generates those requests) internally LOGs the data SSZ-encoded (we can just read the log as opaque bytes and use that). We should update the example (I'll take a look what it does currently)