@ethereumjs/block v5.3.0
Blocks with EIP-7685 Consensus Layer Requests
Starting with this release this library supports requests to the consensus layer (see PRs #3372 and #3393) which have been introduced with EIP-7685 and will come into play for deposit and withdrawal requests along the upcoming Prague hardfork.
EIP-6110 Deposit Requests
EIP-6110 introduces deposit requests allowing beacon chain deposits being triggered from the execution layer, see PRs #3390 and #3397. Starting with this release this library supports deposit requests and a containing block can be instantiated as follows:
import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { Block } from '@ethereumjs/block'
import {
bytesToBigInt,
DepositRequest,
randomBytes,
type CLRequest,
type CLRequestType,
} from '@ethereumjs/util'
const main = async () => {
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Prague,
})
const depositRequestData = {
pubkey: randomBytes(48),
withdrawalCredentials: randomBytes(32),
amount: bytesToBigInt(randomBytes(8)),
signature: randomBytes(96),
index: bytesToBigInt(randomBytes(8)),
}
const request = DepositRequest.fromRequestData(depositRequestData) as CLRequest<CLRequestType>
const requests = [request]
const requestsRoot = await Block.genRequestsTrieRoot(requests)
const block = Block.fromBlockData(
{
requests,
header: { requestsRoot },
},
{ common }
)
console.log(
`Instantiated block with ${
block.requests?.length
} request, requestTrieValid=${await block.requestsTrieIsValid()}`
)
}
main()
Have a look at the EIP for some guidance on how to use and fill in the various deposit request parameters.
EIP-7002 Withdrawal Requests
EIP-7002 introduces the possibility for validators to trigger exits and partial withdrawals via the execution layer, see PR #3385. Starting with this release this library supports withdrawal requests and a containing block can be instantiated as follows:
import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { Block } from '@ethereumjs/block'
import {
bytesToBigInt,
randomBytes,
WithdrawalRequest,
type CLRequest,
type CLRequestType,
} from '@ethereumjs/util'
const main = async () => {
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Prague,
})
const withdrawalRequestData = {
sourceAddress: randomBytes(20),
validatorPubkey: randomBytes(48),
amount: bytesToBigInt(randomBytes(8)),
}
const request = WithdrawalRequest.fromRequestData(
withdrawalRequestData
) as CLRequest<CLRequestType>
const requests = [request]
const requestsRoot = await Block.genRequestsTrieRoot(requests)
const block = Block.fromBlockData(
{
requests,
header: { requestsRoot },
},
{ common }
)
console.log(
`Instantiated block with ${
block.requests?.length
} withdrawal request, requestTrieValid=${await block.requestsTrieIsValid()}`
)
}
main()
Have a look at the EIP for some guidance on how to use and fill in the various withdrawal request parameters.
EIP-7251 Consolidation Requests
EIP-7251 introduces consolidation requests allowing staked ETH from more than one validator on the beacon chain to be consolidated into one validator, triggered from the execution layer, see PR #3477. Starting with this release this library supports consolidation requests and a containing block can be instantiated as follows:
// ./examples/7251Requests.ts
import { Chain, Common, Hardfork } from '@ethereumjs/common'
import { Block } from '@ethereumjs/block'
import {
bytesToBigInt,
ConsolidationRequest,
randomBytes,
type CLRequest,
type CLRequestType,
} from '@ethereumjs/util'
const main = async () => {
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Prague,
})
const consolidationRequestData = {
sourceAddress: randomBytes(20),
sourcePubkey: randomBytes(48),
targetPubkey: randomBytes(48),
}
const request = ConsolidationRequest.fromRequestData(
consolidationRequestData
) as CLRequest<CLRequestType>
const requests = [request]
const requestsRoot = await Block.genRequestsTrieRoot(requests)
const block = Block.fromBlockData(
{
requests,
header: { requestsRoot },
},
{ common }
)
console.log(
`Instantiated block with ${
block.requests?.length
} consolidation request, requestTrieValid=${await block.requestsTrieIsValid()}`
)
}
main()
Have a look at the EIP for some guidance on how to use and fill in the various deposit request parameters.
Verkle Updates
- Fixes for Kaustinen4 support, PR #3269
- Update
kzg-wasm
to0.4.0
, PR #3358 - Shift Verkle to
osaka
hardfork, PR #3371 - Fix the block body parsing as well as save/load from blockchain, PR #3392
- Verkle type/interface refactoring (moved to Common package), PR #3462
Other Features
- New
Block.toExecutionPayload()
method to map to the execution payload structure from the beacon chain, PR #3269 - Stricter prefixed hex typing, PRs #3348, #3427 and #3357 (some changes removed in PR #3382 for backwards compatibility reasons, will be reintroduced along upcoming breaking releases)