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(all): update SSZ dependencies #2153

Merged
merged 5 commits into from
Nov 14, 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
4 changes: 2 additions & 2 deletions beacond/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ replace (
github.com/cometbft/cometbft => github.com/cometbft/cometbft v1.0.0-rc1.0.20240805092115-3b2c5d9e1843
github.com/cosmos/cosmos-sdk => github.com/berachain/cosmos-sdk v0.46.0-beta2.0.20240808182639-7bdbf06a94f2
github.com/ferranbt/fastssz => github.com/itsdevbear/fastssz v0.0.0-20240731164358-a354a31813e6
github.com/karalabe/ssz => github.com/itsdevbear/ssz v0.0.0-20240729201410-1a53beff08cb
github.com/karalabe/ssz => github.com/berachain/karalabe-ssz v0.2.0-alpha.9
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the main goal of this PR. We fix a bug in this dependency

)

require (
Expand Down Expand Up @@ -73,7 +73,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/berachain/beacon-kit/mod/async v0.0.0-20240821213929-f32b8e2dc5c8 // indirect
github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240705193247-d464364483df // indirect
github.com/berachain/beacon-kit/mod/config v0.0.0-20241107170417-7905e3d59a1d // indirect
github.com/berachain/beacon-kit/mod/config v0.0.0-20241113214258-240f617103ad // indirect
github.com/berachain/beacon-kit/mod/errors v0.0.0-20240806211103-d1105603bfc0 // indirect
github.com/berachain/beacon-kit/mod/geth-primitives v0.0.0-20240806160829-cde2d1347e7e // indirect
github.com/berachain/beacon-kit/mod/observability v0.0.0-unpublished // indirect
Expand Down
4 changes: 2 additions & 2 deletions beacond/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ github.com/berachain/beacon-kit/mod/state-transition v0.0.0-20240717225334-64ec6
github.com/berachain/beacon-kit/mod/state-transition v0.0.0-20240717225334-64ec6650da31/go.mod h1:sIzib45R7B9Q99yvsYUcj2xJZPBpe3J9JbcBDMZNp7E=
github.com/berachain/cosmos-sdk v0.46.0-beta2.0.20240808182639-7bdbf06a94f2 h1:4qwOPga+dKeDelSJ6pseasQq6fcjd7iXhah0y7enuco=
github.com/berachain/cosmos-sdk v0.46.0-beta2.0.20240808182639-7bdbf06a94f2/go.mod h1:DUyJJMMuFJ9OZAhnFMLA0KTFGoVw61p8wnqtV3Wgx3c=
github.com/berachain/karalabe-ssz v0.2.0-alpha.9 h1:ewcsWxRhZ+KM4xfamF5zgmbWlgkllCZtdv0k2ivPCmM=
github.com/berachain/karalabe-ssz v0.2.0-alpha.9/go.mod h1:7BZG/jckt43eKw7sl/AF6gTcL0oxgFPme39m54v8rDI=
github.com/bgentry/speakeasy v0.2.0 h1:tgObeVOf8WAvtuAX6DhJ4xks4CFNwPDZiqzGqIHE51E=
github.com/bgentry/speakeasy v0.2.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
Expand Down Expand Up @@ -420,8 +422,6 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/itsdevbear/fastssz v0.0.0-20240731164358-a354a31813e6 h1:UZPeAqKS2AXLvFpSgPgZ2Vj3ZNl4iapFTK49wMujFMM=
github.com/itsdevbear/fastssz v0.0.0-20240731164358-a354a31813e6/go.mod h1:Ea3+oeoRGGLGm5shYAeDgu6PGUlcvQhE2fILyD9+tGg=
github.com/itsdevbear/ssz v0.0.0-20240729201410-1a53beff08cb h1:ANOSROCqWTdb2N0/FBJ3VhpvUhs2rb4xtKJeT35jM+4=
github.com/itsdevbear/ssz v0.0.0-20240729201410-1a53beff08cb/go.mod h1:SUFJO5R2VkUK3vT80pjfIB/g7eaQgSU2RhbuL8GOJq4=
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jhump/protoreflect v1.16.0 h1:54fZg+49widqXYQ0b+usAFHbMkBGR4PpXrsHc8+TBDg=
Expand Down
17 changes: 8 additions & 9 deletions examples/berad/pkg/consensus-types/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,19 @@ type BeaconState[
// SizeSSZ returns the ssz encoded size in bytes for the BeaconState object.
func (st *BeaconState[
_, _, _, _, _, _, _, _, _,
]) SizeSSZ(fixed bool) uint32 {
]) SizeSSZ(siz *ssz.Sizer, fixed bool) uint32 {
var size uint32 = 276

if fixed {
return size
}

// Dynamic size fields
size += ssz.SizeSliceOfStaticBytes(st.BlockRoots)
size += ssz.SizeSliceOfStaticBytes(st.StateRoots)
size += ssz.SizeDynamicObject(st.LatestExecutionPayloadHeader)
size += ssz.SizeSliceOfStaticObjects(st.Validators)
size += ssz.SizeSliceOfUint64s(st.Balances)
size += ssz.SizeSliceOfStaticBytes(st.RandaoMixes)
size += ssz.SizeSliceOfStaticBytes(siz, st.BlockRoots)
size += ssz.SizeSliceOfStaticBytes(siz, st.StateRoots)
size += ssz.SizeDynamicObject(siz, st.LatestExecutionPayloadHeader)
size += ssz.SizeSliceOfStaticObjects(siz, st.Validators)
size += ssz.SizeSliceOfUint64s(siz, st.Balances)
size += ssz.SizeSliceOfStaticBytes(siz, st.RandaoMixes)

return size
}
Expand Down Expand Up @@ -131,7 +130,7 @@ func (st *BeaconState[
func (st *BeaconState[
_, _, _, _, _, _, _, _, _,
]) MarshalSSZ() ([]byte, error) {
buf := make([]byte, st.SizeSSZ(false))
buf := make([]byte, ssz.Size(st))
return buf, ssz.EncodeToBytes(buf, st)
}

Expand Down
4 changes: 2 additions & 2 deletions examples/berad/pkg/consensus-types/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (v *Validator) New(
const ValidatorSize = 112

// SizeSSZ returns the size of the Validator object in SSZ encoding.
func (*Validator) SizeSSZ() uint32 {
func (*Validator) SizeSSZ(*ssz.Sizer) uint32 {
return ValidatorSize
}

Expand All @@ -117,7 +117,7 @@ func (v *Validator) HashTreeRoot() common.Root {

// MarshalSSZ marshals the Validator object to SSZ format.
func (v *Validator) MarshalSSZ() ([]byte, error) {
buf := make([]byte, v.SizeSSZ())
buf := make([]byte, ssz.Size(v))
return buf, ssz.EncodeToBytes(buf, v)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ func (sp *StateProcessor[
// changes.
g.Go(func() error {
var err error
header, err = payload.ToHeader(
sp.cs.MaxWithdrawalsPerPayload(),
sp.cs.DepositEth1ChainID(),
)
header, err = payload.ToHeader()
return err
})

Expand Down
5 changes: 1 addition & 4 deletions examples/berad/pkg/state-transition/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ type ExecutionPayload[
GetBaseFeePerGas() *math.U256
GetBlobGasUsed() math.U64
GetExcessBlobGas() math.U64
ToHeader(
maxWithdrawalsPerPayload uint64,
eth1ChainID uint64,
Comment on lines -167 to -168
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

side effect of dropping Bartio stuff

) (ExecutionPayloadHeaderT, error)
ToHeader() (ExecutionPayloadHeaderT, error)
}

type ExecutionPayloadHeader interface {
Expand Down
27 changes: 24 additions & 3 deletions mod/beacon/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ module github.com/berachain/beacon-kit/mod/beacon

go 1.23.0
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Invalid Go version specified

The Go version 1.23.0 does not exist. The latest stable version is 1.22.0. This will prevent the module from being used.

Apply this diff to fix the Go version:

-go 1.23.0
+go 1.22.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go 1.23.0
go 1.22.0


replace google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240711142825-46eb208f015d
Copy link
Collaborator Author

@abi87 abi87 Nov 14, 2024

Choose a reason for hiding this comment

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

necessary to unlock mod tidy.
In essence, without this mod tidy breaks due to ambiguous import among:

  • google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
  • google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d

Here we explicitly select the second because it's the most recent and them tidy the rest of dependencies


require (
github.com/berachain/beacon-kit/mod/async v0.0.0-20240816230528-f52c938c20cc
github.com/berachain/beacon-kit/mod/async v0.0.0-20240821213929-f32b8e2dc5c8
github.com/berachain/beacon-kit/mod/config v0.0.0-20241113214258-240f617103ad
github.com/berachain/beacon-kit/mod/engine-primitives v0.0.0-20240809202957-3e3f169ad720
github.com/berachain/beacon-kit/mod/errors v0.0.0-20240806211103-d1105603bfc0
github.com/berachain/beacon-kit/mod/log v0.0.0-20240809202957-3e3f169ad720
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240820191615-398849c34954
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240911165923-82f71ec86570
golang.org/x/sync v0.8.0
Comment on lines +8 to 14
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider using tagged versions instead of commit hashes

All direct dependencies use pseudo-versions (commit hashes). While this ensures exact version pinning, it makes it harder to:

  • Track semantic versioning
  • Understand compatibility between versions
  • Maintain reproducible builds across different environments

Consider using tagged versions where available.

)

Expand All @@ -16,7 +19,7 @@ require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240703145037-b5612ab256db // indirect
github.com/berachain/beacon-kit/mod/chain-spec v0.0.0-20240705193247-d464364483df // indirect
github.com/berachain/beacon-kit/mod/geth-primitives v0.0.0-20240806160829-cde2d1347e7e // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
Expand All @@ -27,21 +30,31 @@ require (
github.com/cockroachdb/pebble v1.1.1 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft v1.0.0-rc1.0.20240805092115-3b2c5d9e1843 // indirect
github.com/cometbft/cometbft/api v1.0.0-rc.1.0.20240806094948-2c4293ef36c4 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.13.0 // indirect
github.com/cosmos/crypto v0.1.2 // indirect
github.com/cosmos/gogoproto v1.7.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
github.com/ethereum/go-ethereum v1.14.7 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
github.com/ferranbt/fastssz v0.1.4-0.20240629094022-eac385e6ee79 // indirect
github.com/getsentry/sentry-go v0.28.1 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
Expand All @@ -56,8 +69,11 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/petermattis/goid v0.0.0-20240607163614-bb94eb51e7a7 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
Expand All @@ -66,7 +82,9 @@ require (
github.com/prysmaticlabs/gohashtree v0.0.4-beta.0.20240624100937-73632381301b // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
Expand All @@ -78,7 +96,10 @@ require (
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Loading
Loading