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

Added EIP-4844 Headers for BlockHeaderOutput. Issue: 6933 #6937

Merged
merged 6 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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: {
Copy link
Contributor

Choose a reason for hiding this comment

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

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',
},
Comment on lines +299 to +322
Copy link
Contributor

Choose a reason for hiding this comment

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

these fields are already in current schema but this PR is only rearranging these to diff lines.

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[];
Comment on lines +172 to +202
Copy link
Contributor

Choose a reason for hiding this comment

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

this is also rearranging most of field except adding ( eip 4844, 4895, 4788 )s

}

export interface ReceiptInput {
Expand Down
Loading
Loading