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

chore(deneb-plus): forgot to implement set eth1data #1738

Merged
merged 7 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
55 changes: 5 additions & 50 deletions mod/consensus-types/pkg/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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,
}
}
34 changes: 17 additions & 17 deletions mod/consensus-types/pkg/types/block.ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions mod/consensus-types/pkg/types/block_deneb.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
77 changes: 77 additions & 0 deletions mod/consensus-types/pkg/types/block_denebplus.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
5 changes: 0 additions & 5 deletions mod/consensus-types/pkg/types/body.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ func (b *BeaconBlockBodyBase) GetEth1Data() *Eth1Data {
return b.Eth1Data
}

// SetEth1Data sets the Eth1Data 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
Expand Down
5 changes: 5 additions & 0 deletions mod/consensus-types/pkg/types/body_deneb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
ocnc marked this conversation as resolved.
Show resolved Hide resolved

// GetTopLevelRoots returns the top-level roots of the BeaconBlockBodyDeneb.
func (b *BeaconBlockBodyDeneb) GetTopLevelRoots() ([][32]byte, error) {
var (
Expand Down
2 changes: 1 addition & 1 deletion mod/consensus-types/pkg/types/body_deneb.ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions mod/consensus-types/pkg/types/body_denebplus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
ocnc marked this conversation as resolved.
Show resolved Hide resolved

// GetTopLevelRoots returns the top-level roots of the BeaconBlockBodyDenebPlus.
func (b *BeaconBlockBodyDenebPlus) GetTopLevelRoots() ([][32]byte, error) {
var (
Expand Down
2 changes: 1 addition & 1 deletion mod/consensus-types/pkg/types/body_denebplus.ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/consensus-types/pkg/types/deposit.ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod/consensus-types/pkg/types/payload.ssz.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions mod/primitives/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
Bellatrix
Capella
Deneb
DenebPlus
Electra
)

Expand Down
Loading
Loading