diff --git a/eth/new_heads.go b/eth/new_heads.go index e53edd5..4ba2f74 100644 --- a/eth/new_heads.go +++ b/eth/new_heads.go @@ -40,6 +40,13 @@ type NewHeadsResult struct { // EIP-4895 Withdrawals WithdrawalsRoot *Data32 `json:"withdrawalsRoot,omitempty"` + // EIP-4788 Beacon Block Root + ParentBeaconBlockRoot *Hash `json:"parentBeaconBlockRoot,omitempty"` + + // EIP-4844 Blob related block fields + ExcessBlobGas *Quantity `json:"excessBlobGas,omitempty"` + BlobGasUsed *Quantity `json:"blobGasUsed,omitempty"` + // Ethhash POW Fields Nonce *Data8 `json:"nonce"` MixHash *Data `json:"mixHash"` @@ -89,6 +96,13 @@ func (nh *NewHeadsResult) FromBlock(block *Block) { // EIP-4895 Withdrawals WithdrawalsRoot: block.WithdrawalsRoot, + // EIP-4788 Beacon Block Root + ParentBeaconBlockRoot: block.ParentBeaconBlockRoot, + + // EIP-4844 Blob related block fields + ExcessBlobGas: block.ExcessBlobGas, + BlobGasUsed: block.BlobGasUsed, + flavor: block.flavor, } @@ -159,6 +173,13 @@ func (nh NewHeadsResult) MarshalJSON() ([]byte, error) { // EIP-4895 Withdrawals WithdrawalsRoot *Data32 `json:"withdrawalsRoot,omitempty"` + // EIP-4788 Beacon Block Root + ParentBeaconBlockRoot *Hash `json:"parentBeaconBlockRoot,omitempty"` + + // EIP-4844 Blob related block fields + ExcessBlobGas *Quantity `json:"excessBlobGas,omitempty"` + BlobGasUsed *Quantity `json:"blobGasUsed,omitempty"` + Nonce *Data8 `json:"nonce"` MixHash *Data `json:"mixHash"` } @@ -180,10 +201,13 @@ func (nh NewHeadsResult) MarshalJSON() ([]byte, error) { GasUsed: nh.GasUsed, Timestamp: nh.Timestamp, // Transactions: nh.Transactions, - BaseFeePerGas: nh.BaseFeePerGas, - WithdrawalsRoot: nh.WithdrawalsRoot, - Nonce: nh.Nonce, - MixHash: nh.MixHash, + BaseFeePerGas: nh.BaseFeePerGas, + WithdrawalsRoot: nh.WithdrawalsRoot, + ParentBeaconBlockRoot: nh.ParentBeaconBlockRoot, + ExcessBlobGas: nh.ExcessBlobGas, + BlobGasUsed: nh.BlobGasUsed, + Nonce: nh.Nonce, + MixHash: nh.MixHash, } return json.Marshal(&g) diff --git a/eth/new_heads_test.go b/eth/new_heads_test.go index cb75675..96df557 100644 --- a/eth/new_heads_test.go +++ b/eth/new_heads_test.go @@ -103,6 +103,11 @@ func TestNewHeadsResult_FromBlock(t *testing.T) { // NOTE: parity actually appears to return wrong-looking size and sealFields in newHeads results. This payload has been patched to correct values. Expected: `{"baseFeePerGas":"0x7", "difficulty":"0x2", "extraData":"0x00000000000000000000000000000000000000000000000000000000000000009d3524c9acd91e52c9636eff76173d1de58419611da303ee131bc4dae18ecba17a01174694cce18611bbd691b24f171d5a68ae208e43f792b105fdaf950963af00", "gasLimit":"0x1c9c380", "gasUsed":"0xcf1f", "hash":"0xe47daeae74c521fc4a8e7fece9820bcb68a1d83382ef06700e67caba4245ef47", "logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner":"0x0000000000000000000000000000000000000000", "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000", "nonce":"0x0000000000000000", "number":"0x8496", "parentHash":"0xd8c32ba3341e8a239c41390fd68fd51a76ded9a4cc0260918acc1a54e0f3315d", "receiptsRoot":"0x340f7266a1624ed1d28caeed494df579e00e1e2355587d256c333b7f80ab1756", "sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "stateRoot":"0x93bfec7c3496021d3ff4674ad96ffe856e1f3cf1fed59770756ab4a074d0e535", "timestamp":"0x60ab38f3", "transactionsRoot":"0x658830e11eab0d07fd04dfe524711e509111ad0b543bb310296cb67a638445e4"}`, }, + { + Source: "https://rpc.dencun-devnet-8.ethpandaops.io/", + Block: `{"baseFeePerGas":"0x7","blobGasUsed":"0x60000","difficulty":"0x0","excessBlobGas":"0x200000","extraData":"0xd883010d00846765746888676f312e32312e30856c696e7578","gasLimit":"0x1c9c380","gasUsed":"0xf618","hash":"0x430ab7f664886887ba62dcaa5cf83d8e44b1bf0ad4a576410dbc84a109f95dbf","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0xf97e180c050e5ab072211ad2c213eb5aee4df134","mixHash":"0x050fa496047dbdcb8de6b0a64974637fb120f390f4bebf73acec5d01844185ab","nonce":"0x0000000000000000","number":"0x393f0","parentBeaconBlockRoot":"0x1951d53e036e0961e9785ef881d922f633fc52645eca81a5528da5e64db947d4","parentHash":"0x71c731f4fa13cc5a9ae3ae4f20420298f00629f06db252944995bd46d2121a91","receiptsRoot":"0x9af165447e5b3193e9ac8389418648ee6d6cb1d37459fe65cfc245fc358721bd","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","size":"0x449","stateRoot":"0x438bba4641dd03719086b83db167fe8dd2d1eedda588fb69316a905e66a2727a","timestamp":"0x650db730","totalDifficulty":"0x1","transactions":["0x8af966d5c3c566d7587851e71cf3d7392fe3eda960bd6d2b8cbf0e75c7cbeaff","0x976f8d3d95ee6a8ece7d4ba6c84db6a026873d7923dba95700688996fdf451ee","0xbd35e3daf31c3f71721b3b7ec5f8e25b0be50ad442095477017e98f93d6eaf0b"],"transactionsRoot":"0x1b01eb935388e62c3abcb75c4fd63f95b669fb1e5777eb54483e062fea55c71e","uncles":[],"withdrawals":[],"withdrawalsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"}`, + Expected: `{"baseFeePerGas":"0x7","blobGasUsed":"0x60000","difficulty":"0x0","excessBlobGas":"0x200000","extraData":"0xd883010d00846765746888676f312e32312e30856c696e7578","gasLimit":"0x1c9c380","gasUsed":"0xf618","hash":"0x430ab7f664886887ba62dcaa5cf83d8e44b1bf0ad4a576410dbc84a109f95dbf","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0xf97e180c050e5ab072211ad2c213eb5aee4df134","mixHash":"0x050fa496047dbdcb8de6b0a64974637fb120f390f4bebf73acec5d01844185ab","nonce":"0x0000000000000000","number":"0x393f0","parentBeaconBlockRoot":"0x1951d53e036e0961e9785ef881d922f633fc52645eca81a5528da5e64db947d4","parentHash":"0x71c731f4fa13cc5a9ae3ae4f20420298f00629f06db252944995bd46d2121a91","receiptsRoot":"0x9af165447e5b3193e9ac8389418648ee6d6cb1d37459fe65cfc245fc358721bd","sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347","stateRoot":"0x438bba4641dd03719086b83db167fe8dd2d1eedda588fb69316a905e66a2727a","timestamp":"0x650db730","transactionsRoot":"0x1b01eb935388e62c3abcb75c4fd63f95b669fb1e5777eb54483e062fea55c71e","withdrawalsRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"}`, + }, } { block := eth.Block{} err := json.Unmarshal([]byte(testCase.Block), &block)