From 74311235720da7550d90918ac65a5a454398e5e5 Mon Sep 17 00:00:00 2001 From: ocnc Date: Wed, 10 Jul 2024 16:47:20 -0400 Subject: [PATCH 1/6] bet --- mod/consensus-types/pkg/types/block.go | 55 ++----------- mod/consensus-types/pkg/types/block.ssz.go | 34 ++++---- mod/consensus-types/pkg/types/block_deneb.go | 77 +++++++++++++++++++ .../pkg/types/block_denebplus.go | 77 +++++++++++++++++++ mod/consensus-types/pkg/types/body.go | 6 -- mod/consensus-types/pkg/types/body_deneb.go | 5 ++ .../pkg/types/body_deneb.ssz.go | 2 +- .../pkg/types/body_denebplus.go | 5 ++ .../pkg/types/body_denebplus.ssz.go | 2 +- mod/consensus-types/pkg/types/deposit.ssz.go | 2 +- mod/consensus-types/pkg/types/payload.ssz.go | 2 +- .../pkg/engine-primitives/withdrawal.ssz.go | 2 +- mod/primitives/pkg/version/version.go | 1 + 13 files changed, 192 insertions(+), 78 deletions(-) create mode 100644 mod/consensus-types/pkg/types/block_deneb.go create mode 100644 mod/consensus-types/pkg/types/block_denebplus.go diff --git a/mod/consensus-types/pkg/types/block.go b/mod/consensus-types/pkg/types/block.go index 3b9631a6aa..63fef32f88 100644 --- a/mod/consensus-types/pkg/types/block.go +++ b/mod/consensus-types/pkg/types/block.go @@ -67,6 +67,11 @@ func (w *BeaconBlock) NewWithVersion( BeaconBlockHeaderBase: base, Body: &BeaconBlockBodyDeneb{}, } + case version.DenebPlus: + block = &BeaconBlockDenebPlus{ + BeaconBlockHeaderBase: base, + Body: &BeaconBlockBodyDenebPlus{}, + } default: return &BeaconBlock{}, ErrForkVersionNotSupported } @@ -101,53 +106,3 @@ func (w *BeaconBlock) IsNil() bool { w.RawBeaconBlock == nil || w.RawBeaconBlock.IsNil() } - -// BeaconBlockDeneb represents a block in the beacon chain during -// the Deneb fork. -// -//go:generate go run github.com/ferranbt/fastssz/sszgen --path block.go -objs BeaconBlockDeneb -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_deneb.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block.ssz.go -type BeaconBlockDeneb struct { - // BeaconBlockHeaderBase is the base of the BeaconBlockDeneb. - BeaconBlockHeaderBase - // Body is the body of the BeaconBlockDeneb, containing the block's - // operations. - Body *BeaconBlockBodyDeneb -} - -// Version identifies the version of the BeaconBlockDeneb. -func (b *BeaconBlockDeneb) Version() uint32 { - return version.Deneb -} - -// IsNil checks if the BeaconBlockDeneb instance is nil. -func (b *BeaconBlockDeneb) IsNil() bool { - return b == nil -} - -// SetStateRoot sets the state root of the BeaconBlockDeneb. -func (b *BeaconBlockDeneb) SetStateRoot(root common.Root) { - b.StateRoot = root -} - -// GetBody retrieves the body of the BeaconBlockDeneb. -func (b *BeaconBlockDeneb) GetBody() *BeaconBlockBody { - return &BeaconBlockBody{RawBeaconBlockBody: b.Body} -} - -// GetHeader builds a BeaconBlockHeader from the BeaconBlockDeneb. -func (b BeaconBlockDeneb) GetHeader() *BeaconBlockHeader { - bodyRoot, err := b.GetBody().HashTreeRoot() - if err != nil { - return nil - } - - return &BeaconBlockHeader{ - BeaconBlockHeaderBase: BeaconBlockHeaderBase{ - Slot: b.Slot, - ProposerIndex: b.ProposerIndex, - ParentBlockRoot: b.ParentBlockRoot, - StateRoot: b.StateRoot, - }, - BodyRoot: bodyRoot, - } -} diff --git a/mod/consensus-types/pkg/types/block.ssz.go b/mod/consensus-types/pkg/types/block.ssz.go index a9e83195ff..8d5daaa06d 100644 --- a/mod/consensus-types/pkg/types/block.ssz.go +++ b/mod/consensus-types/pkg/types/block.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 18135b8b18a7f0dda54e385bd75eea0c9c6a48c41870cdda0deee044baacaa97 +// Hash: 6401129c77820a513c17f214ef2269681bf668f0c24021219d7ed4ec60dd204c // Version: 0.1.3 package types @@ -7,13 +7,13 @@ import ( ssz "github.com/ferranbt/fastssz" ) -// MarshalSSZ ssz marshals the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) MarshalSSZ() ([]byte, error) { +// MarshalSSZ ssz marshals the BeaconBlockDenebPlus object +func (b *BeaconBlockDenebPlus) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(b) } -// MarshalSSZTo ssz marshals the BeaconBlockDeneb object to a target array -func (b *BeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { +// MarshalSSZTo ssz marshals the BeaconBlockDenebPlus object to a target array +func (b *BeaconBlockDenebPlus) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf offset := int(84) @@ -40,8 +40,8 @@ func (b *BeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { return } -// UnmarshalSSZ ssz unmarshals the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { +// UnmarshalSSZ ssz unmarshals the BeaconBlockDenebPlus object +func (b *BeaconBlockDenebPlus) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) if size < 84 { @@ -76,7 +76,7 @@ func (b *BeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { { buf = tail[o4:] if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) + b.Body = new(BeaconBlockBodyDenebPlus) } if err = b.Body.UnmarshalSSZ(buf); err != nil { return err @@ -85,26 +85,26 @@ func (b *BeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { return err } -// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) SizeSSZ() (size int) { +// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockDenebPlus object +func (b *BeaconBlockDenebPlus) SizeSSZ() (size int) { size = 84 // Field (4) 'Body' if b.Body == nil { - b.Body = new(BeaconBlockBodyDeneb) + b.Body = new(BeaconBlockBodyDenebPlus) } size += b.Body.SizeSSZ() return } -// HashTreeRoot ssz hashes the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { +// HashTreeRoot ssz hashes the BeaconBlockDenebPlus object +func (b *BeaconBlockDenebPlus) HashTreeRoot() ([32]byte, error) { return ssz.HashWithDefaultHasher(b) } -// HashTreeRootWith ssz hashes the BeaconBlockDeneb object with a hasher -func (b *BeaconBlockDeneb) HashTreeRootWith(hh ssz.HashWalker) (err error) { +// HashTreeRootWith ssz hashes the BeaconBlockDenebPlus object with a hasher +func (b *BeaconBlockDenebPlus) HashTreeRootWith(hh ssz.HashWalker) (err error) { indx := hh.Index() // Field (0) 'Slot' @@ -128,7 +128,7 @@ func (b *BeaconBlockDeneb) HashTreeRootWith(hh ssz.HashWalker) (err error) { return } -// GetTree ssz hashes the BeaconBlockDeneb object -func (b *BeaconBlockDeneb) GetTree() (*ssz.Node, error) { +// GetTree ssz hashes the BeaconBlockDenebPlus object +func (b *BeaconBlockDenebPlus) GetTree() (*ssz.Node, error) { return ssz.ProofTree(b) } diff --git a/mod/consensus-types/pkg/types/block_deneb.go b/mod/consensus-types/pkg/types/block_deneb.go new file mode 100644 index 0000000000..07c46aa24f --- /dev/null +++ b/mod/consensus-types/pkg/types/block_deneb.go @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +//nolint:dupl // it's okay to duplicate code for different types +package types + +import ( + "github.com/berachain/beacon-kit/mod/primitives/pkg/common" + "github.com/berachain/beacon-kit/mod/primitives/pkg/version" +) + +// BeaconBlockDeneb represents a block in the beacon chain during +// the Deneb fork. +// +//go:generate go run github.com/ferranbt/fastssz/sszgen --path block_deneb.go -objs BeaconBlockDeneb -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_deneb.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block.ssz.go +type BeaconBlockDeneb struct { + // BeaconBlockHeaderBase is the base of the BeaconBlockDeneb. + BeaconBlockHeaderBase + // Body is the body of the BeaconBlockDeneb, containing the block's + // operations. + Body *BeaconBlockBodyDeneb +} + +// Version identifies the version of the BeaconBlockDeneb. +func (b *BeaconBlockDeneb) Version() uint32 { + return version.Deneb +} + +// IsNil checks if the BeaconBlockDeneb instance is nil. +func (b *BeaconBlockDeneb) IsNil() bool { + return b == nil +} + +// SetStateRoot sets the state root of the BeaconBlockDeneb. +func (b *BeaconBlockDeneb) SetStateRoot(root common.Root) { + b.StateRoot = root +} + +// GetBody retrieves the body of the BeaconBlockDeneb. +func (b *BeaconBlockDeneb) GetBody() *BeaconBlockBody { + return &BeaconBlockBody{RawBeaconBlockBody: b.Body} +} + +// GetHeader builds a BeaconBlockHeader from the BeaconBlockDeneb. +func (b BeaconBlockDeneb) GetHeader() *BeaconBlockHeader { + bodyRoot, err := b.GetBody().HashTreeRoot() + if err != nil { + return nil + } + + return &BeaconBlockHeader{ + BeaconBlockHeaderBase: BeaconBlockHeaderBase{ + Slot: b.Slot, + ProposerIndex: b.ProposerIndex, + ParentBlockRoot: b.ParentBlockRoot, + StateRoot: b.StateRoot, + }, + BodyRoot: bodyRoot, + } +} diff --git a/mod/consensus-types/pkg/types/block_denebplus.go b/mod/consensus-types/pkg/types/block_denebplus.go new file mode 100644 index 0000000000..28fc79f06b --- /dev/null +++ b/mod/consensus-types/pkg/types/block_denebplus.go @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: BUSL-1.1 +// +// Copyright (C) 2024, Berachain Foundation. All rights reserved. +// Use of this software is governed by the Business Source License included +// in the LICENSE file of this repository and at www.mariadb.com/bsl11. +// +// ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY +// TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER +// VERSIONS OF THE LICENSED WORK. +// +// THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF +// LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF +// LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE). +// +// TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +// AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +// EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +// TITLE. + +//nolint:dupl // it's okay to duplicate code for different types +package types + +import ( + "github.com/berachain/beacon-kit/mod/primitives/pkg/common" + "github.com/berachain/beacon-kit/mod/primitives/pkg/version" +) + +// BeaconBlockDenebPlus represents a block in the beacon chain during +// the DenebPlus fork. +// +//go:generate go run github.com/ferranbt/fastssz/sszgen --path block_denebplus.go -objs BeaconBlockDenebPlus -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_denebplus.go,./attestation_data.go,./slashing_info.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block.ssz.go +type BeaconBlockDenebPlus struct { + // BeaconBlockHeaderBase is the base of the BeaconBlockDenebPlus. + BeaconBlockHeaderBase + // Body is the body of the BeaconBlockDenebPlus, containing the block's + // operations. + Body *BeaconBlockBodyDenebPlus +} + +// Version identifies the version of the BeaconBlockDenebPlus. +func (b *BeaconBlockDenebPlus) Version() uint32 { + return version.Deneb +} + +// IsNil checks if the BeaconBlockDenebPlus instance is nil. +func (b *BeaconBlockDenebPlus) IsNil() bool { + return b == nil +} + +// SetStateRoot sets the state root of the BeaconBlockDenebPlus. +func (b *BeaconBlockDenebPlus) SetStateRoot(root common.Root) { + b.StateRoot = root +} + +// GetBody retrieves the body of the BeaconBlockDenebPlus. +func (b *BeaconBlockDenebPlus) GetBody() *BeaconBlockBody { + return &BeaconBlockBody{RawBeaconBlockBody: b.Body} +} + +// GetHeader builds a BeaconBlockHeader from the BeaconBlockDenebPlus. +func (b BeaconBlockDenebPlus) GetHeader() *BeaconBlockHeader { + bodyRoot, err := b.GetBody().HashTreeRoot() + if err != nil { + return nil + } + + return &BeaconBlockHeader{ + BeaconBlockHeaderBase: BeaconBlockHeaderBase{ + Slot: b.Slot, + ProposerIndex: b.ProposerIndex, + ParentBlockRoot: b.ParentBlockRoot, + StateRoot: b.StateRoot, + }, + BodyRoot: bodyRoot, + } +} diff --git a/mod/consensus-types/pkg/types/body.go b/mod/consensus-types/pkg/types/body.go index 254adeeb2f..aa8da806ae 100644 --- a/mod/consensus-types/pkg/types/body.go +++ b/mod/consensus-types/pkg/types/body.go @@ -114,12 +114,6 @@ func (b *BeaconBlockBodyBase) GetEth1Data() *Eth1Data { return b.Eth1Data } -// SetBlobKzgCommitments sets the BlobKzgCommitments of the -// BeaconBlockBodyDeneb. -func (b *BeaconBlockBodyDeneb) SetEth1Data(eth1Data *Eth1Data) { - b.Eth1Data = eth1Data -} - // GetGraffiti returns the Graffiti of the Body. func (b *BeaconBlockBodyBase) GetGraffiti() common.Bytes32 { return b.Graffiti diff --git a/mod/consensus-types/pkg/types/body_deneb.go b/mod/consensus-types/pkg/types/body_deneb.go index 48c2d3727a..bac5a881ed 100644 --- a/mod/consensus-types/pkg/types/body_deneb.go +++ b/mod/consensus-types/pkg/types/body_deneb.go @@ -86,6 +86,11 @@ func (b *BeaconBlockBodyDeneb) SetBlobKzgCommitments( b.BlobKzgCommitments = commitments } +// SetEth1Data sets the SetEth1Data of the BeaconBlockBodyDeneb. +func (b *BeaconBlockBodyDeneb) SetEth1Data(eth1Data *Eth1Data) { + b.Eth1Data = eth1Data +} + // GetTopLevelRoots returns the top-level roots of the BeaconBlockBodyDeneb. func (b *BeaconBlockBodyDeneb) GetTopLevelRoots() ([][32]byte, error) { var ( diff --git a/mod/consensus-types/pkg/types/body_deneb.ssz.go b/mod/consensus-types/pkg/types/body_deneb.ssz.go index f9f77e3449..5472e674b0 100644 --- a/mod/consensus-types/pkg/types/body_deneb.ssz.go +++ b/mod/consensus-types/pkg/types/body_deneb.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: ed9c3086b11b06277df5571f9949e0798a4e57507a3a089265f9f4d1b4b75c3f +// Hash: edd554cd85d1277ee64bdf14d245db92fa43ff67fb414cfc7b79a3602f4083e6 // Version: 0.1.3 package types diff --git a/mod/consensus-types/pkg/types/body_denebplus.go b/mod/consensus-types/pkg/types/body_denebplus.go index 29f9965a26..a3f3bd436d 100644 --- a/mod/consensus-types/pkg/types/body_denebplus.go +++ b/mod/consensus-types/pkg/types/body_denebplus.go @@ -91,6 +91,11 @@ func (b *BeaconBlockBodyDenebPlus) SetBlobKzgCommitments( b.BlobKzgCommitments = commitments } +// SetEth1Data sets the SetEth1Data of the BeaconBlockBodyDeneb. +func (b *BeaconBlockBodyDenebPlus) SetEth1Data(eth1Data *Eth1Data) { + b.Eth1Data = eth1Data +} + // GetTopLevelRoots returns the top-level roots of the BeaconBlockBodyDenebPlus. func (b *BeaconBlockBodyDenebPlus) GetTopLevelRoots() ([][32]byte, error) { var ( diff --git a/mod/consensus-types/pkg/types/body_denebplus.ssz.go b/mod/consensus-types/pkg/types/body_denebplus.ssz.go index f5b628d6d2..b6ba34cb5d 100644 --- a/mod/consensus-types/pkg/types/body_denebplus.ssz.go +++ b/mod/consensus-types/pkg/types/body_denebplus.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 8d96adddac3545462c1aa3abdfac540bb09b9e2bae3e03d594e1b8151f226a78 +// Hash: 85379aa0a26ae9de6919c9242d4621267a55d5137f72bcb0ab7a3282e06f743e // Version: 0.1.3 package types diff --git a/mod/consensus-types/pkg/types/deposit.ssz.go b/mod/consensus-types/pkg/types/deposit.ssz.go index 14ccfbfdfa..985de3cbd5 100644 --- a/mod/consensus-types/pkg/types/deposit.ssz.go +++ b/mod/consensus-types/pkg/types/deposit.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 915b85206687e0d756a9cbfb6a735cd6c2a6c6fca251badaa43811f619678ca5 +// Hash: 79a3e343d582db360b93fc7971a8242f51e68c1a6e5a0ad84fecfc24a8e093d4 // Version: 0.1.3 package types diff --git a/mod/consensus-types/pkg/types/payload.ssz.go b/mod/consensus-types/pkg/types/payload.ssz.go index 602254c3e9..e3353f7b2f 100644 --- a/mod/consensus-types/pkg/types/payload.ssz.go +++ b/mod/consensus-types/pkg/types/payload.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: d24e42b93ce98adc60e5374f8be7261a3891ac80c8227aa0eadbaea5ca330982 +// Hash: 60ac64e30dc0dc2b06e4142bccc8bf1570dcfea625a6763628a2e04382db61e6 // Version: 0.1.3 package types diff --git a/mod/engine-primitives/pkg/engine-primitives/withdrawal.ssz.go b/mod/engine-primitives/pkg/engine-primitives/withdrawal.ssz.go index 07f00fac03..d7cc60cd3a 100644 --- a/mod/engine-primitives/pkg/engine-primitives/withdrawal.ssz.go +++ b/mod/engine-primitives/pkg/engine-primitives/withdrawal.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 0a6d2efa4eb5cf260a07ebf775481fdecfa3986800893c80374b910f5bd983a1 +// Hash: 17e91a00097f40cec5075a3673361be7891ccf9a58fa4a1347cf1b30428f35ac // Version: 0.1.3 package engineprimitives diff --git a/mod/primitives/pkg/version/version.go b/mod/primitives/pkg/version/version.go index 07a2fa4c59..787b8b03bb 100644 --- a/mod/primitives/pkg/version/version.go +++ b/mod/primitives/pkg/version/version.go @@ -30,6 +30,7 @@ const ( Bellatrix Capella Deneb + DenebPlus Electra ) From 522a17e8b617a411fbcaafe9adfada0593fd71d6 Mon Sep 17 00:00:00 2001 From: ocnc Date: Thu, 11 Jul 2024 20:40:12 -0400 Subject: [PATCH 2/6] bet --- mod/primitives/pkg/version/version_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mod/primitives/pkg/version/version_test.go b/mod/primitives/pkg/version/version_test.go index 4f50e7d3a0..81009f7b6d 100644 --- a/mod/primitives/pkg/version/version_test.go +++ b/mod/primitives/pkg/version/version_test.go @@ -115,9 +115,14 @@ func TestToUint32(t *testing.T) { input: [4]byte{4, 0, 0, 0}, expected: version.Deneb, }, + { + name: "DenebPlus", + input: [4]byte{4, 0, 0, 0}, + expected: version.Deneb, + }, { name: "Electra", - input: [4]byte{5, 0, 0, 0}, + input: [4]byte{6, 0, 0, 0}, expected: version.Electra, }, } From ee8bb48cce3eacd46238ea617f667654e6503f07 Mon Sep 17 00:00:00 2001 From: ocnc Date: Thu, 11 Jul 2024 20:52:48 -0400 Subject: [PATCH 3/6] bet --- mod/primitives/pkg/version/version_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mod/primitives/pkg/version/version_test.go b/mod/primitives/pkg/version/version_test.go index 81009f7b6d..62b1449e29 100644 --- a/mod/primitives/pkg/version/version_test.go +++ b/mod/primitives/pkg/version/version_test.go @@ -59,10 +59,15 @@ func TestFromUint32(t *testing.T) { input: version.Deneb, expected: [4]byte{4, 0, 0, 0}, }, + { + name: "DenebPlus", + input: version.DenebPlus, + expected: [4]byte{5, 0, 0, 0}, + }, { name: "Electra", input: version.Electra, - expected: [4]byte{5, 0, 0, 0}, + expected: [4]byte{6, 0, 0, 0}, }, } @@ -117,8 +122,8 @@ func TestToUint32(t *testing.T) { }, { name: "DenebPlus", - input: [4]byte{4, 0, 0, 0}, - expected: version.Deneb, + input: [4]byte{5, 0, 0, 0}, + expected: version.DenebPlus, }, { name: "Electra", From 9b6757a8ac535b57cba9a7c6cf296b99cb670c25 Mon Sep 17 00:00:00 2001 From: ocnc Date: Thu, 11 Jul 2024 21:15:30 -0400 Subject: [PATCH 4/6] bet --- mod/consensus-types/pkg/types/body_deneb.go | 2 +- mod/consensus-types/pkg/types/body_denebplus.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/consensus-types/pkg/types/body_deneb.go b/mod/consensus-types/pkg/types/body_deneb.go index bac5a881ed..3d1fd68402 100644 --- a/mod/consensus-types/pkg/types/body_deneb.go +++ b/mod/consensus-types/pkg/types/body_deneb.go @@ -86,7 +86,7 @@ func (b *BeaconBlockBodyDeneb) SetBlobKzgCommitments( b.BlobKzgCommitments = commitments } -// SetEth1Data sets the SetEth1Data of the BeaconBlockBodyDeneb. +// SetEth1Data sets the Eth1Data of the BeaconBlockBodyDeneb. func (b *BeaconBlockBodyDeneb) SetEth1Data(eth1Data *Eth1Data) { b.Eth1Data = eth1Data } diff --git a/mod/consensus-types/pkg/types/body_denebplus.go b/mod/consensus-types/pkg/types/body_denebplus.go index a3f3bd436d..7f33e698a0 100644 --- a/mod/consensus-types/pkg/types/body_denebplus.go +++ b/mod/consensus-types/pkg/types/body_denebplus.go @@ -91,7 +91,7 @@ func (b *BeaconBlockBodyDenebPlus) SetBlobKzgCommitments( b.BlobKzgCommitments = commitments } -// SetEth1Data sets the SetEth1Data of the BeaconBlockBodyDeneb. +// SetEth1Data sets the Eth1Data of the BeaconBlockBodyDeneb. func (b *BeaconBlockBodyDenebPlus) SetEth1Data(eth1Data *Eth1Data) { b.Eth1Data = eth1Data } From efc42dee1de67d5eb9559647d139ed1b67a51776 Mon Sep 17 00:00:00 2001 From: ocnc Date: Thu, 11 Jul 2024 21:21:48 -0400 Subject: [PATCH 5/6] bet --- mod/consensus-types/pkg/types/block_deneb.go | 2 +- .../pkg/types/block_deneb.ssz.go | 134 ++++++++++++++++++ .../pkg/types/block_denebplus.go | 2 +- .../{block.ssz.go => block_denebplus.ssz.go} | 2 +- .../pkg/types/body_deneb.ssz.go | 2 +- .../pkg/types/body_denebplus.ssz.go | 2 +- 6 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 mod/consensus-types/pkg/types/block_deneb.ssz.go rename mod/consensus-types/pkg/types/{block.ssz.go => block_denebplus.ssz.go} (97%) diff --git a/mod/consensus-types/pkg/types/block_deneb.go b/mod/consensus-types/pkg/types/block_deneb.go index 07c46aa24f..8a3619e3ac 100644 --- a/mod/consensus-types/pkg/types/block_deneb.go +++ b/mod/consensus-types/pkg/types/block_deneb.go @@ -29,7 +29,7 @@ import ( // BeaconBlockDeneb represents a block in the beacon chain during // the Deneb fork. // -//go:generate go run github.com/ferranbt/fastssz/sszgen --path block_deneb.go -objs BeaconBlockDeneb -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_deneb.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block.ssz.go +//go:generate go run github.com/ferranbt/fastssz/sszgen --path block_deneb.go -objs BeaconBlockDeneb -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_deneb.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block_deneb.ssz.go type BeaconBlockDeneb struct { // BeaconBlockHeaderBase is the base of the BeaconBlockDeneb. BeaconBlockHeaderBase diff --git a/mod/consensus-types/pkg/types/block_deneb.ssz.go b/mod/consensus-types/pkg/types/block_deneb.ssz.go new file mode 100644 index 0000000000..ca9077c122 --- /dev/null +++ b/mod/consensus-types/pkg/types/block_deneb.ssz.go @@ -0,0 +1,134 @@ +// Code generated by fastssz. DO NOT EDIT. +// Hash: 68933976b40d0b90e2e647839a478acfaa493157e62e40c50d4c531cc8c6671a +// Version: 0.1.3 +package types + +import ( + ssz "github.com/ferranbt/fastssz" +) + +// MarshalSSZ ssz marshals the BeaconBlockDeneb object +func (b *BeaconBlockDeneb) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(b) +} + +// MarshalSSZTo ssz marshals the BeaconBlockDeneb object to a target array +func (b *BeaconBlockDeneb) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(84) + + // Field (0) 'Slot' + dst = ssz.MarshalUint64(dst, b.Slot) + + // Field (1) 'ProposerIndex' + dst = ssz.MarshalUint64(dst, b.ProposerIndex) + + // Field (2) 'ParentBlockRoot' + dst = append(dst, b.ParentBlockRoot[:]...) + + // Field (3) 'StateRoot' + dst = append(dst, b.StateRoot[:]...) + + // Offset (4) 'Body' + dst = ssz.WriteOffset(dst, offset) + + // Field (4) 'Body' + if dst, err = b.Body.MarshalSSZTo(dst); err != nil { + return + } + + return +} + +// UnmarshalSSZ ssz unmarshals the BeaconBlockDeneb object +func (b *BeaconBlockDeneb) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + tail := buf + var o4 uint64 + + // Field (0) 'Slot' + b.Slot = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'ProposerIndex' + b.ProposerIndex = ssz.UnmarshallUint64(buf[8:16]) + + // Field (2) 'ParentBlockRoot' + copy(b.ParentBlockRoot[:], buf[16:48]) + + // Field (3) 'StateRoot' + copy(b.StateRoot[:], buf[48:80]) + + // Offset (4) 'Body' + if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + return ssz.ErrOffset + } + + if o4 < 84 { + return ssz.ErrInvalidVariableOffset + } + + // Field (4) 'Body' + { + buf = tail[o4:] + if b.Body == nil { + b.Body = new(BeaconBlockBodyDeneb) + } + if err = b.Body.UnmarshalSSZ(buf); err != nil { + return err + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockDeneb object +func (b *BeaconBlockDeneb) SizeSSZ() (size int) { + size = 84 + + // Field (4) 'Body' + if b.Body == nil { + b.Body = new(BeaconBlockBodyDeneb) + } + size += b.Body.SizeSSZ() + + return +} + +// HashTreeRoot ssz hashes the BeaconBlockDeneb object +func (b *BeaconBlockDeneb) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(b) +} + +// HashTreeRootWith ssz hashes the BeaconBlockDeneb object with a hasher +func (b *BeaconBlockDeneb) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Slot' + hh.PutUint64(b.Slot) + + // Field (1) 'ProposerIndex' + hh.PutUint64(b.ProposerIndex) + + // Field (2) 'ParentBlockRoot' + hh.PutBytes(b.ParentBlockRoot[:]) + + // Field (3) 'StateRoot' + hh.PutBytes(b.StateRoot[:]) + + // Field (4) 'Body' + if err = b.Body.HashTreeRootWith(hh); err != nil { + return + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the BeaconBlockDeneb object +func (b *BeaconBlockDeneb) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(b) +} diff --git a/mod/consensus-types/pkg/types/block_denebplus.go b/mod/consensus-types/pkg/types/block_denebplus.go index 28fc79f06b..54490b7105 100644 --- a/mod/consensus-types/pkg/types/block_denebplus.go +++ b/mod/consensus-types/pkg/types/block_denebplus.go @@ -29,7 +29,7 @@ import ( // BeaconBlockDenebPlus represents a block in the beacon chain during // the DenebPlus fork. // -//go:generate go run github.com/ferranbt/fastssz/sszgen --path block_denebplus.go -objs BeaconBlockDenebPlus -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_denebplus.go,./attestation_data.go,./slashing_info.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block.ssz.go +//go:generate go run github.com/ferranbt/fastssz/sszgen --path block_denebplus.go -objs BeaconBlockDenebPlus -include ../../../primitives/pkg/common,../../../primitives/pkg/crypto,../../../primitives/pkg/math,..,./header.go,./withdrawal_credentials.go,../../../engine-primitives/pkg/engine-primitives/withdrawal.go,./deposit.go,./payload.go,./deposit.go,../../../primitives/pkg/eip4844,../../../primitives/pkg/bytes,./eth1data.go,../../../primitives/pkg/math,../../../primitives/pkg/common,./body.go,./body_denebplus.go,./attestation_data.go,./slashing_info.go,$GETH_PKG_INCLUDE/common,$GETH_PKG_INCLUDE/common/hexutil -output block_denebplus.ssz.go type BeaconBlockDenebPlus struct { // BeaconBlockHeaderBase is the base of the BeaconBlockDenebPlus. BeaconBlockHeaderBase diff --git a/mod/consensus-types/pkg/types/block.ssz.go b/mod/consensus-types/pkg/types/block_denebplus.ssz.go similarity index 97% rename from mod/consensus-types/pkg/types/block.ssz.go rename to mod/consensus-types/pkg/types/block_denebplus.ssz.go index 8d5daaa06d..cc6980ce76 100644 --- a/mod/consensus-types/pkg/types/block.ssz.go +++ b/mod/consensus-types/pkg/types/block_denebplus.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 6401129c77820a513c17f214ef2269681bf668f0c24021219d7ed4ec60dd204c +// Hash: 3706d1fc38ee870de444ca96dda50f8cb984a5d0df7f7c7af03751c80b1831f5 // Version: 0.1.3 package types diff --git a/mod/consensus-types/pkg/types/body_deneb.ssz.go b/mod/consensus-types/pkg/types/body_deneb.ssz.go index 5472e674b0..aff92b6e9f 100644 --- a/mod/consensus-types/pkg/types/body_deneb.ssz.go +++ b/mod/consensus-types/pkg/types/body_deneb.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: edd554cd85d1277ee64bdf14d245db92fa43ff67fb414cfc7b79a3602f4083e6 +// Hash: dfcdfbba13d83a8124d1e600a13d6c48aab974a26fa323f85ae1cd963a8b0050 // Version: 0.1.3 package types diff --git a/mod/consensus-types/pkg/types/body_denebplus.ssz.go b/mod/consensus-types/pkg/types/body_denebplus.ssz.go index b6ba34cb5d..7e45ae9e6c 100644 --- a/mod/consensus-types/pkg/types/body_denebplus.ssz.go +++ b/mod/consensus-types/pkg/types/body_denebplus.ssz.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 85379aa0a26ae9de6919c9242d4621267a55d5137f72bcb0ab7a3282e06f743e +// Hash: 18df428c01eb765e8458ec2b45fff4ed302c4035b98620e22aa24113da6c7720 // Version: 0.1.3 package types From b1d136957fa3687c420c04e32a7852c95e18a957 Mon Sep 17 00:00:00 2001 From: ocnc Date: Thu, 11 Jul 2024 21:28:58 -0400 Subject: [PATCH 6/6] bet --- mod/chain-spec/pkg/chain/chain_spec.go | 3 ++- mod/consensus-types/pkg/types/block_deneb.go | 1 - mod/consensus-types/pkg/types/block_denebplus.go | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/mod/chain-spec/pkg/chain/chain_spec.go b/mod/chain-spec/pkg/chain/chain_spec.go index 2c08196854..c1f0fbfa84 100644 --- a/mod/chain-spec/pkg/chain/chain_spec.go +++ b/mod/chain-spec/pkg/chain/chain_spec.go @@ -180,7 +180,8 @@ type Spec[ // availability period relative to the current slot. WithinDAPeriod(block, current SlotT) bool - // GetCometBFTConfigForSlot retrieves the CometBFT config for a specific slot. + // GetCometBFTConfigForSlot retrieves the CometBFT config for a specific + // slot. GetCometBFTConfigForSlot(slot SlotT) CometBFTConfigT } diff --git a/mod/consensus-types/pkg/types/block_deneb.go b/mod/consensus-types/pkg/types/block_deneb.go index 8a3619e3ac..f09ea01ba1 100644 --- a/mod/consensus-types/pkg/types/block_deneb.go +++ b/mod/consensus-types/pkg/types/block_deneb.go @@ -18,7 +18,6 @@ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE. -//nolint:dupl // it's okay to duplicate code for different types package types import ( diff --git a/mod/consensus-types/pkg/types/block_denebplus.go b/mod/consensus-types/pkg/types/block_denebplus.go index 54490b7105..809d68f9f8 100644 --- a/mod/consensus-types/pkg/types/block_denebplus.go +++ b/mod/consensus-types/pkg/types/block_denebplus.go @@ -18,7 +18,6 @@ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND // TITLE. -//nolint:dupl // it's okay to duplicate code for different types package types import (