Skip to content

Commit

Permalink
Added EIP-4844 Headers for BlockHeaderOutput. Issue: 6933 (#6937)
Browse files Browse the repository at this point in the history
* Added EIP-4844 Headers for BlockHeaderOutput. getBlock() now references blockHeaderSchema instead of blockSchema.

* Updated blockSchema & blockHeaderSchema to reflect shared properties.

* Removed changes from yarn.lock.

* Removed author & excessDataGas from the BlockOutput interface.

* Separated old and new properties in the BlockOutput interface.

* Moved the Withdrawals interface above BlockOutput.
  • Loading branch information
ymonye committed Apr 15, 2024
1 parent 1c03666 commit 578ebb6
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 111 deletions.
175 changes: 101 additions & 74 deletions packages/web3-eth/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,46 +236,55 @@ export const transactionInfoSchema = {
},
};

export const blockSchema = {
export const withdrawalsSchema = {
type: 'object',
properties: {
parentHash: {
format: 'bytes32',
},
sha3Uncles: {
format: 'bytes32',
index: {
format: 'uint',
},
miner: {
format: 'bytes',
validatorIndex: {
format: 'uint',
},
stateRoot: {
format: 'bytes32',
address: {
format: 'address',
},
transactionsRoot: {
format: 'bytes32',
amount: {
format: 'uint',
},
receiptsRoot: {
format: 'bytes32',
},
};

export const blockSchema = {
type: 'object',
properties: {
baseFeePerGas: {
format: 'uint',
},
logsBloom: {
format: 'bytes256',
blobGasUsed: {
format: 'uint',
},
difficulty: {
format: 'uint',
},
number: {
excessBlobGas: {
format: 'uint',
},
extraData: {
format: 'bytes',
},
gasLimit: {
format: 'uint',
},
gasUsed: {
format: 'uint',
},
timestamp: {
format: 'uint',
hash: {
format: 'bytes32',
},
extraData: {
logsBloom: {
format: 'bytes256',
},
miner: {
format: 'bytes',
},
mixHash: {
Expand All @@ -284,15 +293,33 @@ export const blockSchema = {
nonce: {
format: 'uint',
},
totalDifficulty: {
number: {
format: 'uint',
},
baseFeePerGas: {
format: 'uint',
parentBeaconBlockRoot: {
format: 'bytes32',
},
parentHash: {
format: 'bytes32',
},
receiptsRoot: {
format: 'bytes32',
},
sha3Uncles: {
format: 'bytes32',
},
size: {
format: 'uint',
},
stateRoot: {
format: 'bytes32',
},
timestamp: {
format: 'uint',
},
totalDifficulty: {
format: 'uint',
},
transactions: {
oneOf: [
{
Expand All @@ -309,123 +336,123 @@ export const blockSchema = {
},
],
},
transactionsRoot: {
format: 'bytes32',
},
uncles: {
type: 'array',
items: {
format: 'bytes32',
},
},
hash: {
withdrawals: {
type: 'array',
items: {
...withdrawalsSchema,
},
},
withdrawalsRoot: {
format: 'bytes32',
},
},
};

export const withdrawalsSchema = {
export const blockHeaderSchema = {
type: 'object',
properties: {
index: {
format: 'uint',
author: {
format: 'bytes32',
},
validatorIndex: {
excessDataGas: {
format: 'uint',
},
address: {
format: 'address',
},
amount: {
baseFeePerGas: {
format: 'uint',
},
},
};

export const blockHeaderSchema = {
type: 'object',
properties: {
author: {
format: 'bytes32',
},
hash: {
format: 'bytes32',
blobGasUsed: {
format: 'uint',
},
parentHash: {
format: 'bytes32',
difficulty: {
format: 'uint',
},
receiptsRoot: {
format: 'bytes32',
excessBlobGas: {
format: 'uint',
},
miner: {
extraData: {
format: 'bytes',
},
stateRoot: {
format: 'bytes32',
gasLimit: {
format: 'uint',
},
transactionsRoot: {
format: 'bytes32',
gasUsed: {
format: 'uint',
},
withdrawalsRoot: {
hash: {
format: 'bytes32',
},
logsBloom: {
format: 'bytes256',
},
difficulty: {
format: 'uint',
},
totalDifficulty: {
format: 'uint',
miner: {
format: 'bytes',
},
number: {
format: 'uint',
mixHash: {
format: 'bytes32',
},
gasLimit: {
nonce: {
format: 'uint',
},
gasUsed: {
number: {
format: 'uint',
},
timestamp: {
format: 'uint',
parentBeaconBlockRoot: {
format: 'bytes32',
},
extraData: {
format: 'bytes',
parentHash: {
format: 'bytes32',
},
nonce: {
format: 'uint',
receiptsRoot: {
format: 'bytes32',
},
sha3Uncles: {
format: 'bytes32',
},
size: {
format: 'uint',
},
baseFeePerGas: {
format: 'uint',
stateRoot: {
format: 'bytes32',
},
excessDataGas: {
timestamp: {
format: 'uint',
},
mixHash: {
format: 'bytes32',
totalDifficulty: {
format: 'uint',
},
transactions: {
type: 'array',
items: {
format: 'bytes32',
},
},
transactionsRoot: {
format: 'bytes32',
},
uncles: {
type: 'array',
items: {
format: 'bytes32',
},
},
withdrawals: {
withdrawals: {
type: 'array',
items: {
...withdrawalsSchema,
},
},
withdrawalsRoot: {
format: 'bytes32',
},
},
};

Expand Down
92 changes: 56 additions & 36 deletions packages/web3-types/src/eth_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,16 @@ export interface BlockInput {
readonly baseFeePerGas?: HexString;
}

export interface Withdrawals {
readonly index: Numbers;
readonly validatorIndex: Numbers;
readonly address: Address;
readonly amount: Numbers;
}

export interface BlockOutput {
readonly gasLimit: bigint | number;
readonly gasUsed: bigint | number;
readonly gasLimit: bigint | number;
readonly gasUsed: bigint | number;
readonly size: bigint | number;
readonly timestamp: bigint | number;
readonly number?: bigint | number;
Expand All @@ -142,44 +149,57 @@ export interface BlockOutput {
readonly miner?: HexString;
readonly baseFeePerGas?: bigint | number;
readonly parentHash?: HexString32Bytes;
}

export interface Withdrawals {
readonly index: Numbers;
readonly validatorIndex: Numbers;
readonly address: Address;
readonly amount: Numbers;
// Added properties
readonly blobGasUsed?: bigint | number;
readonly excessBlobGas?: bigint | number;
readonly extraData?: Bytes;
readonly hash?: HexString32Bytes;
readonly logsBloom?: Bytes;
readonly nonce?: bigint | number;
readonly parentBeaconBlockRoot?: HexString32Bytes;
readonly receiptsRoot?: HexString32Bytes;
readonly sha3Uncles: HexString32Bytes[];
readonly stateRoot?: HexString32Bytes;
readonly transactionsRoot?: HexString32Bytes;
readonly withdrawalsRoot?: HexString32Bytes;
readonly mixHash?: HexString32Bytes;
readonly uncles?: Uncles;
readonly withdrawals?: Withdrawals[];
}

export interface BlockHeaderOutput {
readonly hash?: HexString32Bytes;
readonly parentHash?: HexString32Bytes;
readonly receiptsRoot?: HexString32Bytes;
readonly miner?: HexString;
readonly stateRoot?: HexString32Bytes;
readonly transactionsRoot?: HexString32Bytes;
readonly withdrawalsRoot?: HexString32Bytes;
readonly logsBloom?: Bytes;
readonly difficulty?: Numbers;
readonly number?: Numbers;
readonly gasLimit: Numbers;
readonly gasUsed: Numbers;
readonly timestamp: Numbers;
readonly extraData?: Bytes;
readonly nonce?: Numbers;
readonly sha3Uncles: HexString32Bytes[];
readonly baseFeePerGas?: Numbers;

// These fields are returned when the RPC client is Nethermind,
// but aren't available in other clients such as Geth
readonly author?: Address;
readonly totalDifficulty?: Numbers;
readonly size?: Numbers;
readonly excessDataGas?: Numbers;
readonly mixHash?: HexString32Bytes;
readonly transactions?: TransactionOutput[];
readonly uncles?: Uncles;
readonly withdrawals?: Withdrawals[];
readonly baseFeePerGas?: Numbers;
readonly blobGasUsed?: Numbers;
readonly difficulty?: Numbers;
readonly excessBlobGas?: Numbers;
readonly extraData?: Bytes;
readonly gasLimit: Numbers;
readonly gasUsed: Numbers;
readonly hash?: HexString32Bytes;
readonly logsBloom?: Bytes;
readonly miner?: HexString;
readonly nonce?: Numbers;
readonly number?: Numbers;
readonly parentBeaconBlockRoot?: HexString32Bytes;
readonly parentHash?: HexString32Bytes;
readonly receiptsRoot?: HexString32Bytes;
readonly sha3Uncles: HexString32Bytes[];
readonly stateRoot?: HexString32Bytes;
readonly timestamp: Numbers;
readonly transactionsRoot?: HexString32Bytes;
readonly withdrawalsRoot?: HexString32Bytes;

// These fields are returned when the RPC client is Nethermind,
// but aren't available in other clients such as Geth
readonly author?: Address;
readonly totalDifficulty?: Numbers;
readonly size?: Numbers;
readonly excessDataGas?: Numbers;
readonly mixHash?: HexString32Bytes;
readonly transactions?: TransactionOutput[];
readonly uncles?: Uncles;
readonly withdrawals?: Withdrawals[];
}

export interface ReceiptInput {
Expand Down
Loading

1 comment on commit 578ebb6

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 578ebb6 Previous: 6c075db Ratio
processingTx 9289 ops/sec (±3.54%) 9301 ops/sec (±4.81%) 1.00
processingContractDeploy 37132 ops/sec (±7.25%) 39129 ops/sec (±7.62%) 1.05
processingContractMethodSend 18837 ops/sec (±7.07%) 19443 ops/sec (±5.19%) 1.03
processingContractMethodCall 37187 ops/sec (±5.56%) 38971 ops/sec (±6.34%) 1.05
abiEncode 43087 ops/sec (±7.86%) 44252 ops/sec (±6.92%) 1.03
abiDecode 30251 ops/sec (±6.46%) 30419 ops/sec (±8.89%) 1.01
sign 1532 ops/sec (±4.35%) 1656 ops/sec (±4.08%) 1.08
verify 368 ops/sec (±0.42%) 373 ops/sec (±0.78%) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.