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

Capella beacon state #11141

Merged
merged 51 commits into from
Oct 12, 2022
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d56db46
fork
rkapka Jul 29, 2022
657b897
types
rkapka Jul 29, 2022
fffa376
cloners
rkapka Jul 29, 2022
ed6c73a
getters
rkapka Jul 29, 2022
2b8a8da
remove CapellaBlind from fork
rkapka Jul 29, 2022
6d303f6
hasher
rkapka Jul 29, 2022
d21d437
setters
rkapka Jul 29, 2022
f061dab
spec params, config tests
rkapka Jul 29, 2022
00a840b
generate ssz
rkapka Aug 1, 2022
a8c9125
executionPayloadHeaderCapella
rkapka Aug 1, 2022
6790b1c
proto state
rkapka Aug 1, 2022
b1ba747
BeaconStateCapella SSZ
rkapka Aug 1, 2022
0b7cfbd
saving state
rkapka Aug 1, 2022
437c265
configfork
rkapka Aug 1, 2022
c5deedb
BUILD files
rkapka Aug 1, 2022
8af7855
Merge branch 'develop' into capella-state
rkapka Aug 1, 2022
d5e8c25
fix RealPosition
rkapka Aug 1, 2022
f98e90b
Merge branch '__develop' into capella-state
rkapka Aug 1, 2022
8b4b3cf
Merge remote-tracking branch 'origin/capella-state' into capella-state
rkapka Aug 1, 2022
d2aabcf
fix hasher
rkapka Aug 1, 2022
e74ad33
SetLatestExecutionPayloadHeaderCapella
rkapka Aug 1, 2022
e21ab9c
fix error message
rkapka Aug 1, 2022
c96303e
reduce complexity of saveStatesEfficientInternal
rkapka Aug 1, 2022
50ba24b
add latestExecutionPayloadHeaderCapella to minimal state
rkapka Aug 1, 2022
70c74ba
halway done interface
rkapka Aug 2, 2022
525066f
remove withdrawal methods
rkapka Aug 2, 2022
686d14c
merge setters
rkapka Aug 2, 2022
5926230
change signatures for v1 and v2
rkapka Aug 2, 2022
b05ed63
fixing errors pt. 1
rkapka Aug 2, 2022
bfeff5e
paylod_test fixes
rkapka Aug 2, 2022
a995186
fix everything
rkapka Aug 2, 2022
5d84931
remove unused func
rkapka Aug 2, 2022
ad28693
Merge branch '__develop' into capella-state
rkapka Sep 29, 2022
a311c89
fix tests
rkapka Sep 29, 2022
6326523
state_trie_test improvements
rkapka Sep 29, 2022
d7de7c7
in progress...
rkapka Sep 29, 2022
2647b1f
hasher test
rkapka Sep 29, 2022
bcae282
fix configs
rkapka Sep 30, 2022
fb6b1d1
Merge branch '__develop' into capella-state
rkapka Sep 30, 2022
0df2f33
simplify hashing
rkapka Sep 30, 2022
a117e0b
Revert "fix configs"
rkapka Sep 30, 2022
0b00e1e
remove capella from config test
rkapka Sep 30, 2022
1a43b53
Merge branch 'develop' into capella-state
rkapka Sep 30, 2022
5548f0f
unify locking
rkapka Oct 4, 2022
6a49722
Merge branch 'develop' into capella-state
terencechain Oct 4, 2022
54e519c
review
rkapka Oct 4, 2022
ae78e88
hashing
rkapka Oct 5, 2022
2ab4908
Merge branch 'develop' into capella-state
rkapka Oct 5, 2022
872245c
fixes
rkapka Oct 5, 2022
f437cd8
Merge branch 'develop' into capella-state
rauljordan Oct 5, 2022
6266ce2
Merge branch 'develop' into capella-state
rkapka Oct 12, 2022
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
Prev Previous commit
Next Next commit
halway done interface
rkapka committed Aug 2, 2022
commit 70c74bac7c533aa49129860953680acc55c0c46d
1 change: 0 additions & 1 deletion beacon-chain/state/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ go_library(
"//config/fieldparams:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"@com_github_prometheus_client_golang//prometheus:go_default_library",
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
3 changes: 1 addition & 2 deletions beacon-chain/state/interfaces.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ import (
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
"github.com/prysmaticlabs/prysm/consensus-types/interfaces"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)

@@ -62,7 +61,7 @@ type ReadOnlyBeaconState interface {
MarshalSSZ() ([]byte, error)
IsNil() bool
Version() int
LatestExecutionPayloadHeader() (*enginev1.ExecutionPayloadHeader, error)
LatestExecutionPayloadHeader() (interfaces.ExecutionData, error)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to reuse the interface that Raul created for blocks.

}

// WriteOnlyBeaconState defines a struct which only has write access to beacon state methods.
1 change: 1 addition & 0 deletions beacon-chain/state/state-native/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ go_library(
"//config/params:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/wrapper:go_default_library",
"//container/slice:go_default_library",
"//crypto/hash:go_default_library",
"//encoding/bytesutil:go_default_library",
27 changes: 8 additions & 19 deletions beacon-chain/state/state-native/getters_payload_header.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package state_native

import (
"github.com/prysmaticlabs/prysm/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/consensus-types/wrapper"
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"github.com/prysmaticlabs/prysm/runtime/version"
)

// LatestExecutionPayloadHeader of the beacon state.
func (b *BeaconState) LatestExecutionPayloadHeader() (*enginev1.ExecutionPayloadHeader, error) {
if b.version != version.Bellatrix {
func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData, error) {
if b.version < version.Bellatrix {
return nil, errNotSupported("LatestExecutionPayloadHeader", b.version)
}

@@ -19,7 +21,10 @@ func (b *BeaconState) LatestExecutionPayloadHeader() (*enginev1.ExecutionPayload
b.lock.RLock()
defer b.lock.RUnlock()

return b.latestExecutionPayloadHeaderVal(), nil
if b.version == version.Bellatrix {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think in general and considering future forks, the best approach for all these switches is the opposite order

if version >= Capella { do something  }
else if version >= Bellatrix { do something }
else { not supported }

The first one is hit more often.

return wrapper.WrappedExecutionPayloadHeader(b.latestExecutionPayloadHeaderVal())
}
return wrapper.WrappedExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapellaVal())
}

// latestExecutionPayloadHeaderVal of the beacon state.
@@ -28,22 +33,6 @@ func (b *BeaconState) latestExecutionPayloadHeaderVal() *enginev1.ExecutionPaylo
return ethpb.CopyExecutionPayloadHeader(b.latestExecutionPayloadHeader)
}

// LatestExecutionPayloadHeaderCapella of the beacon state.
func (b *BeaconState) LatestExecutionPayloadHeaderCapella() (*enginev1.ExecutionPayloadHeaderCapella, error) {
if b.version != version.Capella {
return nil, errNotSupported("LatestExecutionPayloadHeaderCapella", b.version)
}

if b.latestExecutionPayloadHeaderCapella == nil {
return nil, nil
}

b.lock.RLock()
defer b.lock.RUnlock()

return b.latestExecutionPayloadHeaderCapellaVal(), nil
}

// latestExecutionPayloadHeaderCapellaVal of the beacon state.
// This assumes that a lock is already held on BeaconState.
func (b *BeaconState) latestExecutionPayloadHeaderCapellaVal() *enginev1.ExecutionPayloadHeaderCapella {
1 change: 1 addition & 0 deletions beacon-chain/state/v3/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ go_library(
"//config/params:go_default_library",
"//consensus-types/interfaces:go_default_library",
"//consensus-types/primitives:go_default_library",
"//consensus-types/wrapper:go_default_library",
"//container/slice:go_default_library",
"//crypto/hash:go_default_library",
"//encoding/bytesutil:go_default_library",
6 changes: 4 additions & 2 deletions beacon-chain/state/v3/getters_payload_header.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package v3

import (
"github.com/prysmaticlabs/prysm/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/consensus-types/wrapper"
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)

// LatestExecutionPayloadHeader of the beacon state.
func (b *BeaconState) LatestExecutionPayloadHeader() (*enginev1.ExecutionPayloadHeader, error) {
func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData, error) {
if !b.hasInnerState() {
return nil, ErrNilInnerState
}
@@ -17,7 +19,7 @@ func (b *BeaconState) LatestExecutionPayloadHeader() (*enginev1.ExecutionPayload
b.lock.RLock()
defer b.lock.RUnlock()

return b.latestExecutionPayloadHeader(), nil
return wrapper.WrappedExecutionPayloadHeader(b.latestExecutionPayloadHeader())
}

// latestExecutionPayloadHeader of the beacon state.
1 change: 1 addition & 0 deletions consensus-types/interfaces/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//consensus-types/primitives:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//proto/prysm/v1alpha1/validator-client:go_default_library",
"@com_github_pkg_errors//:go_default_library",
3 changes: 3 additions & 0 deletions consensus-types/interfaces/beacon_block.go
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ package interfaces
import (
ssz "github.com/prysmaticlabs/fastssz"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
enginev1 "github.com/prysmaticlabs/prysm/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
"google.golang.org/protobuf/proto"
@@ -87,4 +88,6 @@ type ExecutionData interface {
BaseFeePerGas() []byte
BlockHash() []byte
Transactions() ([][]byte, error)
Withdrawals() ([]*enginev1.Withdrawal, error)
WithdrawalsRoot() ([]byte, error)
}
Loading