mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 05:47:59 -05:00
Compare commits
164 Commits
get-local-
...
capella-de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80c6fe9f65 | ||
|
|
ffbb73a59b | ||
|
|
649974f14d | ||
|
|
9ec0bc0734 | ||
|
|
b6a32c050f | ||
|
|
055e225093 | ||
|
|
144218cb1b | ||
|
|
13b575a609 | ||
|
|
b5a414eae9 | ||
|
|
b94b347ace | ||
|
|
f5ee225819 | ||
|
|
9cb48be14f | ||
|
|
ffcdc26618 | ||
|
|
96981a07b9 | ||
|
|
6b2721b239 | ||
|
|
911048aa6d | ||
|
|
255e9693ee | ||
|
|
d602c94b7b | ||
|
|
6a5ecbd68f | ||
|
|
29dfcab505 | ||
|
|
16e5c903cc | ||
|
|
66682cb4e5 | ||
|
|
cab42a4ae3 | ||
|
|
a5bdd42bdd | ||
|
|
a26197f919 | ||
|
|
080ce31395 | ||
|
|
d5d17e00b3 | ||
|
|
9c6a1331cf | ||
|
|
8629ac8417 | ||
|
|
6dcb2bbf0d | ||
|
|
deb138959a | ||
|
|
45e6f3bd00 | ||
|
|
55a9e0d51a | ||
|
|
3ddae600fb | ||
|
|
56503110dd | ||
|
|
f67d35dffd | ||
|
|
b05b67b264 | ||
|
|
a5c6518c20 | ||
|
|
da048395ce | ||
|
|
f31f7be310 | ||
|
|
e1a2267f86 | ||
|
|
3c9e4ee7f7 | ||
|
|
9ba32c9acd | ||
|
|
d23008452e | ||
|
|
f397cba1e0 | ||
|
|
1583e93b48 | ||
|
|
849457df81 | ||
|
|
903cab75ee | ||
|
|
ee108d4aff | ||
|
|
49bcc58762 | ||
|
|
a08baf4a14 | ||
|
|
8c56dfdd46 | ||
|
|
dcdd9af9db | ||
|
|
a464cf5c60 | ||
|
|
2d483ab09f | ||
|
|
6e26a6f128 | ||
|
|
b512b92a8a | ||
|
|
b0601580ef | ||
|
|
c1f29ea651 | ||
|
|
881d1d435a | ||
|
|
d1aae0c941 | ||
|
|
57bdb907cc | ||
|
|
15d683c78f | ||
|
|
bf6c8ced7d | ||
|
|
78fb685027 | ||
|
|
98c0b23350 | ||
|
|
039a0fffba | ||
|
|
90ec640e7a | ||
|
|
10acd31d25 | ||
|
|
df1e8b33d8 | ||
|
|
cdb4ee42cc | ||
|
|
d29baec77e | ||
|
|
0adc54b7ff | ||
|
|
1cbd7e9888 | ||
|
|
0a9e1658dd | ||
|
|
31d4a4cd11 | ||
|
|
fbc4e73d31 | ||
|
|
c1d4eaa79d | ||
|
|
760af6428e | ||
|
|
dfa0ccf626 | ||
|
|
1a51fdbd58 | ||
|
|
368a99ec8d | ||
|
|
1c7e734918 | ||
|
|
764d1325bf | ||
|
|
0cf30e9022 | ||
|
|
227b20f368 | ||
|
|
d7d70bc25b | ||
|
|
82f6ddb693 | ||
|
|
9e4e82d2c5 | ||
|
|
9838369fe9 | ||
|
|
6085ad1bfa | ||
|
|
d3851b27df | ||
|
|
d6100dfdcb | ||
|
|
c2144dac86 | ||
|
|
a47ff569a8 | ||
|
|
f8be022ef2 | ||
|
|
4f39e6b685 | ||
|
|
c67b000633 | ||
|
|
02f7443586 | ||
|
|
6275e7df4e | ||
|
|
1b6b52fda1 | ||
|
|
5fa1fd84b9 | ||
|
|
bd0c9f9e8d | ||
|
|
2532bb370c | ||
|
|
12efc6c2c1 | ||
|
|
a6cc9ac9c5 | ||
|
|
031f5845a2 | ||
|
|
b88559726c | ||
|
|
62f6b07cba | ||
|
|
f956f1ed6e | ||
|
|
16b0820193 | ||
|
|
4b02267e96 | ||
|
|
746584c453 | ||
|
|
b56daaaca2 | ||
|
|
931e5e10c3 | ||
|
|
c172f838b1 | ||
|
|
c07ae29cd9 | ||
|
|
214c9bfd8b | ||
|
|
716140d64d | ||
|
|
088cb4ef59 | ||
|
|
d1472fc351 | ||
|
|
5c8c0c31d8 | ||
|
|
7f3c00c7a2 | ||
|
|
c180dab791 | ||
|
|
f24acc21c7 | ||
|
|
40b637849d | ||
|
|
e7db1685df | ||
|
|
eccbfd1011 | ||
|
|
90211f6769 | ||
|
|
edc32ac18e | ||
|
|
fe68e020e3 | ||
|
|
81e1e3544d | ||
|
|
09372d5c35 | ||
|
|
078a89e4ca | ||
|
|
dbc6ae26a6 | ||
|
|
b6f429867a | ||
|
|
09f50660ce | ||
|
|
189825b495 | ||
|
|
764b7ff610 | ||
|
|
d499db7f0e | ||
|
|
ed2d1c7bf9 | ||
|
|
14b73cbd47 | ||
|
|
3124785a08 | ||
|
|
60e6306107 | ||
|
|
42ccb7830a | ||
|
|
0bb03b9292 | ||
|
|
ed6fbf1480 | ||
|
|
477cec6021 | ||
|
|
924500d111 | ||
|
|
0677504ef1 | ||
|
|
ca2a7c4d9c | ||
|
|
28606629ad | ||
|
|
c817279464 | ||
|
|
009d6ed8ed | ||
|
|
5cec1282a9 | ||
|
|
340170fd29 | ||
|
|
7ed0cc139a | ||
|
|
2c822213eb | ||
|
|
c08bb39ffe | ||
|
|
5083d8ab34 | ||
|
|
7552a5dd07 | ||
|
|
c93d68f853 | ||
|
|
3e8aa4023d | ||
|
|
b443875e66 |
10
WORKSPACE
10
WORKSPACE
@@ -188,7 +188,7 @@ filegroup(
|
||||
url = "https://github.com/eth-clients/slashing-protection-interchange-tests/archive/b8413ca42dc92308019d0d4db52c87e9e125c4e9.tar.gz",
|
||||
)
|
||||
|
||||
consensus_spec_version = "v1.3.0-alpha.2"
|
||||
consensus_spec_version = "v1.3.0-rc.0"
|
||||
|
||||
bls_test_version = "v0.1.1"
|
||||
|
||||
@@ -204,7 +204,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "a92c41058dc17ced811cc85570cd6f8af761aedfcbd2dd7dd4fb64ac961d76f9",
|
||||
#sha256 = "a92c41058dc17ced811cc85570cd6f8af761aedfcbd2dd7dd4fb64ac961d76f9",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -220,7 +220,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "49a7944da92429ac8f41347f19837762247cdbf00e628c285d1b826e58e4096d",
|
||||
#sha256 = "49a7944da92429ac8f41347f19837762247cdbf00e628c285d1b826e58e4096d",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -236,7 +236,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "d19673e9cd55e0c8d45eefc33b60978e14c166d0e891976fcaa114085312adcb",
|
||||
#sha256 = "d19673e9cd55e0c8d45eefc33b60978e14c166d0e891976fcaa114085312adcb",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -251,7 +251,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
sha256 = "a72b7457c403f6b76567d4d7bec19d01bedf7d5ef1d6f2c3a9e09ee86d401a14",
|
||||
#sha256 = "a72b7457c403f6b76567d4d7bec19d01bedf7d5ef1d6f2c3a9e09ee86d401a14",
|
||||
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
|
||||
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -68,6 +68,7 @@ func (s *Service) verifyBlkPreState(ctx context.Context, b interfaces.BeaconBloc
|
||||
// during initial syncing. There's no risk given a state summary object is just a
|
||||
// a subset of the block object.
|
||||
if !s.cfg.BeaconDB.HasStateSummary(ctx, parentRoot) && !s.cfg.BeaconDB.HasBlock(ctx, parentRoot) {
|
||||
log.Errorf("requesting blockroot %#x", bytesutil.Trunc(parentRoot[:]))
|
||||
return errors.New("could not reconstruct parent state")
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ func ProcessEpoch(ctx context.Context, state state.BeaconState) (state.BeaconSta
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
state, err = e.ProcessHistoricalRootsUpdate(state)
|
||||
state, err = e.ProcessHistoricalDataUpdate(state)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ func ValidatePayloadWhenMergeCompletes(st state.BeaconState, payload interfaces.
|
||||
return err
|
||||
}
|
||||
if !bytes.Equal(payload.ParentHash(), header.BlockHash()) {
|
||||
log.Errorf("parent Hash %#x, header Hash: %#x", bytesutil.Trunc(payload.ParentHash()), bytesutil.Trunc(header.BlockHash()))
|
||||
return ErrInvalidPayloadBlockHash
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -13,11 +13,14 @@ go_library(
|
||||
"//beacon-chain/core/time:go_default_library",
|
||||
"//beacon-chain/core/validators:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
"//math:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//proto/prysm/v1alpha1/attestation:go_default_library",
|
||||
"//runtime/version:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
],
|
||||
)
|
||||
@@ -33,8 +36,10 @@ go_test(
|
||||
deps = [
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/core/time:go_default_library",
|
||||
"//beacon-chain/core/transition:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//beacon-chain/state/state-native:go_default_library",
|
||||
"//beacon-chain/state/stateutil:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//consensus-types/primitives:go_default_library",
|
||||
|
||||
@@ -14,11 +14,14 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/validators"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/math"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1/attestation"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
)
|
||||
|
||||
// sortableIndices implements the Sort interface to sort newly activated validator indices
|
||||
@@ -349,33 +352,39 @@ func ProcessRandaoMixesReset(state state.BeaconState) (state.BeaconState, error)
|
||||
return state, nil
|
||||
}
|
||||
|
||||
// ProcessHistoricalRootsUpdate processes the updates to historical root accumulator during epoch processing.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
//
|
||||
// def process_historical_roots_update(state: BeaconState) -> None:
|
||||
// # Set historical root accumulator
|
||||
// next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
// if next_epoch % (SLOTS_PER_HISTORICAL_ROOT // SLOTS_PER_EPOCH) == 0:
|
||||
// historical_batch = HistoricalBatch(block_roots=state.block_roots, state_roots=state.state_roots)
|
||||
// state.historical_roots.append(hash_tree_root(historical_batch))
|
||||
func ProcessHistoricalRootsUpdate(state state.BeaconState) (state.BeaconState, error) {
|
||||
// ProcessHistoricalDataUpdate processes the updates to historical data during epoch processing.
|
||||
// For Capella state, per spec, historical summaries is updated instead of historical roots.
|
||||
func ProcessHistoricalDataUpdate(state state.BeaconState) (state.BeaconState, error) {
|
||||
currentEpoch := time.CurrentEpoch(state)
|
||||
nextEpoch := currentEpoch + 1
|
||||
|
||||
// Set historical root accumulator.
|
||||
epochsPerHistoricalRoot := params.BeaconConfig().SlotsPerHistoricalRoot.DivSlot(params.BeaconConfig().SlotsPerEpoch)
|
||||
if nextEpoch.Mod(uint64(epochsPerHistoricalRoot)) == 0 {
|
||||
historicalBatch := ðpb.HistoricalBatch{
|
||||
BlockRoots: state.BlockRoots(),
|
||||
StateRoots: state.StateRoots(),
|
||||
}
|
||||
batchRoot, err := historicalBatch.HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not hash historical batch")
|
||||
}
|
||||
if err := state.AppendHistoricalRoots(batchRoot); err != nil {
|
||||
return nil, err
|
||||
if state.Version() >= version.Capella {
|
||||
br, err := stateutil.ArraysRoot(state.BlockRoots(), fieldparams.BlockRootsLength)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sr, err := stateutil.ArraysRoot(state.StateRoots(), fieldparams.StateRootsLength)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := state.AppendHistoricalSummariesUpdate(ðpb.HistoricalSummary{BlockSummaryRoot: br[:], StateSummaryRoot: sr[:]}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
historicalBatch := ðpb.HistoricalBatch{
|
||||
BlockRoots: state.BlockRoots(),
|
||||
StateRoots: state.StateRoots(),
|
||||
}
|
||||
batchRoot, err := historicalBatch.HashTreeRoot()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not hash historical batch")
|
||||
}
|
||||
if err := state.AppendHistoricalRoots(batchRoot); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +435,7 @@ func ProcessFinalUpdates(state state.BeaconState) (state.BeaconState, error) {
|
||||
}
|
||||
|
||||
// Set historical root accumulator.
|
||||
state, err = ProcessHistoricalRootsUpdate(state)
|
||||
state, err = ProcessHistoricalDataUpdate(state)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/epoch"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
state_native "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
@@ -455,3 +457,71 @@ func TestProcessSlashings_BadValue(t *testing.T) {
|
||||
_, err = epoch.ProcessSlashings(s, params.BeaconConfig().ProportionalSlashingMultiplier)
|
||||
require.ErrorContains(t, "addition overflows", err)
|
||||
}
|
||||
|
||||
func TestProcessHistoricalRootsUpdate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
st func() state.BeaconState
|
||||
verifier func(state.BeaconState)
|
||||
}{
|
||||
{
|
||||
name: "no change",
|
||||
st: func() state.BeaconState {
|
||||
st, _ := util.DeterministicGenesisState(t, 1)
|
||||
return st
|
||||
},
|
||||
verifier: func(st state.BeaconState) {
|
||||
require.Equal(t, 0, len(st.HistoricalRoots()))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "before capella can process and get historical root",
|
||||
st: func() state.BeaconState {
|
||||
st, _ := util.DeterministicGenesisState(t, 1)
|
||||
st, err := transition.ProcessSlots(context.Background(), st, params.BeaconConfig().SlotsPerHistoricalRoot-1)
|
||||
require.NoError(t, err)
|
||||
return st
|
||||
},
|
||||
verifier: func(st state.BeaconState) {
|
||||
require.Equal(t, 1, len(st.HistoricalRoots()))
|
||||
|
||||
b := ðpb.HistoricalBatch{
|
||||
BlockRoots: st.BlockRoots(),
|
||||
StateRoots: st.StateRoots(),
|
||||
}
|
||||
r, err := b.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, r[:], st.HistoricalRoots()[0])
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "after capella can process and get historical summary",
|
||||
st: func() state.BeaconState {
|
||||
st, _ := util.DeterministicGenesisStateCapella(t, 1)
|
||||
st, err := transition.ProcessSlots(context.Background(), st, params.BeaconConfig().SlotsPerHistoricalRoot-1)
|
||||
require.NoError(t, err)
|
||||
return st
|
||||
},
|
||||
verifier: func(st state.BeaconState) {
|
||||
require.Equal(t, 1, len(st.HistoricalSummaries()))
|
||||
|
||||
br, err := stateutil.ArraysRoot(st.BlockRoots(), fieldparams.BlockRootsLength)
|
||||
require.NoError(t, err)
|
||||
sr, err := stateutil.ArraysRoot(st.StateRoots(), fieldparams.StateRootsLength)
|
||||
require.NoError(t, err)
|
||||
b := ðpb.HistoricalSummary{
|
||||
BlockSummaryRoot: br[:],
|
||||
StateSummaryRoot: sr[:],
|
||||
}
|
||||
require.DeepEqual(t, b, st.HistoricalSummaries()[0])
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := epoch.ProcessHistoricalDataUpdate(tt.st())
|
||||
require.NoError(t, err)
|
||||
tt.verifier(got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ func TestClient_IPC(t *testing.T) {
|
||||
want, ok := fix["ExecutionBlock"].(*pb.ExecutionBlock)
|
||||
require.Equal(t, true, ok)
|
||||
arg := common.BytesToHash([]byte("foo"))
|
||||
resp, err := srv.ExecutionBlockByHash(ctx, arg, true /* with txs */)
|
||||
resp, err := srv.ExecutionBlockByHash(ctx, version.Bellatrix, arg, true /* with txs */)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, want, resp)
|
||||
})
|
||||
@@ -618,7 +618,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
service.rpcClient = rpcClient
|
||||
|
||||
// We call the RPC method via HTTP and expect a proper result.
|
||||
resp, err := service.ExecutionBlockByHash(ctx, arg, true /* with txs */)
|
||||
resp, err := service.ExecutionBlockByHash(ctx, version.Bellatrix, arg, true /* with txs */)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, want, resp)
|
||||
})
|
||||
|
||||
@@ -1195,3 +1195,555 @@ func TestSubmitBlindedBlock(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_GetBlindedBlockSSZ(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocks(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBeaconBlock()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
wsb, err := blocks.NewSignedBeaconBlock(headBlock.Block.(*ethpbalpha.BeaconBlockContainer_Phase0Block).Phase0Block)
|
||||
require.NoError(t, err)
|
||||
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: wsb,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_PHASE0, resp.Version)
|
||||
})
|
||||
|
||||
t.Run("Altair", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocksAltair(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBeaconBlockAltair()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetAltairBlock())
|
||||
require.NoError(t, err)
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_ALTAIR, resp.Version)
|
||||
})
|
||||
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocksBellatrixBlinded(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBlindedBeaconBlockBellatrix()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetBlindedBellatrixBlock())
|
||||
require.NoError(t, err)
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
OptimisticModeFetcher: &mock.ChainService{},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_BELLATRIX, resp.Version)
|
||||
})
|
||||
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
_, blkContainers := fillDBTestBlocksCapellaBlinded(ctx, t, beaconDB)
|
||||
headBlock := blkContainers[len(blkContainers)-1]
|
||||
|
||||
b2 := util.NewBlindedBeaconBlockCapella()
|
||||
b2.Block.Slot = 30
|
||||
b2.Block.ParentRoot = bytesutil.PadTo([]byte{1}, 32)
|
||||
util.SaveBlock(t, ctx, beaconDB, b2)
|
||||
|
||||
chainBlk, err := blocks.NewSignedBeaconBlock(headBlock.GetBlindedCapellaBlock())
|
||||
require.NoError(t, err)
|
||||
bs := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
ChainInfoFetcher: &mock.ChainService{
|
||||
DB: beaconDB,
|
||||
Block: chainBlk,
|
||||
Root: headBlock.BlockRoot,
|
||||
FinalizedCheckPoint: ðpbalpha.Checkpoint{Root: blkContainers[64].BlockRoot},
|
||||
},
|
||||
OptimisticModeFetcher: &mock.ChainService{},
|
||||
}
|
||||
|
||||
blks, err := beaconDB.BlocksBySlot(ctx, 30)
|
||||
require.Equal(t, true, len(blks) > 0)
|
||||
require.NoError(t, err)
|
||||
sszBlock, err := blks[0].MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
|
||||
resp, err := bs.GetBlindedBlockSSZ(ctx, ðpbv1.BlockRequest{BlockId: []byte("30")})
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, resp)
|
||||
assert.DeepEqual(t, sszBlock, resp.Data)
|
||||
assert.Equal(t, ethpbv2.Version_CAPELLA, resp.Version)
|
||||
})
|
||||
}
|
||||
|
||||
func TestServer_SubmitBlindedBlockSSZ_OK(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlock()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
HeadFetcher: c,
|
||||
}
|
||||
req := util.NewBeaconBlock()
|
||||
req.Block.Slot = 5
|
||||
req.Block.ParentRoot = bsRoot[:]
|
||||
util.SaveBlock(t, ctx, beaconDB, req)
|
||||
blockSsz, err := req.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
blockReq := ðpbv2.SSZContainer{
|
||||
Data: blockSsz,
|
||||
}
|
||||
md := metadata.MD{}
|
||||
md.Set(versionHeader, "phase0")
|
||||
sszCtx := metadata.NewIncomingContext(ctx, md)
|
||||
_, err = beaconChainServer.SubmitBlindedBlockSSZ(sszCtx, blockReq)
|
||||
assert.NoError(t, err, "Could not propose block correctly")
|
||||
})
|
||||
|
||||
t.Run("Altair", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlockAltair()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
HeadFetcher: c,
|
||||
}
|
||||
req := util.NewBeaconBlockAltair()
|
||||
req.Block.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().AltairForkEpoch))
|
||||
req.Block.ParentRoot = bsRoot[:]
|
||||
util.SaveBlock(t, ctx, beaconDB, req)
|
||||
blockSsz, err := req.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
blockReq := ðpbv2.SSZContainer{
|
||||
Data: blockSsz,
|
||||
}
|
||||
md := metadata.MD{}
|
||||
md.Set(versionHeader, "altair")
|
||||
sszCtx := metadata.NewIncomingContext(ctx, md)
|
||||
_, err = beaconChainServer.SubmitBlindedBlockSSZ(sszCtx, blockReq)
|
||||
assert.NoError(t, err, "Could not propose block correctly")
|
||||
})
|
||||
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
// INFO: This code block can be removed once Bellatrix
|
||||
// fork epoch is set to a value other than math.MaxUint64
|
||||
params.SetupTestConfigCleanup(t)
|
||||
cfg := params.BeaconConfig()
|
||||
cfg.BellatrixForkEpoch = cfg.AltairForkEpoch + 1000
|
||||
cfg.ForkVersionSchedule[bytesutil.ToBytes4(cfg.BellatrixForkVersion)] = cfg.AltairForkEpoch + 1000
|
||||
params.OverrideBeaconConfig(cfg)
|
||||
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlockBellatrix()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
alphaServer := &validator.Server{
|
||||
SyncCommitteePool: synccommittee.NewStore(),
|
||||
P2P: &mockp2p.MockBroadcaster{},
|
||||
BlockBuilder: &builderTest.MockBuilderService{},
|
||||
BlockReceiver: c,
|
||||
BlockNotifier: &mock.MockBlockNotifier{},
|
||||
}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
HeadFetcher: c,
|
||||
V1Alpha1ValidatorServer: alphaServer,
|
||||
}
|
||||
req := util.NewBlindedBeaconBlockBellatrix()
|
||||
req.Block.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().BellatrixForkEpoch))
|
||||
req.Block.ParentRoot = bsRoot[:]
|
||||
util.SaveBlock(t, ctx, beaconDB, req)
|
||||
blockSsz, err := req.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
blockReq := ðpbv2.SSZContainer{
|
||||
Data: blockSsz,
|
||||
}
|
||||
md := metadata.MD{}
|
||||
md.Set(versionHeader, "bellatrix")
|
||||
sszCtx := metadata.NewIncomingContext(ctx, md)
|
||||
_, err = beaconChainServer.SubmitBlindedBlockSSZ(sszCtx, blockReq)
|
||||
assert.NoError(t, err, "Could not propose block correctly")
|
||||
})
|
||||
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
t.Skip("This test needs Capella fork version configured properly")
|
||||
|
||||
// INFO: This code block can be removed once Capella
|
||||
// fork epoch is set to a value other than math.MaxUint64
|
||||
params.SetupTestConfigCleanup(t)
|
||||
cfg := params.BeaconConfig()
|
||||
cfg.CapellaForkEpoch = cfg.BellatrixForkEpoch + 1000
|
||||
cfg.ForkVersionSchedule[bytesutil.ToBytes4(cfg.CapellaForkVersion)] = cfg.BellatrixForkEpoch + 1000
|
||||
params.OverrideBeaconConfig(cfg)
|
||||
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlockCapella()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
alphaServer := &validator.Server{
|
||||
SyncCommitteePool: synccommittee.NewStore(),
|
||||
P2P: &mockp2p.MockBroadcaster{},
|
||||
BlockBuilder: &builderTest.MockBuilderService{},
|
||||
BlockReceiver: c,
|
||||
BlockNotifier: &mock.MockBlockNotifier{},
|
||||
}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
HeadFetcher: c,
|
||||
V1Alpha1ValidatorServer: alphaServer,
|
||||
}
|
||||
req := util.NewBlindedBeaconBlockCapella()
|
||||
req.Block.Slot = params.BeaconConfig().SlotsPerEpoch.Mul(uint64(params.BeaconConfig().CapellaForkEpoch))
|
||||
req.Block.ParentRoot = bsRoot[:]
|
||||
util.SaveBlock(t, ctx, beaconDB, req)
|
||||
blockSsz, err := req.MarshalSSZ()
|
||||
require.NoError(t, err)
|
||||
blockReq := ðpbv2.SSZContainer{
|
||||
Data: blockSsz,
|
||||
}
|
||||
md := metadata.MD{}
|
||||
md.Set(versionHeader, "capella")
|
||||
sszCtx := metadata.NewIncomingContext(ctx, md)
|
||||
_, err = beaconChainServer.SubmitBlindedBlockSSZ(sszCtx, blockReq)
|
||||
assert.NoError(t, err, "Could not propose block correctly")
|
||||
})
|
||||
}
|
||||
|
||||
func TestSubmitBlindedBlock(t *testing.T) {
|
||||
t.Run("Phase 0", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlock()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
}
|
||||
req := util.NewBeaconBlock()
|
||||
req.Block.Slot = 5
|
||||
req.Block.ParentRoot = bsRoot[:]
|
||||
v1Block, err := migration.V1Alpha1ToV1SignedBlock(req)
|
||||
require.NoError(t, err)
|
||||
util.SaveBlock(t, ctx, beaconDB, req)
|
||||
blockReq := ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_Phase0Block{Phase0Block: v1Block.Block},
|
||||
Signature: v1Block.Signature,
|
||||
}
|
||||
_, err = beaconChainServer.SubmitBlindedBlock(context.Background(), blockReq)
|
||||
assert.NoError(t, err, "Could not propose block correctly")
|
||||
})
|
||||
|
||||
t.Run("Altair", func(t *testing.T) {
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlockAltair()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
}
|
||||
req := util.NewBeaconBlockAltair()
|
||||
req.Block.Slot = 5
|
||||
req.Block.ParentRoot = bsRoot[:]
|
||||
v2Block, err := migration.V1Alpha1BeaconBlockAltairToV2(req.Block)
|
||||
require.NoError(t, err)
|
||||
util.SaveBlock(t, ctx, beaconDB, req)
|
||||
blockReq := ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_AltairBlock{AltairBlock: v2Block},
|
||||
Signature: req.Signature,
|
||||
}
|
||||
_, err = beaconChainServer.SubmitBlindedBlock(context.Background(), blockReq)
|
||||
assert.NoError(t, err, "Could not propose block correctly")
|
||||
})
|
||||
|
||||
t.Run("Bellatrix", func(t *testing.T) {
|
||||
transactions := [][]byte{[]byte("transaction1"), []byte("transaction2")}
|
||||
transactionsRoot, err := ssz.TransactionsRoot(transactions)
|
||||
require.NoError(t, err)
|
||||
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlockBellatrix()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
alphaServer := &validator.Server{
|
||||
SyncCommitteePool: synccommittee.NewStore(),
|
||||
P2P: &mockp2p.MockBroadcaster{},
|
||||
BlockBuilder: &builderTest.MockBuilderService{},
|
||||
BlockReceiver: c,
|
||||
BlockNotifier: &mock.MockBlockNotifier{},
|
||||
}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
V1Alpha1ValidatorServer: alphaServer,
|
||||
}
|
||||
|
||||
blk := util.NewBeaconBlockBellatrix()
|
||||
blk.Block.Slot = 5
|
||||
blk.Block.ParentRoot = bsRoot[:]
|
||||
blk.Block.Body.ExecutionPayload.Transactions = transactions
|
||||
blindedBlk := util.NewBlindedBeaconBlockBellatrixV2()
|
||||
blindedBlk.Message.Slot = 5
|
||||
blindedBlk.Message.ParentRoot = bsRoot[:]
|
||||
blindedBlk.Message.Body.ExecutionPayloadHeader.TransactionsRoot = transactionsRoot[:]
|
||||
util.SaveBlock(t, ctx, beaconDB, blk)
|
||||
|
||||
blockReq := ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_BellatrixBlock{BellatrixBlock: blindedBlk.Message},
|
||||
Signature: blindedBlk.Signature,
|
||||
}
|
||||
_, err = beaconChainServer.SubmitBlindedBlock(context.Background(), blockReq)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Capella", func(t *testing.T) {
|
||||
transactions := [][]byte{[]byte("transaction1"), []byte("transaction2")}
|
||||
transactionsRoot, err := ssz.TransactionsRoot(transactions)
|
||||
require.NoError(t, err)
|
||||
|
||||
withdrawals := []*enginev1.Withdrawal{
|
||||
{
|
||||
Index: 1,
|
||||
ValidatorIndex: 1,
|
||||
Address: bytesutil.PadTo([]byte("address1"), 20),
|
||||
Amount: 1,
|
||||
},
|
||||
{
|
||||
Index: 2,
|
||||
ValidatorIndex: 2,
|
||||
Address: bytesutil.PadTo([]byte("address2"), 20),
|
||||
Amount: 2,
|
||||
},
|
||||
}
|
||||
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(hash.CustomSHA256Hasher(), withdrawals, 16)
|
||||
require.NoError(t, err)
|
||||
|
||||
beaconDB := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
genesis := util.NewBeaconBlockCapella()
|
||||
util.SaveBlock(t, context.Background(), beaconDB, genesis)
|
||||
|
||||
numDeposits := uint64(64)
|
||||
beaconState, _ := util.DeterministicGenesisState(t, numDeposits)
|
||||
bsRoot, err := beaconState.HashTreeRoot(ctx)
|
||||
require.NoError(t, err)
|
||||
genesisRoot, err := genesis.Block.HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconDB.SaveState(ctx, beaconState, genesisRoot), "Could not save genesis state")
|
||||
|
||||
c := &mock.ChainService{Root: bsRoot[:], State: beaconState}
|
||||
alphaServer := &validator.Server{
|
||||
SyncCommitteePool: synccommittee.NewStore(),
|
||||
P2P: &mockp2p.MockBroadcaster{},
|
||||
BlockBuilder: &builderTest.MockBuilderService{},
|
||||
BlockReceiver: c,
|
||||
BlockNotifier: &mock.MockBlockNotifier{},
|
||||
}
|
||||
beaconChainServer := &Server{
|
||||
BeaconDB: beaconDB,
|
||||
BlockReceiver: c,
|
||||
ChainInfoFetcher: c,
|
||||
BlockNotifier: c.BlockNotifier(),
|
||||
Broadcaster: mockp2p.NewTestP2P(t),
|
||||
V1Alpha1ValidatorServer: alphaServer,
|
||||
}
|
||||
|
||||
blk := util.NewBeaconBlockCapella()
|
||||
blk.Block.Slot = 5
|
||||
blk.Block.ParentRoot = bsRoot[:]
|
||||
blk.Block.Body.ExecutionPayload.Transactions = transactions
|
||||
blk.Block.Body.ExecutionPayload.Withdrawals = withdrawals
|
||||
blindedBlk := util.NewBlindedBeaconBlockCapellaV2()
|
||||
blindedBlk.Message.Slot = 5
|
||||
blindedBlk.Message.ParentRoot = bsRoot[:]
|
||||
blindedBlk.Message.Body.ExecutionPayloadHeader.TransactionsRoot = transactionsRoot[:]
|
||||
blindedBlk.Message.Body.ExecutionPayloadHeader.WithdrawalsRoot = withdrawalsRoot[:]
|
||||
util.SaveBlock(t, ctx, beaconDB, blk)
|
||||
|
||||
blockReq := ðpbv2.SignedBlindedBeaconBlockContainer{
|
||||
Message: ðpbv2.SignedBlindedBeaconBlockContainer_CapellaBlock{CapellaBlock: blindedBlk.Message},
|
||||
Signature: blindedBlk.Signature,
|
||||
}
|
||||
_, err = beaconChainServer.SubmitBlindedBlock(context.Background(), blockReq)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -383,6 +383,7 @@ func (bs *Server) GetBlockV2(ctx context.Context, req *ethpbv2.BlockRequestV2) (
|
||||
if !errors.Is(err, blocks.ErrUnsupportedGetter) {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get signed beacon block: %v", err)
|
||||
}
|
||||
|
||||
return nil, status.Errorf(codes.Internal, "Unknown block type %T", blk)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ go_library(
|
||||
"//beacon-chain/core/helpers:go_default_library",
|
||||
"//beacon-chain/db/kv:go_default_library",
|
||||
"//beacon-chain/operations/attestations:go_default_library",
|
||||
"//beacon-chain/operations/blstoexec:go_default_library",
|
||||
"//beacon-chain/operations/synccommittee:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/rpc/eth/helpers:go_default_library",
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/cache"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/attestations"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/blstoexec"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/synccommittee"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p"
|
||||
v1alpha1validator "github.com/prysmaticlabs/prysm/v3/beacon-chain/rpc/prysm/v1alpha1/validator"
|
||||
@@ -24,6 +25,7 @@ type Server struct {
|
||||
StateFetcher statefetcher.Fetcher
|
||||
OptimisticModeFetcher blockchain.OptimisticModeFetcher
|
||||
SyncCommitteePool synccommittee.Pool
|
||||
BLSChangesPool blstoexec.PoolManager
|
||||
V1Alpha1Server *v1alpha1validator.Server
|
||||
ProposerSlotIndexCache *cache.ProposerPayloadIDsCache
|
||||
}
|
||||
|
||||
@@ -500,16 +500,9 @@ func (vs *Server) ProduceBlindedBlock(ctx context.Context, req *ethpbv1.ProduceB
|
||||
if optimistic {
|
||||
return nil, status.Errorf(codes.Unavailable, "The node is currently optimistic and cannot serve validators")
|
||||
}
|
||||
altairBlk, err := vs.V1Alpha1Server.BuildAltairBeaconBlock(ctx, v1alpha1req)
|
||||
b, err := vs.V1Alpha1Server.GetBeaconBlock(ctx, v1alpha1req)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not prepare beacon block: %v", err)
|
||||
}
|
||||
ok, b, err := vs.V1Alpha1Server.GetAndBuildBlindBlock(ctx, altairBlk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not prepare blind beacon block: %v", err)
|
||||
}
|
||||
if !ok {
|
||||
return nil, status.Error(codes.Unavailable, "Builder is not available due to miss-config or circuit breaker")
|
||||
return nil, err
|
||||
}
|
||||
blk, err := migration.V1Alpha1BeaconBlockBlindedBellatrixToV2Blinded(b.GetBlindedBellatrix())
|
||||
if err != nil {
|
||||
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
"assignments.go",
|
||||
"attestations.go",
|
||||
"blocks.go",
|
||||
"blstoexec.go",
|
||||
"committees.go",
|
||||
"config.go",
|
||||
"log.go",
|
||||
@@ -36,6 +37,7 @@ go_library(
|
||||
"//beacon-chain/db/filters:go_default_library",
|
||||
"//beacon-chain/execution:go_default_library",
|
||||
"//beacon-chain/operations/attestations:go_default_library",
|
||||
"//beacon-chain/operations/blstoexec:go_default_library",
|
||||
"//beacon-chain/operations/slashings:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
"//beacon-chain/state:go_default_library",
|
||||
|
||||
24
beacon-chain/rpc/prysm/v1alpha1/beacon/blstoexec.go
Normal file
24
beacon-chain/rpc/prysm/v1alpha1/beacon/blstoexec.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package beacon
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// SubmitBLSToExecutionChange receives a withdrawal credential change object via
|
||||
// RPC and injects it into the beacon node's operations pool.
|
||||
// Submission into this pool does not guarantee inclusion into a beacon block. If the object passes validation
|
||||
// the node MUST broadcast it
|
||||
func (bs *Server) SubmitBLSToExecutionChange(
|
||||
ctx context.Context,
|
||||
req *ethpb.SignedBLSToExecutionChange,
|
||||
) (*ethpb.BLSToExecutionChangeResponse, error) {
|
||||
bs.BLSChangesPool.InsertBLSToExecChange(req)
|
||||
if err := bs.Broadcaster.Broadcast(ctx, req); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not broadcast SigledBLSToExecutionChange object: %v", err)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/db"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/execution"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/attestations"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/blstoexec"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/slashings"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/p2p"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stategen"
|
||||
@@ -40,6 +41,7 @@ type Server struct {
|
||||
Broadcaster p2p.Broadcaster
|
||||
AttestationsPool attestations.Pool
|
||||
SlashingsPool slashings.PoolManager
|
||||
BLSChangesPool blstoexec.PoolManager
|
||||
ChainStartChan chan time.Time
|
||||
ReceivedAttestationsBuffer chan *ethpb.Attestation
|
||||
CollectedAttestationsBuffer chan []*ethpb.Attestation
|
||||
|
||||
@@ -19,7 +19,6 @@ go_library(
|
||||
"proposer_eth1data.go",
|
||||
"proposer_execution_payload.go",
|
||||
"proposer_exits.go",
|
||||
"proposer_phase0.go",
|
||||
"proposer_slashings.go",
|
||||
"proposer_sync_aggregate.go",
|
||||
"server.go",
|
||||
@@ -51,6 +50,7 @@ go_library(
|
||||
"//beacon-chain/execution:go_default_library",
|
||||
"//beacon-chain/operations/attestations:go_default_library",
|
||||
"//beacon-chain/operations/slashings:go_default_library",
|
||||
"//beacon-chain/operations/blstoexec:go_default_library",
|
||||
"//beacon-chain/operations/synccommittee:go_default_library",
|
||||
"//beacon-chain/operations/voluntaryexits:go_default_library",
|
||||
"//beacon-chain/p2p:go_default_library",
|
||||
|
||||
@@ -89,6 +89,17 @@ func sendVerifiedBlocks(stream ethpb.BeaconNodeValidator_StreamBlocksAltairServe
|
||||
return nil
|
||||
}
|
||||
b.Block = ðpb.StreamBlocksResponse_BellatrixBlock{BellatrixBlock: phBlk}
|
||||
case version.Capella:
|
||||
pb, err := data.SignedBlock.Proto()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get protobuf block")
|
||||
}
|
||||
phBlk, ok := pb.(*ethpb.SignedBeaconBlockCapella)
|
||||
if !ok {
|
||||
log.Warn("Mismatch between version and block type, was expecting SignedBeaconBlockCapella")
|
||||
return nil
|
||||
}
|
||||
b.Block = ðpb.StreamBlocksResponse_CapellaBlock{CapellaBlock: phBlk}
|
||||
}
|
||||
|
||||
if err := stream.Send(b); err != nil {
|
||||
@@ -136,6 +147,8 @@ func (vs *Server) sendBlocks(stream ethpb.BeaconNodeValidator_StreamBlocksAltair
|
||||
b.Block = ðpb.StreamBlocksResponse_AltairBlock{AltairBlock: p}
|
||||
case *ethpb.SignedBeaconBlockBellatrix:
|
||||
b.Block = ðpb.StreamBlocksResponse_BellatrixBlock{BellatrixBlock: p}
|
||||
case *ethpb.SignedBeaconBlockCapella:
|
||||
b.Block = ðpb.StreamBlocksResponse_CapellaBlock{CapellaBlock: p}
|
||||
default:
|
||||
log.Errorf("Unknown block type %T", p)
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/builder"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/feed"
|
||||
blockfeed "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/feed/block"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/db/kv"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
@@ -35,32 +37,186 @@ var eth1DataNotification bool
|
||||
const eth1dataTimeout = 2 * time.Second
|
||||
|
||||
// GetBeaconBlock is called by a proposer during its assigned slot to request a block to sign
|
||||
// by passing in the slot and the signed randao reveal of the slot. Returns phase0 beacon blocks
|
||||
// before the Altair fork epoch and Altair blocks post-fork epoch.
|
||||
// by passing in the slot and the signed randao reveal of the slot. Returns a full block
|
||||
// corresponding to the fork epoch
|
||||
func (vs *Server) GetBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.GetBeaconBlock")
|
||||
defer span.End()
|
||||
span.AddAttributes(trace.Int64Attribute("slot", int64(req.Slot)))
|
||||
if slots.ToEpoch(req.Slot) < params.BeaconConfig().AltairForkEpoch {
|
||||
blk, err := vs.getPhase0BeaconBlock(ctx, req)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not fetch phase0 beacon block: %v", err)
|
||||
}
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Phase0{Phase0: blk}}, nil
|
||||
} else if slots.ToEpoch(req.Slot) < params.BeaconConfig().BellatrixForkEpoch {
|
||||
blk, err := vs.getAltairBeaconBlock(ctx, req)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not fetch Altair beacon block: %v", err)
|
||||
}
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Altair{Altair: blk}}, nil
|
||||
|
||||
// A syncing validator should not produce a block.
|
||||
if vs.SyncChecker.Syncing() {
|
||||
return nil, status.Error(codes.Unavailable, "Syncing to latest head, not ready to respond")
|
||||
}
|
||||
|
||||
// An optimistic validator MUST NOT produce a block (i.e., sign across the DOMAIN_BEACON_PROPOSER domain).
|
||||
if err := vs.optimisticStatus(ctx); err != nil {
|
||||
return nil, err
|
||||
return nil, status.Errorf(codes.Unavailable, "Validator is not ready to propose: %v", err)
|
||||
}
|
||||
|
||||
return vs.getBellatrixBeaconBlock(ctx, req)
|
||||
sBlk, err := emptyBlockToSign(req.Slot)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not prepare block: %v", err)
|
||||
}
|
||||
|
||||
parentRoot, err := vs.HeadFetcher.HeadRoot(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get head root: %v", err)
|
||||
}
|
||||
head, err := vs.HeadFetcher.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
|
||||
}
|
||||
head, err = transition.ProcessSlotsUsingNextSlotCache(ctx, head, parentRoot, req.Slot)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not process slots up to %d: %v", req.Slot, err)
|
||||
}
|
||||
|
||||
blk := sBlk.Block()
|
||||
// Set slot, graffiti, randao reveal, and parent root.
|
||||
blk.SetSlot(req.Slot)
|
||||
blk.Body().SetGraffiti(req.Graffiti)
|
||||
blk.Body().SetRandaoReveal(req.RandaoReveal)
|
||||
blk.SetParentRoot(parentRoot)
|
||||
|
||||
// Set eth1 data.
|
||||
eth1Data, err := vs.eth1DataMajorityVote(ctx, head)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not get eth1data")
|
||||
} else {
|
||||
blk.Body().SetEth1Data(eth1Data)
|
||||
|
||||
// Set deposit and attestation.
|
||||
deposits, atts, err := vs.packDepositsAndAttestations(ctx, head, eth1Data) // TODO: split attestations and deposits
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not pack deposits and attestations")
|
||||
} else {
|
||||
blk.Body().SetDeposits(deposits)
|
||||
blk.Body().SetAttestations(atts)
|
||||
}
|
||||
}
|
||||
|
||||
// Set proposer index
|
||||
idx, err := helpers.BeaconProposerIndex(ctx, head)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not calculate proposer index %v", err)
|
||||
}
|
||||
blk.SetProposerIndex(idx)
|
||||
|
||||
// Set slashings
|
||||
validProposerSlashings, validAttSlashings := vs.getSlashings(ctx, head)
|
||||
blk.Body().SetProposerSlashings(validProposerSlashings)
|
||||
blk.Body().SetAttesterSlashings(validAttSlashings)
|
||||
|
||||
// Set exits
|
||||
blk.Body().SetVoluntaryExits(vs.getExits(head, req.Slot))
|
||||
|
||||
// Set sync aggregate. New in Altair.
|
||||
if req.Slot > 0 && slots.ToEpoch(req.Slot) >= params.BeaconConfig().AltairForkEpoch {
|
||||
syncAggregate, err := vs.getSyncAggregate(ctx, req.Slot-1, bytesutil.ToBytes32(parentRoot))
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not get sync aggregate")
|
||||
} else {
|
||||
if err := blk.Body().SetSyncAggregate(syncAggregate); err != nil {
|
||||
log.WithError(err).Error("Could not set sync aggregate")
|
||||
if err := blk.Body().SetSyncAggregate(ðpb.SyncAggregate{
|
||||
SyncCommitteeBits: make([]byte, params.BeaconConfig().SyncCommitteeSize),
|
||||
SyncCommitteeSignature: make([]byte, fieldparams.BLSSignatureLength),
|
||||
}); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not set default sync aggregate: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set execution data. New in Bellatrix
|
||||
if slots.ToEpoch(req.Slot) >= params.BeaconConfig().BellatrixForkEpoch {
|
||||
fallBackToLocal := true
|
||||
canUseBuilder, err := vs.canUseBuilder(ctx, req.Slot, idx)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Proposer: failed to check if builder can be used")
|
||||
} else if canUseBuilder {
|
||||
h, err := vs.getPayloadHeaderFromBuilder(ctx, req.Slot, idx)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Proposer: failed to get payload header from builder")
|
||||
} else {
|
||||
blk.SetBlinded(true)
|
||||
if err := blk.Body().SetExecution(h); err != nil {
|
||||
log.WithError(err).Warn("Proposer: failed to set execution payload")
|
||||
} else {
|
||||
fallBackToLocal = false
|
||||
}
|
||||
}
|
||||
}
|
||||
if fallBackToLocal {
|
||||
executionData, err := vs.getExecutionPayload(ctx, req.Slot, idx, bytesutil.ToBytes32(parentRoot), head)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not get execution payload: %v", err)
|
||||
}
|
||||
if err := blk.Body().SetExecution(executionData); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not set execution payload: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set bls to execution change. New in Capella
|
||||
if slots.ToEpoch(req.Slot) >= params.BeaconConfig().CapellaForkEpoch {
|
||||
changes, err := vs.BLSChangesPool.BLSToExecChangesForInclusion(head)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Could not get bls to execution changes")
|
||||
} else {
|
||||
if err := blk.Body().SetBLSToExecutionChanges(changes); err != nil {
|
||||
log.WithError(err).Error("Could not set bls to execution changes")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sr, err := vs.computeStateRoot(ctx, sBlk)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not compute state root: %v", err)
|
||||
}
|
||||
blk.SetStateRoot(sr)
|
||||
|
||||
pb, err := blk.Proto()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not convert block to proto: %v", err)
|
||||
}
|
||||
if slots.ToEpoch(req.Slot) >= params.BeaconConfig().CapellaForkEpoch {
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Capella{Capella: pb.(*ethpb.BeaconBlockCapella)}}, nil
|
||||
} else if slots.ToEpoch(req.Slot) >= params.BeaconConfig().BellatrixForkEpoch {
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Bellatrix{Bellatrix: pb.(*ethpb.BeaconBlockBellatrix)}}, nil
|
||||
} else if slots.ToEpoch(req.Slot) >= params.BeaconConfig().AltairForkEpoch {
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Altair{Altair: pb.(*ethpb.BeaconBlockAltair)}}, nil
|
||||
}
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Phase0{Phase0: pb.(*ethpb.BeaconBlock)}}, nil
|
||||
}
|
||||
|
||||
func emptyBlockToSign(slot types.Slot) (interfaces.SignedBeaconBlock, error) {
|
||||
var sBlk interfaces.SignedBeaconBlock
|
||||
var err error
|
||||
switch {
|
||||
case slots.ToEpoch(slot) < params.BeaconConfig().AltairForkEpoch:
|
||||
sBlk, err = blocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{Body: ðpb.BeaconBlockBody{}}})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not initialize block for proposal: %v", err)
|
||||
}
|
||||
case slots.ToEpoch(slot) < params.BeaconConfig().BellatrixForkEpoch:
|
||||
sBlk, err = blocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlockAltair{Block: ðpb.BeaconBlockAltair{Body: ðpb.BeaconBlockBodyAltair{}}})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not initialize block for proposal: %v", err)
|
||||
}
|
||||
case slots.ToEpoch(slot) < params.BeaconConfig().CapellaForkEpoch:
|
||||
sBlk, err = blocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlockBellatrix{Block: ðpb.BeaconBlockBellatrix{Body: ðpb.BeaconBlockBodyBellatrix{}}})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not initialize block for proposal: %v", err)
|
||||
}
|
||||
default:
|
||||
sBlk, err = blocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlockCapella{Block: ðpb.BeaconBlockCapella{Body: ðpb.BeaconBlockBodyCapella{}}})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "Could not initialize block for proposal: %v", err)
|
||||
}
|
||||
}
|
||||
return sBlk, err
|
||||
}
|
||||
|
||||
// ProposeBeaconBlock is called by a proposer during its assigned slot to create a block in an attempt
|
||||
|
||||
@@ -2,11 +2,8 @@ package validator
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition/interop"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
@@ -15,66 +12,6 @@ import (
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
func (vs *Server) BuildAltairBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.BeaconBlockAltair, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.BuildAltairBeaconBlock")
|
||||
defer span.End()
|
||||
blkData, err := vs.buildPhase0BlockData(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not build block data: %v", err)
|
||||
}
|
||||
|
||||
// Use zero hash as stub for state root to compute later.
|
||||
stateRoot := params.BeaconConfig().ZeroHash[:]
|
||||
|
||||
// No need for safe sub as req.Slot cannot be 0 if requesting Altair blocks. If 0, we will be throwing
|
||||
// an error in the first validity check of this endpoint.
|
||||
syncAggregate, err := vs.getSyncAggregate(ctx, req.Slot-1, bytesutil.ToBytes32(blkData.ParentRoot))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ðpb.BeaconBlockAltair{
|
||||
Slot: req.Slot,
|
||||
ParentRoot: blkData.ParentRoot,
|
||||
StateRoot: stateRoot,
|
||||
ProposerIndex: blkData.ProposerIdx,
|
||||
Body: ðpb.BeaconBlockBodyAltair{
|
||||
Eth1Data: blkData.Eth1Data,
|
||||
Deposits: blkData.Deposits,
|
||||
Attestations: blkData.Attestations,
|
||||
RandaoReveal: req.RandaoReveal,
|
||||
ProposerSlashings: blkData.ProposerSlashings,
|
||||
AttesterSlashings: blkData.AttesterSlashings,
|
||||
VoluntaryExits: blkData.VoluntaryExits,
|
||||
Graffiti: blkData.Graffiti[:],
|
||||
SyncAggregate: syncAggregate,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (vs *Server) getAltairBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.BeaconBlockAltair, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.getAltairBeaconBlock")
|
||||
defer span.End()
|
||||
blk, err := vs.BuildAltairBeaconBlock(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not build block data: %v", err)
|
||||
}
|
||||
// Compute state root with the newly constructed block.
|
||||
wsb, err := blocks.NewSignedBeaconBlock(
|
||||
ðpb.SignedBeaconBlockAltair{Block: blk, Signature: make([]byte, 96)},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stateRoot, err := vs.computeStateRoot(ctx, wsb)
|
||||
if err != nil {
|
||||
interop.WriteBlockToDisk(wsb, true /*failed*/)
|
||||
return nil, fmt.Errorf("could not compute state root: %v", err)
|
||||
}
|
||||
blk.StateRoot = stateRoot
|
||||
return blk, nil
|
||||
}
|
||||
|
||||
// getSyncAggregate retrieves the sync contributions from the pool to construct the sync aggregate object.
|
||||
// The contributions are filtered based on matching of the input root and slot then profitability.
|
||||
func (vs *Server) getSyncAggregate(ctx context.Context, slot types.Slot, root [32]byte) (*ethpb.SyncAggregate, error) {
|
||||
|
||||
@@ -80,7 +80,7 @@ func (vs *Server) packAttestations(ctx context.Context, latestState state.Beacon
|
||||
// filter separates attestation list into two groups: valid and invalid attestations.
|
||||
// The first group passes the all the required checks for attestation to be considered for proposing.
|
||||
// And attestations from the second group should be deleted.
|
||||
func (a proposerAtts) filter(ctx context.Context, st state.BeaconState) (proposerAtts, proposerAtts) {
|
||||
func (a proposerAtts) filter(ctx context.Context, st state.BeaconState) (proposerAtts, proposerAtts, error) {
|
||||
validAtts := make([]*ethpb.Attestation, 0, len(a))
|
||||
invalidAtts := make([]*ethpb.Attestation, 0, len(a))
|
||||
var attestationProcessor func(context.Context, state.BeaconState, *ethpb.Attestation) (state.BeaconState, error)
|
||||
@@ -98,7 +98,7 @@ func (a proposerAtts) filter(ctx context.Context, st state.BeaconState) (propose
|
||||
}
|
||||
} else {
|
||||
// Exit early if there is an unknown state type.
|
||||
return validAtts, invalidAtts
|
||||
return validAtts, invalidAtts, errors.Errorf("unknown state type: %v", st.Version())
|
||||
}
|
||||
|
||||
for _, att := range a {
|
||||
@@ -108,7 +108,7 @@ func (a proposerAtts) filter(ctx context.Context, st state.BeaconState) (propose
|
||||
}
|
||||
invalidAtts = append(invalidAtts, att)
|
||||
}
|
||||
return validAtts, invalidAtts
|
||||
return validAtts, invalidAtts, nil
|
||||
}
|
||||
|
||||
// sortByProfitability orders attestations by highest slot and by highest aggregation bit count.
|
||||
@@ -247,7 +247,10 @@ func (vs *Server) validateAndDeleteAttsInPool(ctx context.Context, st state.Beac
|
||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.validateAndDeleteAttsInPool")
|
||||
defer span.End()
|
||||
|
||||
validAtts, invalidAtts := proposerAtts(atts).filter(ctx, st)
|
||||
validAtts, invalidAtts, err := proposerAtts(atts).filter(ctx, st)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := vs.deleteAttsInPool(ctx, invalidAtts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -11,9 +12,9 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition/interop"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
coreBlock "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
@@ -35,73 +36,9 @@ var builderGetPayloadMissCount = promauto.NewCounter(prometheus.CounterOpts{
|
||||
// block request. This value is known as `BUILDER_PROPOSAL_DELAY_TOLERANCE` in builder spec.
|
||||
const blockBuilderTimeout = 1 * time.Second
|
||||
|
||||
func (vs *Server) getBellatrixBeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.GenericBeaconBlock, error) {
|
||||
altairBlk, err := vs.BuildAltairBeaconBlock(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !req.SkipMevBoost {
|
||||
registered, err := vs.validatorRegistered(ctx, altairBlk.ProposerIndex)
|
||||
if registered && err == nil {
|
||||
builderReady, b, err := vs.GetAndBuildBlindBlock(ctx, altairBlk)
|
||||
if err != nil {
|
||||
// In the event of an error, the node should fall back to default execution engine for building block.
|
||||
log.WithError(err).Error("Failed to build a block from external builder, falling " +
|
||||
"back to local execution client")
|
||||
builderGetPayloadMissCount.Inc()
|
||||
} else if builderReady {
|
||||
return b, nil
|
||||
}
|
||||
} else if err != nil {
|
||||
log.WithError(err).WithFields(logrus.Fields{
|
||||
"slot": req.Slot,
|
||||
"validatorIndex": altairBlk.ProposerIndex,
|
||||
}).Error("Could not determine validator has registered. Defaulting to local execution client")
|
||||
}
|
||||
}
|
||||
payload, err := vs.getExecutionPayload(ctx, req.Slot, altairBlk.ProposerIndex, bytesutil.ToBytes32(altairBlk.ParentRoot))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blk := ðpb.BeaconBlockBellatrix{
|
||||
Slot: altairBlk.Slot,
|
||||
ProposerIndex: altairBlk.ProposerIndex,
|
||||
ParentRoot: altairBlk.ParentRoot,
|
||||
StateRoot: params.BeaconConfig().ZeroHash[:],
|
||||
Body: ðpb.BeaconBlockBodyBellatrix{
|
||||
RandaoReveal: altairBlk.Body.RandaoReveal,
|
||||
Eth1Data: altairBlk.Body.Eth1Data,
|
||||
Graffiti: altairBlk.Body.Graffiti,
|
||||
ProposerSlashings: altairBlk.Body.ProposerSlashings,
|
||||
AttesterSlashings: altairBlk.Body.AttesterSlashings,
|
||||
Attestations: altairBlk.Body.Attestations,
|
||||
Deposits: altairBlk.Body.Deposits,
|
||||
VoluntaryExits: altairBlk.Body.VoluntaryExits,
|
||||
SyncAggregate: altairBlk.Body.SyncAggregate,
|
||||
ExecutionPayload: payload,
|
||||
},
|
||||
}
|
||||
// Compute state root with the newly constructed block.
|
||||
wsb, err := consensusblocks.NewSignedBeaconBlock(
|
||||
ðpb.SignedBeaconBlockBellatrix{Block: blk, Signature: make([]byte, 96)},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stateRoot, err := vs.computeStateRoot(ctx, wsb)
|
||||
if err != nil {
|
||||
interop.WriteBlockToDisk(wsb, true /*failed*/)
|
||||
return nil, fmt.Errorf("could not compute state root: %v", err)
|
||||
}
|
||||
blk.StateRoot = stateRoot
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_Bellatrix{Bellatrix: blk}}, nil
|
||||
}
|
||||
|
||||
// This function retrieves the payload header given the slot number and the validator index.
|
||||
// It's a no-op if the latest head block is not versioned bellatrix.
|
||||
func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot types.Slot, idx types.ValidatorIndex) (*enginev1.ExecutionPayloadHeader, error) {
|
||||
func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot types.Slot, idx types.ValidatorIndex) (interfaces.ExecutionData, error) {
|
||||
b, err := vs.HeadFetcher.HeadBlock(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -126,7 +63,7 @@ func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot types.Sl
|
||||
return nil, errors.New("builder returned nil bid")
|
||||
}
|
||||
|
||||
v := bytesutil.LittleEndianBytesToBigInt(bid.Message.Value)
|
||||
v := new(big.Int).SetBytes(bytesutil.ReverseByteOrder(bid.Message.Value))
|
||||
if v.String() == "0" {
|
||||
return nil, errors.New("builder returned header with 0 bid amount")
|
||||
}
|
||||
@@ -152,7 +89,7 @@ func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot types.Sl
|
||||
return nil, fmt.Errorf("incorrect timestamp %d != %d", bid.Message.Header.Timestamp, uint64(t.Unix()))
|
||||
}
|
||||
|
||||
if err := validateBuilderSignature(bid); err != nil {
|
||||
if err := vs.validateBuilderSignature(bid); err != nil {
|
||||
return nil, errors.Wrap(err, "could not validate builder signature")
|
||||
}
|
||||
|
||||
@@ -161,55 +98,15 @@ func (vs *Server) getPayloadHeaderFromBuilder(ctx context.Context, slot types.Sl
|
||||
"builderPubKey": fmt.Sprintf("%#x", bid.Message.Pubkey),
|
||||
"blockHash": fmt.Sprintf("%#x", bid.Message.Header.BlockHash),
|
||||
}).Info("Received header with bid")
|
||||
return bid.Message.Header, nil
|
||||
}
|
||||
|
||||
// This function constructs the builder block given the input altair block and the header. It returns a generic beacon block for signing
|
||||
func (vs *Server) buildBlindBlock(ctx context.Context, b *ethpb.BeaconBlockAltair, h *enginev1.ExecutionPayloadHeader) (*ethpb.GenericBeaconBlock, error) {
|
||||
if b == nil || b.Body == nil {
|
||||
return nil, errors.New("nil block")
|
||||
}
|
||||
if h == nil {
|
||||
return nil, errors.New("nil header")
|
||||
}
|
||||
|
||||
blk := ðpb.BlindedBeaconBlockBellatrix{
|
||||
Slot: b.Slot,
|
||||
ProposerIndex: b.ProposerIndex,
|
||||
ParentRoot: b.ParentRoot,
|
||||
StateRoot: params.BeaconConfig().ZeroHash[:],
|
||||
Body: ðpb.BlindedBeaconBlockBodyBellatrix{
|
||||
RandaoReveal: b.Body.RandaoReveal,
|
||||
Eth1Data: b.Body.Eth1Data,
|
||||
Graffiti: b.Body.Graffiti,
|
||||
ProposerSlashings: b.Body.ProposerSlashings,
|
||||
AttesterSlashings: b.Body.AttesterSlashings,
|
||||
Attestations: b.Body.Attestations,
|
||||
Deposits: b.Body.Deposits,
|
||||
VoluntaryExits: b.Body.VoluntaryExits,
|
||||
SyncAggregate: b.Body.SyncAggregate,
|
||||
ExecutionPayloadHeader: h,
|
||||
},
|
||||
}
|
||||
wsb, err := consensusblocks.NewSignedBeaconBlock(
|
||||
ðpb.SignedBlindedBeaconBlockBellatrix{Block: blk, Signature: make([]byte, 96)},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stateRoot, err := vs.computeStateRoot(ctx, wsb)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not compute state root")
|
||||
}
|
||||
blk.StateRoot = stateRoot
|
||||
return ðpb.GenericBeaconBlock{Block: ðpb.GenericBeaconBlock_BlindedBellatrix{BlindedBellatrix: blk}}, nil
|
||||
return coreBlock.WrappedExecutionPayloadHeader(bid.Message.Header)
|
||||
}
|
||||
|
||||
// This function retrieves the full payload block using the input blind block. This input must be versioned as
|
||||
// bellatrix blind block. The output block will contain the full payload. The original header block
|
||||
// will be returned the block builder is not configured.
|
||||
func (vs *Server) unblindBuilderBlock(ctx context.Context, b interfaces.SignedBeaconBlock) (interfaces.SignedBeaconBlock, error) {
|
||||
if err := consensusblocks.BeaconBlockIsNil(b); err != nil {
|
||||
if err := coreBlock.BeaconBlockIsNil(b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -334,52 +231,8 @@ func (vs *Server) readyForBuilder(ctx context.Context) (bool, error) {
|
||||
return blocks.IsExecutionBlock(b.Block().Body())
|
||||
}
|
||||
|
||||
// GetAndBuildBlindBlock builds blind block from builder network. Returns a boolean status, built block and error.
|
||||
// If the status is false that means builder the header block is disallowed.
|
||||
// This routine is time limited by `blockBuilderTimeout`.
|
||||
func (vs *Server) GetAndBuildBlindBlock(ctx context.Context, b *ethpb.BeaconBlockAltair) (bool, *ethpb.GenericBeaconBlock, error) {
|
||||
// No op. Builder is not defined. User did not specify a user URL. We should use local EE.
|
||||
if vs.BlockBuilder == nil || !vs.BlockBuilder.Configured() {
|
||||
return false, nil, nil
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, blockBuilderTimeout)
|
||||
defer cancel()
|
||||
// Does the protocol allow for builder at this current moment. Builder is only allowed post merge after finalization.
|
||||
ready, err := vs.readyForBuilder(ctx)
|
||||
if err != nil {
|
||||
return false, nil, errors.Wrap(err, "could not determine if builder is ready")
|
||||
}
|
||||
if !ready {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
||||
circuitBreak, err := vs.circuitBreakBuilder(b.Slot)
|
||||
if err != nil {
|
||||
return false, nil, errors.Wrap(err, "could not determine if builder circuit breaker condition")
|
||||
}
|
||||
if circuitBreak {
|
||||
return false, nil, nil
|
||||
}
|
||||
|
||||
h, err := vs.getPayloadHeaderFromBuilder(ctx, b.Slot, b.ProposerIndex)
|
||||
if err != nil {
|
||||
return false, nil, errors.Wrap(err, "could not get payload header")
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
"blockHash": fmt.Sprintf("%#x", h.BlockHash),
|
||||
"feeRecipient": fmt.Sprintf("%#x", h.FeeRecipient),
|
||||
"gasUsed": h.GasUsed,
|
||||
"slot": b.Slot,
|
||||
}).Info("Retrieved header from builder")
|
||||
gb, err := vs.buildBlindBlock(ctx, b, h)
|
||||
if err != nil {
|
||||
return false, nil, errors.Wrap(err, "could not combine altair block with payload header")
|
||||
}
|
||||
return true, gb, nil
|
||||
}
|
||||
|
||||
// Validates builder signature and returns an error if the signature is invalid.
|
||||
func validateBuilderSignature(bid *ethpb.SignedBuilderBid) error {
|
||||
func (vs *Server) validateBuilderSignature(bid *ethpb.SignedBuilderBid) error {
|
||||
d, err := signing.ComputeDomain(params.BeaconConfig().DomainApplicationBuilder,
|
||||
nil, /* fork version */
|
||||
nil /* genesis val root */)
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
blockchainTest "github.com/prysmaticlabs/prysm/v3/beacon-chain/blockchain/testing"
|
||||
builderTest "github.com/prysmaticlabs/prysm/v3/beacon-chain/builder/testing"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/cache"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/altair"
|
||||
consensusblocks "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
|
||||
@@ -40,56 +39,6 @@ import (
|
||||
logTest "github.com/sirupsen/logrus/hooks/test"
|
||||
)
|
||||
|
||||
func TestServer_buildHeaderBlock(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
beaconState, keys := util.DeterministicGenesisStateAltair(t, 16384)
|
||||
sCom, err := altair.NextSyncCommittee(context.Background(), beaconState)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconState.SetCurrentSyncCommittee(sCom))
|
||||
copiedState := beaconState.Copy()
|
||||
|
||||
proposerServer := &Server{
|
||||
BeaconDB: db,
|
||||
StateGen: stategen.New(db, doublylinkedtree.New()),
|
||||
}
|
||||
b, err := util.GenerateFullBlockAltair(copiedState, keys, util.DefaultBlockGenConfig(), 1)
|
||||
require.NoError(t, err)
|
||||
r := bytesutil.ToBytes32(b.Block.ParentRoot)
|
||||
util.SaveBlock(t, ctx, proposerServer.BeaconDB, b)
|
||||
require.NoError(t, proposerServer.BeaconDB.SaveState(ctx, beaconState, r))
|
||||
|
||||
b1, err := util.GenerateFullBlockAltair(copiedState, keys, util.DefaultBlockGenConfig(), 2)
|
||||
require.NoError(t, err)
|
||||
|
||||
vs := &Server{StateGen: stategen.New(db, doublylinkedtree.New()), BeaconDB: db}
|
||||
h := &v1.ExecutionPayloadHeader{
|
||||
BlockNumber: 123,
|
||||
GasLimit: 456,
|
||||
GasUsed: 789,
|
||||
ParentHash: make([]byte, fieldparams.RootLength),
|
||||
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
|
||||
StateRoot: make([]byte, fieldparams.RootLength),
|
||||
ReceiptsRoot: make([]byte, fieldparams.RootLength),
|
||||
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
|
||||
PrevRandao: make([]byte, fieldparams.RootLength),
|
||||
BaseFeePerGas: make([]byte, fieldparams.RootLength),
|
||||
BlockHash: make([]byte, fieldparams.RootLength),
|
||||
TransactionsRoot: make([]byte, fieldparams.RootLength),
|
||||
ExtraData: make([]byte, 0),
|
||||
}
|
||||
got, err := vs.buildBlindBlock(ctx, b1.Block, h)
|
||||
require.NoError(t, err)
|
||||
require.DeepEqual(t, h, got.GetBlindedBellatrix().Body.ExecutionPayloadHeader)
|
||||
|
||||
_, err = vs.buildBlindBlock(ctx, nil, h)
|
||||
require.ErrorContains(t, "nil block", err)
|
||||
|
||||
_, err = vs.buildBlindBlock(ctx, b1.Block, nil)
|
||||
require.ErrorContains(t, "nil header", err)
|
||||
}
|
||||
|
||||
func TestServer_getPayloadHeader(t *testing.T) {
|
||||
emptyRoot, err := ssz.TransactionsRoot([][]byte{})
|
||||
require.NoError(t, err)
|
||||
@@ -409,121 +358,6 @@ func TestServer_readyForBuilder(t *testing.T) {
|
||||
require.Equal(t, true, ready)
|
||||
}
|
||||
|
||||
func TestServer_getAndBuildHeaderBlock(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
vs := &Server{}
|
||||
|
||||
// Nil builder
|
||||
ready, _, err := vs.GetAndBuildBlindBlock(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, ready)
|
||||
|
||||
// Not configured
|
||||
vs.BlockBuilder = &builderTest.MockBuilderService{}
|
||||
ready, _, err = vs.GetAndBuildBlindBlock(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, ready)
|
||||
|
||||
// Block is not ready
|
||||
vs.BlockBuilder = &builderTest.MockBuilderService{HasConfigured: true}
|
||||
vs.FinalizationFetcher = &blockchainTest.ChainService{FinalizedCheckPoint: ðpb.Checkpoint{}}
|
||||
ready, _, err = vs.GetAndBuildBlindBlock(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, false, ready)
|
||||
|
||||
// Failed to get header
|
||||
b1 := util.NewBeaconBlockBellatrix()
|
||||
b1.Block.Body.ExecutionPayload.BlockNumber = 1 // Execution enabled.
|
||||
wb1, err := blocks.NewSignedBeaconBlock(b1)
|
||||
require.NoError(t, err)
|
||||
wbr1, err := wb1.Block().HashTreeRoot()
|
||||
require.NoError(t, err)
|
||||
vs.BeaconDB = dbTest.SetupDB(t)
|
||||
require.NoError(t, vs.BeaconDB.SaveBlock(ctx, wb1))
|
||||
vs.FinalizationFetcher = &blockchainTest.ChainService{FinalizedCheckPoint: ðpb.Checkpoint{Root: wbr1[:]}}
|
||||
vs.HeadFetcher = &blockchainTest.ChainService{Block: wb1}
|
||||
vs.BlockBuilder = &builderTest.MockBuilderService{HasConfigured: true, ErrGetHeader: errors.New("could not get payload")}
|
||||
vs.ForkFetcher = &blockchainTest.ChainService{ForkChoiceStore: doublylinkedtree.New()}
|
||||
ready, _, err = vs.GetAndBuildBlindBlock(ctx, ðpb.BeaconBlockAltair{})
|
||||
require.ErrorContains(t, "could not get payload", err)
|
||||
require.Equal(t, false, ready)
|
||||
|
||||
// Block built and validated!
|
||||
beaconState, keys := util.DeterministicGenesisStateAltair(t, 16384)
|
||||
sCom, err := altair.NextSyncCommittee(context.Background(), beaconState)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, beaconState.SetCurrentSyncCommittee(sCom))
|
||||
copiedState := beaconState.Copy()
|
||||
|
||||
b, err := util.GenerateFullBlockAltair(copiedState, keys, util.DefaultBlockGenConfig(), 1)
|
||||
require.NoError(t, err)
|
||||
r := bytesutil.ToBytes32(b.Block.ParentRoot)
|
||||
util.SaveBlock(t, ctx, vs.BeaconDB, b)
|
||||
require.NoError(t, vs.BeaconDB.SaveState(ctx, beaconState, r))
|
||||
|
||||
altairBlk, err := util.GenerateFullBlockAltair(copiedState, keys, util.DefaultBlockGenConfig(), 2)
|
||||
require.NoError(t, err)
|
||||
|
||||
ts := uint64(time.Now().Unix()) + uint64(altairBlk.Block.Slot)*params.BeaconConfig().SecondsPerSlot
|
||||
h := &v1.ExecutionPayloadHeader{
|
||||
BlockNumber: 123,
|
||||
GasLimit: 456,
|
||||
GasUsed: 789,
|
||||
ParentHash: make([]byte, fieldparams.RootLength),
|
||||
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
|
||||
StateRoot: make([]byte, fieldparams.RootLength),
|
||||
ReceiptsRoot: make([]byte, fieldparams.RootLength),
|
||||
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
|
||||
PrevRandao: make([]byte, fieldparams.RootLength),
|
||||
BaseFeePerGas: make([]byte, fieldparams.RootLength),
|
||||
BlockHash: make([]byte, fieldparams.RootLength),
|
||||
TransactionsRoot: make([]byte, fieldparams.RootLength),
|
||||
Timestamp: ts,
|
||||
}
|
||||
|
||||
vs.StateGen = stategen.New(vs.BeaconDB, doublylinkedtree.New())
|
||||
vs.GenesisFetcher = &blockchainTest.ChainService{}
|
||||
vs.ForkFetcher = &blockchainTest.ChainService{Fork: ðpb.Fork{}}
|
||||
|
||||
sk, err := bls.RandKey()
|
||||
require.NoError(t, err)
|
||||
bid := ðpb.BuilderBid{
|
||||
Header: &v1.ExecutionPayloadHeader{
|
||||
BlockNumber: 123,
|
||||
GasLimit: 456,
|
||||
GasUsed: 789,
|
||||
ParentHash: make([]byte, fieldparams.RootLength),
|
||||
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
|
||||
StateRoot: make([]byte, fieldparams.RootLength),
|
||||
ReceiptsRoot: make([]byte, fieldparams.RootLength),
|
||||
LogsBloom: make([]byte, fieldparams.LogsBloomLength),
|
||||
PrevRandao: make([]byte, fieldparams.RootLength),
|
||||
BaseFeePerGas: make([]byte, fieldparams.RootLength),
|
||||
BlockHash: make([]byte, fieldparams.RootLength),
|
||||
TransactionsRoot: make([]byte, fieldparams.RootLength),
|
||||
Timestamp: ts,
|
||||
},
|
||||
Pubkey: sk.PublicKey().Marshal(),
|
||||
Value: bytesutil.PadTo([]byte{1, 2, 3}, 32),
|
||||
}
|
||||
d := params.BeaconConfig().DomainApplicationBuilder
|
||||
domain, err := signing.ComputeDomain(d, nil, nil)
|
||||
require.NoError(t, err)
|
||||
sr, err := signing.ComputeSigningRoot(bid, domain)
|
||||
require.NoError(t, err)
|
||||
sBid := ðpb.SignedBuilderBid{
|
||||
Message: bid,
|
||||
Signature: sk.Sign(sr[:]).Marshal(),
|
||||
}
|
||||
vs.BlockBuilder = &builderTest.MockBuilderService{HasConfigured: true, Bid: sBid}
|
||||
vs.TimeFetcher = &blockchainTest.ChainService{Genesis: time.Now()}
|
||||
vs.ForkFetcher = &blockchainTest.ChainService{ForkChoiceStore: doublylinkedtree.New()}
|
||||
ready, builtBlk, err := vs.GetAndBuildBlindBlock(ctx, altairBlk.Block)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, true, ready)
|
||||
require.DeepEqual(t, h, builtBlk.GetBlindedBellatrix().Body.ExecutionPayloadHeader)
|
||||
}
|
||||
|
||||
func TestServer_GetBellatrixBeaconBlock_HappyCase(t *testing.T) {
|
||||
db := dbTest.SetupDB(t)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -12,11 +12,12 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/time"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/db/kv"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
|
||||
payloadattribute "github.com/prysmaticlabs/prysm/v3/consensus-types/payload-attribute"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
@@ -39,9 +40,14 @@ var (
|
||||
})
|
||||
)
|
||||
|
||||
// This returns the execution payload of a given slot. The function has full awareness of pre and post merge.
|
||||
// This returns the execution payload of a given slot.
|
||||
// The function has full awareness of pre and post merge.
|
||||
// The payload is computed given the respected time of merge.
|
||||
func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx types.ValidatorIndex, headRoot [32]byte) (*enginev1.ExecutionPayload, error) {
|
||||
func (vs *Server) getExecutionPayload(ctx context.Context,
|
||||
slot types.Slot,
|
||||
vIdx types.ValidatorIndex,
|
||||
headRoot [32]byte,
|
||||
st state.BeaconState) (interfaces.ExecutionData, error) {
|
||||
proposerID, payloadId, ok := vs.ProposerSlotIndexCache.GetProposerPayloadIDs(slot, headRoot)
|
||||
feeRecipient := params.BeaconConfig().DefaultFeeRecipient
|
||||
recipient, err := vs.BeaconDB.FeeRecipientByValidatorID(ctx, vIdx)
|
||||
@@ -71,27 +77,14 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx
|
||||
payload, err := vs.ExecutionEngineCaller.GetPayload(ctx, pid, slot)
|
||||
switch {
|
||||
case err == nil:
|
||||
pb, err := payload.PbBellatrix()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
warnIfFeeRecipientDiffers(pb, feeRecipient)
|
||||
return pb, nil
|
||||
warnIfFeeRecipientDiffers(payload.FeeRecipient(), feeRecipient)
|
||||
return payload, nil
|
||||
case errors.Is(err, context.DeadlineExceeded):
|
||||
default:
|
||||
return nil, errors.Wrap(err, "could not get cached payload from execution client")
|
||||
}
|
||||
}
|
||||
|
||||
st, err := vs.HeadFetcher.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
st, err = transition.ProcessSlotsIfPossible(ctx, st, slot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var parentHash []byte
|
||||
var hasTerminalBlock bool
|
||||
mergeComplete, err := blocks.IsMergeTransitionComplete(st)
|
||||
@@ -111,14 +104,14 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx
|
||||
parentHash = header.BlockHash()
|
||||
} else {
|
||||
if activationEpochNotReached(slot) {
|
||||
return emptyPayload(), nil
|
||||
return emptyPayload()
|
||||
}
|
||||
parentHash, hasTerminalBlock, err = vs.getTerminalBlockHashIfExists(ctx, uint64(t.Unix()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !hasTerminalBlock {
|
||||
return emptyPayload(), nil
|
||||
return emptyPayload()
|
||||
}
|
||||
}
|
||||
payloadIDCacheMiss.Inc()
|
||||
@@ -154,18 +147,15 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx
|
||||
FinalizedBlockHash: finalizedBlockHash,
|
||||
}
|
||||
|
||||
p := &enginev1.PayloadAttributes{
|
||||
p, err := payloadattribute.New(&enginev1.PayloadAttributes{
|
||||
Timestamp: uint64(t.Unix()),
|
||||
PrevRandao: random,
|
||||
SuggestedFeeRecipient: feeRecipient.Bytes(),
|
||||
}
|
||||
|
||||
// This will change in subsequent hardforks like Capella.
|
||||
pa, err := payloadattribute.New(p)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payloadID, _, err := vs.ExecutionEngineCaller.ForkchoiceUpdated(ctx, f, pa)
|
||||
payloadID, _, err := vs.ExecutionEngineCaller.ForkchoiceUpdated(ctx, f, p)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not prepare payload")
|
||||
}
|
||||
@@ -176,22 +166,18 @@ func (vs *Server) getExecutionPayload(ctx context.Context, slot types.Slot, vIdx
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pb, err := payload.PbBellatrix()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
warnIfFeeRecipientDiffers(pb, feeRecipient)
|
||||
return pb, nil
|
||||
warnIfFeeRecipientDiffers(payload.FeeRecipient(), feeRecipient)
|
||||
return payload, nil
|
||||
}
|
||||
|
||||
// warnIfFeeRecipientDiffers logs a warning if the fee recipient in the included payload does not
|
||||
// match the requested one.
|
||||
func warnIfFeeRecipientDiffers(payload *enginev1.ExecutionPayload, feeRecipient common.Address) {
|
||||
func warnIfFeeRecipientDiffers(payloadRecipient []byte, feeRecipient common.Address) {
|
||||
// Warn if the fee recipient is not the value we expect.
|
||||
if payload != nil && !bytes.Equal(payload.FeeRecipient, feeRecipient[:]) {
|
||||
if !bytes.Equal(payloadRecipient, feeRecipient[:]) {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"wantedFeeRecipient": fmt.Sprintf("%#x", feeRecipient),
|
||||
"received": fmt.Sprintf("%#x", payload.FeeRecipient),
|
||||
"received": fmt.Sprintf("%#x", payloadRecipient),
|
||||
}).Warn("Fee recipient address from execution client is not what was expected. " +
|
||||
"It is possible someone has compromised your client to try and take your transaction fees")
|
||||
}
|
||||
@@ -243,8 +229,8 @@ func activationEpochNotReached(slot types.Slot) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func emptyPayload() *enginev1.ExecutionPayload {
|
||||
return &enginev1.ExecutionPayload{
|
||||
func emptyPayload() (interfaces.ExecutionData, error) {
|
||||
return consensusblocks.WrappedExecutionPayload(&enginev1.ExecutionPayload{
|
||||
ParentHash: make([]byte, fieldparams.RootLength),
|
||||
FeeRecipient: make([]byte, fieldparams.FeeRecipientLength),
|
||||
StateRoot: make([]byte, fieldparams.RootLength),
|
||||
@@ -253,5 +239,5 @@ func emptyPayload() *enginev1.ExecutionPayload {
|
||||
PrevRandao: make([]byte, fieldparams.RootLength),
|
||||
BaseFeePerGas: make([]byte, fieldparams.RootLength),
|
||||
BlockHash: make([]byte, fieldparams.RootLength),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
package validator
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/helpers"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/transition/interop"
|
||||
v "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/validators"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
consensusblocks "github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
// blockData required to create a beacon block.
|
||||
type blockData struct {
|
||||
ParentRoot []byte
|
||||
Graffiti [32]byte
|
||||
ProposerIdx types.ValidatorIndex
|
||||
Eth1Data *ethpb.Eth1Data
|
||||
Deposits []*ethpb.Deposit
|
||||
Attestations []*ethpb.Attestation
|
||||
ProposerSlashings []*ethpb.ProposerSlashing
|
||||
AttesterSlashings []*ethpb.AttesterSlashing
|
||||
VoluntaryExits []*ethpb.SignedVoluntaryExit
|
||||
}
|
||||
|
||||
func (vs *Server) getPhase0BeaconBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb.BeaconBlock, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.getPhase0BeaconBlock")
|
||||
defer span.End()
|
||||
blkData, err := vs.buildPhase0BlockData(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not build block data: %v", err)
|
||||
}
|
||||
|
||||
// Use zero hash as stub for state root to compute later.
|
||||
stateRoot := params.BeaconConfig().ZeroHash[:]
|
||||
|
||||
blk := ðpb.BeaconBlock{
|
||||
Slot: req.Slot,
|
||||
ParentRoot: blkData.ParentRoot,
|
||||
StateRoot: stateRoot,
|
||||
ProposerIndex: blkData.ProposerIdx,
|
||||
Body: ðpb.BeaconBlockBody{
|
||||
Eth1Data: blkData.Eth1Data,
|
||||
Deposits: blkData.Deposits,
|
||||
Attestations: blkData.Attestations,
|
||||
RandaoReveal: req.RandaoReveal,
|
||||
ProposerSlashings: blkData.ProposerSlashings,
|
||||
AttesterSlashings: blkData.AttesterSlashings,
|
||||
VoluntaryExits: blkData.VoluntaryExits,
|
||||
Graffiti: blkData.Graffiti[:],
|
||||
},
|
||||
}
|
||||
|
||||
// Compute state root with the newly constructed block.
|
||||
wsb, err := consensusblocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlock{Block: blk, Signature: make([]byte, 96)})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stateRoot, err = vs.computeStateRoot(ctx, wsb)
|
||||
if err != nil {
|
||||
interop.WriteBlockToDisk(wsb, true /*failed*/)
|
||||
return nil, errors.Wrap(err, "could not compute state root")
|
||||
}
|
||||
blk.StateRoot = stateRoot
|
||||
return blk, nil
|
||||
}
|
||||
|
||||
// Build data required for creating a new beacon block, so this method can be shared across forks.
|
||||
func (vs *Server) buildPhase0BlockData(ctx context.Context, req *ethpb.BlockRequest) (*blockData, error) {
|
||||
ctx, span := trace.StartSpan(ctx, "ProposerServer.buildPhase0BlockData")
|
||||
defer span.End()
|
||||
|
||||
if vs.SyncChecker.Syncing() {
|
||||
return nil, fmt.Errorf("syncing to latest head, not ready to respond")
|
||||
}
|
||||
|
||||
if err := vs.HeadUpdater.UpdateHead(ctx); err != nil {
|
||||
log.WithError(err).Error("Could not process attestations and update head")
|
||||
}
|
||||
|
||||
// Retrieve the parent block as the current head of the canonical chain.
|
||||
parentRoot, err := vs.HeadFetcher.HeadRoot(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not retrieve head root: %v", err)
|
||||
}
|
||||
|
||||
head, err := vs.HeadFetcher.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get head state %v", err)
|
||||
}
|
||||
|
||||
head, err = transition.ProcessSlotsUsingNextSlotCache(ctx, head, parentRoot, req.Slot)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not advance slots to calculate proposer index: %v", err)
|
||||
}
|
||||
|
||||
eth1Data, err := vs.eth1DataMajorityVote(ctx, head)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get ETH1 data: %v", err)
|
||||
}
|
||||
|
||||
deposits, atts, err := vs.packDepositsAndAttestations(ctx, head, eth1Data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
graffiti := bytesutil.ToBytes32(req.Graffiti)
|
||||
|
||||
// Calculate new proposer index.
|
||||
idx, err := helpers.BeaconProposerIndex(ctx, head)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not calculate proposer index %v", err)
|
||||
}
|
||||
|
||||
proposerSlashings := vs.SlashingsPool.PendingProposerSlashings(ctx, head, false /*noLimit*/)
|
||||
validProposerSlashings := make([]*ethpb.ProposerSlashing, 0, len(proposerSlashings))
|
||||
for _, slashing := range proposerSlashings {
|
||||
_, err := blocks.ProcessProposerSlashing(ctx, head, slashing, v.SlashValidator)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Proposer: invalid proposer slashing")
|
||||
continue
|
||||
}
|
||||
validProposerSlashings = append(validProposerSlashings, slashing)
|
||||
}
|
||||
|
||||
attSlashings := vs.SlashingsPool.PendingAttesterSlashings(ctx, head, false /*noLimit*/)
|
||||
validAttSlashings := make([]*ethpb.AttesterSlashing, 0, len(attSlashings))
|
||||
for _, slashing := range attSlashings {
|
||||
_, err := blocks.ProcessAttesterSlashing(ctx, head, slashing, v.SlashValidator)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Proposer: invalid attester slashing")
|
||||
continue
|
||||
}
|
||||
validAttSlashings = append(validAttSlashings, slashing)
|
||||
}
|
||||
exits := vs.ExitPool.PendingExits(head, req.Slot, false /*noLimit*/)
|
||||
validExits := make([]*ethpb.SignedVoluntaryExit, 0, len(exits))
|
||||
for _, exit := range exits {
|
||||
val, err := head.ValidatorAtIndexReadOnly(exit.Exit.ValidatorIndex)
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Proposer: invalid exit")
|
||||
continue
|
||||
}
|
||||
if err := blocks.VerifyExitAndSignature(val, head.Slot(), head.Fork(), exit, head.GenesisValidatorsRoot()); err != nil {
|
||||
log.WithError(err).Warn("Proposer: invalid exit")
|
||||
continue
|
||||
}
|
||||
validExits = append(validExits, exit)
|
||||
}
|
||||
|
||||
return &blockData{
|
||||
ParentRoot: parentRoot,
|
||||
Graffiti: graffiti,
|
||||
ProposerIdx: idx,
|
||||
Eth1Data: eth1Data,
|
||||
Deposits: deposits,
|
||||
Attestations: atts,
|
||||
ProposerSlashings: validProposerSlashings,
|
||||
AttesterSlashings: validAttSlashings,
|
||||
VoluntaryExits: validExits,
|
||||
}, nil
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/db"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/execution"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/attestations"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/blstoexec"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/slashings"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/synccommittee"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/operations/voluntaryexits"
|
||||
@@ -62,6 +63,7 @@ type Server struct {
|
||||
SlashingsPool slashings.PoolManager
|
||||
ExitPool voluntaryexits.PoolManager
|
||||
SyncCommitteePool synccommittee.Pool
|
||||
BLSChangesPool blstoexec.PoolManager
|
||||
BlockReceiver blockchain.BlockReceiver
|
||||
MockEth1Votes bool
|
||||
Eth1BlockFetcher execution.POWBlockFetcher
|
||||
|
||||
@@ -98,6 +98,7 @@ type Config struct {
|
||||
AttestationsPool attestations.Pool
|
||||
ExitPool voluntaryexits.PoolManager
|
||||
SlashingsPool slashings.PoolManager
|
||||
BLSToExecPool blstoexec.PoolManager
|
||||
SlashingChecker slasherservice.SlashingChecker
|
||||
SyncCommitteeObjectPool synccommittee.Pool
|
||||
BLSChangesPool blstoexec.PoolManager
|
||||
@@ -218,6 +219,7 @@ func (s *Service) Start() {
|
||||
SlashingsPool: s.cfg.SlashingsPool,
|
||||
StateGen: s.cfg.StateGen,
|
||||
SyncCommitteePool: s.cfg.SyncCommitteeObjectPool,
|
||||
BLSChangesPool: s.cfg.BLSChangesPool,
|
||||
ReplayerBuilder: ch,
|
||||
ExecutionEngineCaller: s.cfg.ExecutionEngineCaller,
|
||||
BeaconDB: s.cfg.BeaconDB,
|
||||
@@ -242,6 +244,7 @@ func (s *Service) Start() {
|
||||
ReplayerBuilder: ch,
|
||||
},
|
||||
SyncCommitteePool: s.cfg.SyncCommitteeObjectPool,
|
||||
BLSChangesPool: s.cfg.BLSChangesPool,
|
||||
ProposerSlotIndexCache: s.cfg.ProposerIdsCache,
|
||||
}
|
||||
|
||||
@@ -294,6 +297,7 @@ func (s *Service) Start() {
|
||||
ReceivedAttestationsBuffer: make(chan *ethpbv1alpha1.Attestation, attestationBufferSize),
|
||||
CollectedAttestationsBuffer: make(chan []*ethpbv1alpha1.Attestation, attestationBufferSize),
|
||||
ReplayerBuilder: ch,
|
||||
BLSChangesPool: s.cfg.BLSChangesPool,
|
||||
}
|
||||
beaconChainServerV1 := &beacon.Server{
|
||||
CanonicalHistory: ch,
|
||||
|
||||
@@ -58,6 +58,7 @@ type ReadOnlyBeaconState interface {
|
||||
Fork() *ethpb.Fork
|
||||
LatestBlockHeader() *ethpb.BeaconBlockHeader
|
||||
HistoricalRoots() [][]byte
|
||||
HistoricalSummaries() []*ethpb.HistoricalSummary
|
||||
Slashings() []uint64
|
||||
FieldReferencesCount() map[string]uint64
|
||||
MarshalSSZ() ([]byte, error)
|
||||
@@ -85,6 +86,7 @@ type WriteOnlyBeaconState interface {
|
||||
SetSlashings(val []uint64) error
|
||||
UpdateSlashingsAtIndex(idx, val uint64) error
|
||||
AppendHistoricalRoots(root [32]byte) error
|
||||
AppendHistoricalSummariesUpdate(*ethpb.HistoricalSummary) error
|
||||
SetLatestExecutionPayloadHeader(payload interfaces.ExecutionData) error
|
||||
SetNextWithdrawalIndex(i uint64) error
|
||||
SetNextWithdrawalValidatorIndex(i types.ValidatorIndex) error
|
||||
|
||||
@@ -27,6 +27,7 @@ type BeaconState struct {
|
||||
blockRoots *customtypes.BlockRoots
|
||||
stateRoots *customtypes.StateRoots
|
||||
historicalRoots customtypes.HistoricalRoots
|
||||
historicalSummaries []*ethpb.HistoricalSummary
|
||||
eth1Data *ethpb.Eth1Data
|
||||
eth1DataVotes []*ethpb.Eth1Data
|
||||
eth1DepositIndex uint64
|
||||
|
||||
@@ -27,6 +27,7 @@ type BeaconState struct {
|
||||
blockRoots *customtypes.BlockRoots
|
||||
stateRoots *customtypes.StateRoots
|
||||
historicalRoots customtypes.HistoricalRoots
|
||||
historicalSummaries []*ethpb.HistoricalSummary
|
||||
eth1Data *ethpb.Eth1Data
|
||||
eth1DataVotes []*ethpb.Eth1Data
|
||||
eth1DepositIndex uint64
|
||||
|
||||
@@ -87,3 +87,21 @@ func (b *BeaconState) balancesLength() int {
|
||||
|
||||
return len(b.balances)
|
||||
}
|
||||
|
||||
// HistoricalSummaries of the beacon state.
|
||||
func (b *BeaconState) HistoricalSummaries() []*ethpb.HistoricalSummary {
|
||||
if b.historicalSummaries == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
return b.historicalSummariesVal()
|
||||
}
|
||||
|
||||
// historicalSummariesVal of the beacon state.
|
||||
// This assumes that a lock is already held on BeaconState.
|
||||
func (b *BeaconState) historicalSummariesVal() []*ethpb.HistoricalSummary {
|
||||
return ethpb.CopyHistoricalSummaries(b.historicalSummaries)
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ func (b *BeaconState) ToProtoUnsafe() interface{} {
|
||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderCapella,
|
||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||
HistoricalSummaries: b.historicalSummaries,
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
@@ -252,6 +253,7 @@ func (b *BeaconState) ToProto() interface{} {
|
||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderCapellaVal(),
|
||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||
HistoricalSummaries: b.historicalSummariesVal(),
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package state_native
|
||||
|
||||
import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/config/params"
|
||||
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
@@ -49,7 +50,7 @@ func (b *BeaconState) ExpectedWithdrawals() ([]*enginev1.Withdrawal, error) {
|
||||
b.lock.RLock()
|
||||
defer b.lock.RUnlock()
|
||||
|
||||
withdrawals := make([]*enginev1.Withdrawal, 0, params.BeaconConfig().MaxWithdrawalsPerPayload)
|
||||
withdrawals := make([]*enginev1.Withdrawal, 0, fieldparams.MaxWithdrawalsPerPayload)
|
||||
validatorIndex := b.nextWithdrawalValidatorIndex
|
||||
withdrawalIndex := b.nextWithdrawalIndex
|
||||
epoch := slots.ToEpoch(b.slot)
|
||||
@@ -75,7 +76,7 @@ func (b *BeaconState) ExpectedWithdrawals() ([]*enginev1.Withdrawal, error) {
|
||||
})
|
||||
withdrawalIndex++
|
||||
}
|
||||
if uint64(len(withdrawals)) == params.BeaconConfig().MaxWithdrawalsPerPayload {
|
||||
if uint64(len(withdrawals)) == fieldparams.MaxWithdrawalsPerPayload {
|
||||
break
|
||||
}
|
||||
validatorIndex += 1
|
||||
|
||||
@@ -26,7 +26,7 @@ func TestNextWithdrawalIndex(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestLastWithdrawalValidatorIndex(t *testing.T) {
|
||||
func TestNextWithdrawalValidatorIndex(t *testing.T) {
|
||||
t.Run("ok", func(t *testing.T) {
|
||||
s := BeaconState{version: version.Capella, nextWithdrawalValidatorIndex: 123}
|
||||
i, err := s.NextWithdrawalValidatorIndex()
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package state_native
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
nativetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
||||
@@ -12,6 +14,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
@@ -255,7 +258,50 @@ func ComputeFieldRootsWithHasher(ctx context.Context, state *BeaconState) ([][]b
|
||||
nextWithdrawalValidatorIndexRoot := make([]byte, 32)
|
||||
binary.LittleEndian.PutUint64(nextWithdrawalValidatorIndexRoot, uint64(state.nextWithdrawalValidatorIndex))
|
||||
fieldRoots[nativetypes.NextWithdrawalValidatorIndex.RealPosition()] = nextWithdrawalValidatorIndexRoot
|
||||
|
||||
// Historical summary root.
|
||||
historicalSummaryRoot, err := historicalSummaryRoot(state.historicalSummaries)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not compute historical summary merkleization")
|
||||
}
|
||||
fieldRoots[nativetypes.HistoricalSummaries.RealPosition()] = historicalSummaryRoot[:]
|
||||
}
|
||||
|
||||
return fieldRoots, nil
|
||||
}
|
||||
|
||||
func historicalSummaryRoot(summaries []*ethpb.HistoricalSummary) ([32]byte, error) {
|
||||
max := uint64(fieldparams.HistoricalRootsLength)
|
||||
if uint64(len(summaries)) > max {
|
||||
return [32]byte{}, fmt.Errorf("historical summary exceeds max length %d", max)
|
||||
}
|
||||
|
||||
hasher := hash.CustomSHA256Hasher()
|
||||
roots := make([][32]byte, len(summaries))
|
||||
for i := 0; i < len(summaries); i++ {
|
||||
r, err := summaries[i].HashTreeRoot()
|
||||
if err != nil {
|
||||
return [32]byte{}, errors.Wrap(err, "could not merkleize historical summary")
|
||||
}
|
||||
roots[i] = r
|
||||
}
|
||||
|
||||
summariesRoot, err := ssz.BitwiseMerkleize(
|
||||
hasher,
|
||||
roots,
|
||||
uint64(len(roots)),
|
||||
fieldparams.HistoricalRootsLength,
|
||||
)
|
||||
if err != nil {
|
||||
return [32]byte{}, errors.Wrap(err, "could not compute epoch attestations merkleization")
|
||||
}
|
||||
summariesLenBuf := new(bytes.Buffer)
|
||||
if err := binary.Write(summariesLenBuf, binary.LittleEndian, uint64(len(summaries))); err != nil {
|
||||
return [32]byte{}, errors.Wrap(err, "could not marshal historical summary length")
|
||||
}
|
||||
// We need to mix in the length of the slice.
|
||||
summariesLenRoot := make([]byte, 32)
|
||||
copy(summariesLenRoot, summariesLenBuf.Bytes())
|
||||
res := ssz.MixInLength(summariesRoot, summariesLenRoot)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package state_native
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
nativetypes "github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/stateutil"
|
||||
@@ -9,6 +11,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -106,11 +109,15 @@ func (b *BeaconState) SetHistoricalRoots(val [][]byte) error {
|
||||
}
|
||||
|
||||
// AppendHistoricalRoots for the beacon state. Appends the new value
|
||||
// to the the end of list.
|
||||
// to the end of list.
|
||||
func (b *BeaconState) AppendHistoricalRoots(root [32]byte) error {
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
if b.version > version.Bellatrix {
|
||||
return fmt.Errorf("AppendHistoricalRoots is not supported for version %d", b.version)
|
||||
}
|
||||
|
||||
roots := b.historicalRoots
|
||||
if b.sharedFieldReferences[nativetypes.HistoricalRoots].Refs() > 1 {
|
||||
roots = make([][32]byte, len(b.historicalRoots))
|
||||
@@ -124,6 +131,29 @@ func (b *BeaconState) AppendHistoricalRoots(root [32]byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AppendHistoricalSummariesUpdate AppendHistoricalSummary for the beacon state. Appends the new value
|
||||
// to the end of list.
|
||||
func (b *BeaconState) AppendHistoricalSummariesUpdate(summary *ethpb.HistoricalSummary) error {
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
if b.version < version.Capella {
|
||||
return fmt.Errorf("AppendHistoricalSummariesUpdate is not supported for version %d", b.version)
|
||||
}
|
||||
|
||||
summaries := b.historicalSummaries
|
||||
if b.sharedFieldReferences[nativetypes.HistoricalSummaries].Refs() > 1 {
|
||||
summaries = make([]*ethpb.HistoricalSummary, len(b.historicalSummaries))
|
||||
copy(summaries, b.historicalSummaries)
|
||||
b.sharedFieldReferences[nativetypes.HistoricalSummaries].MinusRef()
|
||||
b.sharedFieldReferences[nativetypes.HistoricalSummaries] = stateutil.NewRef(1)
|
||||
}
|
||||
|
||||
b.historicalSummaries = append(summaries, summary)
|
||||
b.markFieldAsDirty(nativetypes.HistoricalSummaries)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Recomputes the branch up the index in the Merkle trie representation
|
||||
// of the beacon state. This method performs slice reads and the caller MUST
|
||||
// hold the lock before calling this method.
|
||||
|
||||
@@ -20,7 +20,7 @@ func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetLastWithdrawalValidatorIndex sets the index of the validator which is
|
||||
// SetNexWithdrawalValidatorIndex sets the index of the validator which is
|
||||
// next in line for a partial withdrawal.
|
||||
func (b *BeaconState) SetNextWithdrawalValidatorIndex(i types.ValidatorIndex) error {
|
||||
if b.version < version.Capella {
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestSetNextWithdrawalIndex(t *testing.T) {
|
||||
require.Equal(t, true, s.dirtyFields[nativetypes.NextWithdrawalIndex])
|
||||
}
|
||||
|
||||
func TestSetLastWithdrawalValidatorIndex(t *testing.T) {
|
||||
func TestSetNextWithdrawalValidatorIndex(t *testing.T) {
|
||||
s := BeaconState{
|
||||
version: version.Capella,
|
||||
nextWithdrawalValidatorIndex: 3,
|
||||
|
||||
@@ -82,13 +82,14 @@ var capellaFields = append(
|
||||
nativetypes.LatestExecutionPayloadHeaderCapella,
|
||||
nativetypes.NextWithdrawalIndex,
|
||||
nativetypes.NextWithdrawalValidatorIndex,
|
||||
nativetypes.HistoricalSummaries,
|
||||
)
|
||||
|
||||
const (
|
||||
phase0SharedFieldRefCount = 10
|
||||
altairSharedFieldRefCount = 11
|
||||
bellatrixSharedFieldRefCount = 12
|
||||
capellaSharedFieldRefCount = 13
|
||||
capellaSharedFieldRefCount = 14
|
||||
)
|
||||
|
||||
// InitializeFromProtoPhase0 the beacon state from a protobuf representation.
|
||||
@@ -433,6 +434,7 @@ func InitializeFromProtoUnsafeCapella(st *ethpb.BeaconStateCapella) (state.Beaco
|
||||
latestExecutionPayloadHeaderCapella: st.LatestExecutionPayloadHeader,
|
||||
nextWithdrawalIndex: st.NextWithdrawalIndex,
|
||||
nextWithdrawalValidatorIndex: st.NextWithdrawalValidatorIndex,
|
||||
historicalSummaries: st.HistoricalSummaries,
|
||||
|
||||
dirtyFields: make(map[nativetypes.FieldIndex]bool, fieldCount),
|
||||
dirtyIndices: make(map[nativetypes.FieldIndex][]uint64, fieldCount),
|
||||
@@ -466,6 +468,7 @@ func InitializeFromProtoUnsafeCapella(st *ethpb.BeaconStateCapella) (state.Beaco
|
||||
b.sharedFieldReferences[nativetypes.CurrentEpochParticipationBits] = stateutil.NewRef(1)
|
||||
b.sharedFieldReferences[nativetypes.InactivityScores] = stateutil.NewRef(1)
|
||||
b.sharedFieldReferences[nativetypes.LatestExecutionPayloadHeaderCapella] = stateutil.NewRef(1) // New in Capella.
|
||||
b.sharedFieldReferences[nativetypes.HistoricalSummaries] = stateutil.NewRef(1) // New in Capella.
|
||||
|
||||
state.StateCount.Inc()
|
||||
// Finalizer runs when dst is being destroyed in garbage collection.
|
||||
@@ -530,6 +533,7 @@ func (b *BeaconState) Copy() state.BeaconState {
|
||||
nextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||
latestExecutionPayloadHeader: b.latestExecutionPayloadHeaderVal(),
|
||||
latestExecutionPayloadHeaderCapella: b.latestExecutionPayloadHeaderCapellaVal(),
|
||||
historicalSummaries: b.historicalSummariesVal(),
|
||||
|
||||
dirtyFields: make(map[nativetypes.FieldIndex]bool, fieldCount),
|
||||
dirtyIndices: make(map[nativetypes.FieldIndex][]uint64, fieldCount),
|
||||
@@ -833,6 +837,8 @@ func (b *BeaconState) rootSelector(ctx context.Context, field nativetypes.FieldI
|
||||
return ssz.Uint64Root(b.nextWithdrawalIndex), nil
|
||||
case nativetypes.NextWithdrawalValidatorIndex:
|
||||
return ssz.Uint64Root(uint64(b.nextWithdrawalValidatorIndex)), nil
|
||||
case nativetypes.HistoricalSummaries:
|
||||
return historicalSummaryRoot(b.historicalSummaries)
|
||||
}
|
||||
return [32]byte{}, errors.New("invalid field index provided")
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ func (f FieldIndex) String(_ int) string {
|
||||
return "NextWithdrawalIndex"
|
||||
case NextWithdrawalValidatorIndex:
|
||||
return "NextWithdrawalValidatorIndex"
|
||||
case HistoricalSummaries:
|
||||
return "HistoricalSummaries"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@@ -134,6 +136,8 @@ func (f FieldIndex) RealPosition() int {
|
||||
return 25
|
||||
case NextWithdrawalValidatorIndex:
|
||||
return 26
|
||||
case HistoricalSummaries:
|
||||
return 27
|
||||
default:
|
||||
return -1
|
||||
}
|
||||
@@ -191,4 +195,5 @@ const (
|
||||
LatestExecutionPayloadHeaderCapella
|
||||
NextWithdrawalIndex
|
||||
NextWithdrawalValidatorIndex
|
||||
HistoricalSummaries
|
||||
)
|
||||
|
||||
@@ -174,6 +174,7 @@ var BeaconChainFlags = append(deprecatedBeaconFlags, append(deprecatedFlags, []c
|
||||
disableBroadcastSlashingFlag,
|
||||
enableSlasherFlag,
|
||||
enableHistoricalSpaceRepresentation,
|
||||
disableStakinContractCheck,
|
||||
disablePullTips,
|
||||
disableVecHTR,
|
||||
disableForkChoiceDoublyLinkedTree,
|
||||
|
||||
@@ -227,6 +227,8 @@ func configForkSchedule(b *BeaconChainConfig) map[[fieldparams.VersionLength]byt
|
||||
fvs[bytesutil.ToBytes4(b.AltairForkVersion)] = b.AltairForkEpoch
|
||||
// Set Bellatrix fork data.
|
||||
fvs[bytesutil.ToBytes4(b.BellatrixForkVersion)] = b.BellatrixForkEpoch
|
||||
// Set Capella fork data.
|
||||
fvs[bytesutil.ToBytes4(b.CapellaForkVersion)] = b.CapellaForkEpoch
|
||||
return fvs
|
||||
}
|
||||
|
||||
@@ -238,5 +240,7 @@ func configForkNames(b *BeaconChainConfig) map[[fieldparams.VersionLength]byte]s
|
||||
fvn[bytesutil.ToBytes4(b.AltairForkVersion)] = "altair"
|
||||
// Set Bellatrix fork data.
|
||||
fvn[bytesutil.ToBytes4(b.BellatrixForkVersion)] = "bellatrix"
|
||||
// Set Capella fork data.
|
||||
fvn[bytesutil.ToBytes4(b.CapellaForkVersion)] = "capella"
|
||||
return fvn
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ func InteropConfig() *BeaconChainConfig {
|
||||
c.GenesisForkVersion = []byte{0, 0, 0, 235}
|
||||
c.AltairForkVersion = []byte{1, 0, 0, 235}
|
||||
c.BellatrixForkVersion = []byte{2, 0, 0, 235}
|
||||
c.ShardingForkVersion = []byte{3, 0, 0, 235}
|
||||
c.CapellaForkVersion = []byte{3, 0, 0, 235}
|
||||
c.ShardingForkVersion = []byte{4, 0, 0, 235}
|
||||
|
||||
c.InitializeForkSchedule()
|
||||
return c
|
||||
|
||||
@@ -191,7 +191,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{
|
||||
BeaconStateFieldCount: 21,
|
||||
BeaconStateAltairFieldCount: 24,
|
||||
BeaconStateBellatrixFieldCount: 25,
|
||||
BeaconStateCapellaFieldCount: 27,
|
||||
BeaconStateCapellaFieldCount: 28,
|
||||
|
||||
// Slasher related values.
|
||||
WeakSubjectivityPeriod: 54000,
|
||||
|
||||
@@ -43,7 +43,8 @@ func E2ETestConfig() *BeaconChainConfig {
|
||||
e2eConfig.GenesisForkVersion = []byte{0, 0, 0, 253}
|
||||
e2eConfig.AltairForkVersion = []byte{1, 0, 0, 253}
|
||||
e2eConfig.BellatrixForkVersion = []byte{2, 0, 0, 253}
|
||||
e2eConfig.ShardingForkVersion = []byte{3, 0, 0, 253}
|
||||
e2eConfig.CapellaForkVersion = []byte{3, 0, 0, 253}
|
||||
e2eConfig.ShardingForkVersion = []byte{4, 0, 0, 253}
|
||||
|
||||
e2eConfig.InitializeForkSchedule()
|
||||
return e2eConfig
|
||||
@@ -81,7 +82,8 @@ func E2EMainnetTestConfig() *BeaconChainConfig {
|
||||
e2eConfig.GenesisForkVersion = []byte{0, 0, 0, 254}
|
||||
e2eConfig.AltairForkVersion = []byte{1, 0, 0, 254}
|
||||
e2eConfig.BellatrixForkVersion = []byte{2, 0, 0, 254}
|
||||
e2eConfig.ShardingForkVersion = []byte{3, 0, 0, 254}
|
||||
e2eConfig.CapellaForkVersion = []byte{3, 0, 0, 254}
|
||||
e2eConfig.ShardingForkVersion = []byte{4, 0, 0, 254}
|
||||
|
||||
e2eConfig.InitializeForkSchedule()
|
||||
return e2eConfig
|
||||
|
||||
@@ -32,6 +32,7 @@ func RopstenConfig() *BeaconChainConfig {
|
||||
cfg.AltairForkVersion = []byte{0x80, 0x00, 0x00, 0x70}
|
||||
cfg.BellatrixForkEpoch = 750
|
||||
cfg.BellatrixForkVersion = []byte{0x80, 0x00, 0x00, 0x71}
|
||||
cfg.CapellaForkVersion = []byte{0x80, 0x00, 0x00, 0x72}
|
||||
cfg.TerminalTotalDifficulty = "50000000000000000"
|
||||
cfg.DepositContractAddress = "0x6f22fFbC56eFF051aECF839396DD1eD9aD6BBA9D"
|
||||
cfg.InitializeForkSchedule()
|
||||
|
||||
@@ -16,25 +16,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
)
|
||||
|
||||
func Test_SignedBeaconBlock_SetBlock(t *testing.T) {
|
||||
b := ð.BeaconBlockCapella{Slot: 1, Body: ð.BeaconBlockBodyCapella{ExecutionPayload: &pb.ExecutionPayloadCapella{}}}
|
||||
wb, err := NewBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
wsb, err := NewSignedBeaconBlock(ð.SignedBeaconBlockCapella{
|
||||
Block: ð.BeaconBlockCapella{StateRoot: bytesutil.PadTo([]byte("stateroot"), 32),
|
||||
ParentRoot: bytesutil.PadTo([]byte("parent"), 32),
|
||||
Body: ð.BeaconBlockBodyCapella{
|
||||
RandaoReveal: make([]byte, fieldparams.BLSSignatureLength),
|
||||
Graffiti: make([]byte, fieldparams.RootLength),
|
||||
ExecutionPayload: &pb.ExecutionPayloadCapella{},
|
||||
}},
|
||||
Signature: make([]byte, fieldparams.BLSSignatureLength),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, wsb.SetBlock(wb))
|
||||
require.DeepEqual(t, wsb.Block(), wb)
|
||||
}
|
||||
|
||||
func Test_BeaconBlockIsNil(t *testing.T) {
|
||||
t.Run("not nil", func(t *testing.T) {
|
||||
assert.NoError(t, BeaconBlockIsNil(&SignedBeaconBlock{block: &BeaconBlock{body: &BeaconBlockBody{}}}))
|
||||
|
||||
@@ -13,53 +13,6 @@ func (b *SignedBeaconBlock) SetSignature(sig []byte) {
|
||||
copy(b.signature[:], sig)
|
||||
}
|
||||
|
||||
// SetBlock sets the underlying beacon block object.
|
||||
// This function is not thread safe, it is only used during block creation.
|
||||
func (b *SignedBeaconBlock) SetBlock(blk interfaces.BeaconBlock) error {
|
||||
copied, err := blk.Copy()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.block.slot = copied.Slot()
|
||||
b.block.parentRoot = copied.ParentRoot()
|
||||
b.block.stateRoot = copied.StateRoot()
|
||||
b.block.proposerIndex = copied.ProposerIndex()
|
||||
b.block.body.randaoReveal = copied.Body().RandaoReveal()
|
||||
b.block.body.eth1Data = copied.Body().Eth1Data()
|
||||
b.block.body.graffiti = copied.Body().Graffiti()
|
||||
b.block.body.proposerSlashings = copied.Body().ProposerSlashings()
|
||||
b.block.body.attesterSlashings = copied.Body().AttesterSlashings()
|
||||
b.block.body.attestations = copied.Body().Attestations()
|
||||
b.block.body.deposits = copied.Body().Deposits()
|
||||
b.block.body.voluntaryExits = copied.Body().VoluntaryExits()
|
||||
if b.version >= version.Altair {
|
||||
syncAggregate, err := copied.Body().SyncAggregate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.block.body.syncAggregate = syncAggregate
|
||||
}
|
||||
if b.version >= version.Bellatrix {
|
||||
executionData, err := copied.Body().Execution()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if b.block.body.isBlinded {
|
||||
b.block.body.executionPayloadHeader = executionData
|
||||
} else {
|
||||
b.block.body.executionPayload = executionData
|
||||
}
|
||||
}
|
||||
if b.version >= version.Capella {
|
||||
changes, err := copied.Body().BLSToExecutionChanges()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.block.body.blsToExecutionChanges = changes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetSlot sets the respective slot of the block.
|
||||
// This function is not thread safe, it is only used during block creation.
|
||||
func (b *BeaconBlock) SetSlot(slot types.Slot) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
// a signed beacon block.
|
||||
type SignedBeaconBlock interface {
|
||||
Block() BeaconBlock
|
||||
SetBlock(BeaconBlock) error
|
||||
Signature() [field_params.BLSSignatureLength]byte
|
||||
SetSignature(sig []byte)
|
||||
IsNil() bool
|
||||
|
||||
@@ -113,22 +113,6 @@ func (BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, error)
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) Copy() (interfaces.BeaconBlock, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetSlot(types.Slot) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetProposerIndex(types.ValidatorIndex) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetParentRoot([]byte) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (m BeaconBlock) HashTreeRoot() ([field_params.RootLength]byte, error) {
|
||||
return m.Htr, m.HtrErr
|
||||
}
|
||||
@@ -161,10 +145,6 @@ func (BeaconBlock) IsBlinded() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetBlinded(bool) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) Proto() (proto.Message, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
@@ -193,13 +173,33 @@ func (BeaconBlock) Version() int {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
type BeaconBlockBody struct{}
|
||||
|
||||
func (BeaconBlockBody) RandaoReveal() [field_params.BLSSignatureLength]byte {
|
||||
func (BeaconBlock) ToBlinded() (interfaces.BeaconBlock, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetRandaoReveal([]byte) {
|
||||
func (BeaconBlock) SetSlot(_ types.Slot) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetProposerIndex(_ types.ValidatorIndex) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetParentRoot(_ []byte) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) SetBlinded(_ bool) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlock) Copy() (interfaces.BeaconBlock, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
type BeaconBlockBody struct{}
|
||||
|
||||
func (BeaconBlockBody) RandaoReveal() [field_params.BLSSignatureLength]byte {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
@@ -207,66 +207,34 @@ func (BeaconBlockBody) Eth1Data() *eth.Eth1Data {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetEth1Data(*eth.Eth1Data) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) Graffiti() [field_params.RootLength]byte {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetGraffiti([]byte) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) ProposerSlashings() []*eth.ProposerSlashing {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetProposerSlashings([]*eth.ProposerSlashing) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) AttesterSlashings() []*eth.AttesterSlashing {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetAttesterSlashings([]*eth.AttesterSlashing) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) Attestations() []*eth.Attestation {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetAttestations([]*eth.Attestation) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) Deposits() []*eth.Deposit {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetDeposits([]*eth.Deposit) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) VoluntaryExits() []*eth.SignedVoluntaryExit {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetVoluntaryExits([]*eth.SignedVoluntaryExit) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SyncAggregate() (*eth.SyncAggregate, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetSyncAggregate(*eth.SyncAggregate) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) IsNil() bool {
|
||||
return false
|
||||
}
|
||||
@@ -283,22 +251,58 @@ func (BeaconBlockBody) Execution() (interfaces.ExecutionData, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetExecution(interfaces.ExecutionData) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) BLSToExecutionChanges() ([]*eth.SignedBLSToExecutionChange, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (BeaconBlockBody) SetBLSToExecutionChanges([]*eth.SignedBLSToExecutionChange) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlock) SetStateRoot(root []byte) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetRandaoReveal([]byte) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetEth1Data(*eth.Eth1Data) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetGraffiti([]byte) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetProposerSlashings([]*eth.ProposerSlashing) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetAttesterSlashings([]*eth.AttesterSlashing) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetAttestations([]*eth.Attestation) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetDeposits([]*eth.Deposit) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetVoluntaryExits([]*eth.SignedVoluntaryExit) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetSyncAggregate(*eth.SyncAggregate) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetExecution(interfaces.ExecutionData) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (b *BeaconBlockBody) SetBLSToExecutionChanges([]*eth.SignedBLSToExecutionChange) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
var _ interfaces.SignedBeaconBlock = &SignedBeaconBlock{}
|
||||
var _ interfaces.BeaconBlock = &BeaconBlock{}
|
||||
var _ interfaces.BeaconBlockBody = &BeaconBlockBody{}
|
||||
|
||||
@@ -41,7 +41,6 @@ go_test(
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//testing/assert:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
|
||||
@@ -66,6 +66,8 @@ func FromForkVersion(cv [fieldparams.VersionLength]byte) (*VersionedUnmarshaler,
|
||||
fork = version.Altair
|
||||
case bytesutil.ToBytes4(cfg.BellatrixForkVersion):
|
||||
fork = version.Bellatrix
|
||||
case bytesutil.ToBytes4(cfg.CapellaForkVersion):
|
||||
fork = version.Capella
|
||||
default:
|
||||
return nil, errors.Wrapf(ErrForkNotFound, "version=%#x", cv)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/assert"
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
||||
|
||||
@@ -221,6 +221,29 @@ type executionPayloadJSON struct {
|
||||
Transactions []hexutil.Bytes `json:"transactions"`
|
||||
}
|
||||
|
||||
type getPayloadV2ResponseJson struct {
|
||||
ExecutionPayload *executionPayloadCapellaJSON `json:"executionPayload"`
|
||||
BlockValue string `json:"blockValue"`
|
||||
}
|
||||
|
||||
type executionPayloadCapellaJSON struct {
|
||||
ParentHash *common.Hash `json:"parentHash"`
|
||||
FeeRecipient *common.Address `json:"feeRecipient"`
|
||||
StateRoot *common.Hash `json:"stateRoot"`
|
||||
ReceiptsRoot *common.Hash `json:"receiptsRoot"`
|
||||
LogsBloom *hexutil.Bytes `json:"logsBloom"`
|
||||
PrevRandao *common.Hash `json:"prevRandao"`
|
||||
BlockNumber *hexutil.Uint64 `json:"blockNumber"`
|
||||
GasLimit *hexutil.Uint64 `json:"gasLimit"`
|
||||
GasUsed *hexutil.Uint64 `json:"gasUsed"`
|
||||
Timestamp *hexutil.Uint64 `json:"timestamp"`
|
||||
ExtraData hexutil.Bytes `json:"extraData"`
|
||||
BaseFeePerGas string `json:"baseFeePerGas"`
|
||||
BlockHash *common.Hash `json:"blockHash"`
|
||||
Transactions []hexutil.Bytes `json:"transactions"`
|
||||
Withdrawals []*Withdrawal `json:"withdrawals"`
|
||||
}
|
||||
|
||||
// MarshalJSON --
|
||||
func (e *ExecutionPayload) MarshalJSON() ([]byte, error) {
|
||||
transactions := make([]hexutil.Bytes, len(e.Transactions))
|
||||
@@ -258,6 +281,47 @@ func (e *ExecutionPayload) MarshalJSON() ([]byte, error) {
|
||||
})
|
||||
}
|
||||
|
||||
// MarshalJSON --
|
||||
func (e *ExecutionPayloadCapella) MarshalJSON() ([]byte, error) {
|
||||
transactions := make([]hexutil.Bytes, len(e.Transactions))
|
||||
for i, tx := range e.Transactions {
|
||||
transactions[i] = tx
|
||||
}
|
||||
baseFee := new(big.Int).SetBytes(bytesutil.ReverseByteOrder(e.BaseFeePerGas))
|
||||
baseFeeHex := hexutil.EncodeBig(baseFee)
|
||||
pHash := common.BytesToHash(e.ParentHash)
|
||||
sRoot := common.BytesToHash(e.StateRoot)
|
||||
recRoot := common.BytesToHash(e.ReceiptsRoot)
|
||||
prevRan := common.BytesToHash(e.PrevRandao)
|
||||
bHash := common.BytesToHash(e.BlockHash)
|
||||
blockNum := hexutil.Uint64(e.BlockNumber)
|
||||
gasLimit := hexutil.Uint64(e.GasLimit)
|
||||
gasUsed := hexutil.Uint64(e.GasUsed)
|
||||
timeStamp := hexutil.Uint64(e.Timestamp)
|
||||
recipient := common.BytesToAddress(e.FeeRecipient)
|
||||
logsBloom := hexutil.Bytes(e.LogsBloom)
|
||||
if e.Withdrawals == nil {
|
||||
e.Withdrawals = make([]*Withdrawal, 0)
|
||||
}
|
||||
return json.Marshal(executionPayloadCapellaJSON{
|
||||
ParentHash: &pHash,
|
||||
FeeRecipient: &recipient,
|
||||
StateRoot: &sRoot,
|
||||
ReceiptsRoot: &recRoot,
|
||||
LogsBloom: &logsBloom,
|
||||
PrevRandao: &prevRan,
|
||||
BlockNumber: &blockNum,
|
||||
GasLimit: &gasLimit,
|
||||
GasUsed: &gasUsed,
|
||||
Timestamp: &timeStamp,
|
||||
ExtraData: e.ExtraData,
|
||||
BaseFeePerGas: baseFeeHex,
|
||||
BlockHash: &bHash,
|
||||
Transactions: transactions,
|
||||
Withdrawals: e.Withdrawals,
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalJSON --
|
||||
func (e *ExecutionPayload) UnmarshalJSON(enc []byte) error {
|
||||
dec := executionPayloadJSON{}
|
||||
@@ -331,12 +395,96 @@ func (e *ExecutionPayload) UnmarshalJSON(enc []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON --
|
||||
func (e *ExecutionPayloadCapella) UnmarshalJSON(enc []byte) error {
|
||||
dec := getPayloadV2ResponseJson{}
|
||||
if err := json.Unmarshal(enc, &dec); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if dec.ExecutionPayload.ParentHash == nil {
|
||||
return errors.New("missing required field 'parentHash' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.FeeRecipient == nil {
|
||||
return errors.New("missing required field 'feeRecipient' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.StateRoot == nil {
|
||||
return errors.New("missing required field 'stateRoot' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.ReceiptsRoot == nil {
|
||||
return errors.New("missing required field 'receiptsRoot' for ExecutableDataV1")
|
||||
}
|
||||
if dec.ExecutionPayload.LogsBloom == nil {
|
||||
return errors.New("missing required field 'logsBloom' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.PrevRandao == nil {
|
||||
return errors.New("missing required field 'prevRandao' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.ExtraData == nil {
|
||||
return errors.New("missing required field 'extraData' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.BlockHash == nil {
|
||||
return errors.New("missing required field 'blockHash' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.Transactions == nil {
|
||||
return errors.New("missing required field 'transactions' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.BlockNumber == nil {
|
||||
return errors.New("missing required field 'blockNumber' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.Timestamp == nil {
|
||||
return errors.New("missing required field 'timestamp' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.GasUsed == nil {
|
||||
return errors.New("missing required field 'gasUsed' for ExecutionPayload")
|
||||
}
|
||||
if dec.ExecutionPayload.GasLimit == nil {
|
||||
return errors.New("missing required field 'gasLimit' for ExecutionPayload")
|
||||
}
|
||||
|
||||
*e = ExecutionPayloadCapella{}
|
||||
e.ParentHash = dec.ExecutionPayload.ParentHash.Bytes()
|
||||
e.FeeRecipient = dec.ExecutionPayload.FeeRecipient.Bytes()
|
||||
e.StateRoot = dec.ExecutionPayload.StateRoot.Bytes()
|
||||
e.ReceiptsRoot = dec.ExecutionPayload.ReceiptsRoot.Bytes()
|
||||
e.LogsBloom = *dec.ExecutionPayload.LogsBloom
|
||||
e.PrevRandao = dec.ExecutionPayload.PrevRandao.Bytes()
|
||||
e.BlockNumber = uint64(*dec.ExecutionPayload.BlockNumber)
|
||||
e.GasLimit = uint64(*dec.ExecutionPayload.GasLimit)
|
||||
e.GasUsed = uint64(*dec.ExecutionPayload.GasUsed)
|
||||
e.Timestamp = uint64(*dec.ExecutionPayload.Timestamp)
|
||||
e.ExtraData = dec.ExecutionPayload.ExtraData
|
||||
baseFee, err := hexutil.DecodeBig(dec.ExecutionPayload.BaseFeePerGas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e.BaseFeePerGas = bytesutil.PadTo(bytesutil.ReverseByteOrder(baseFee.Bytes()), fieldparams.RootLength)
|
||||
e.BlockHash = dec.ExecutionPayload.BlockHash.Bytes()
|
||||
transactions := make([][]byte, len(dec.ExecutionPayload.Transactions))
|
||||
for i, tx := range dec.ExecutionPayload.Transactions {
|
||||
transactions[i] = tx
|
||||
}
|
||||
e.Transactions = transactions
|
||||
if dec.ExecutionPayload.Withdrawals == nil {
|
||||
dec.ExecutionPayload.Withdrawals = make([]*Withdrawal, 0)
|
||||
}
|
||||
e.Withdrawals = dec.ExecutionPayload.Withdrawals
|
||||
return nil
|
||||
}
|
||||
|
||||
type payloadAttributesJSON struct {
|
||||
Timestamp hexutil.Uint64 `json:"timestamp"`
|
||||
PrevRandao hexutil.Bytes `json:"prevRandao"`
|
||||
SuggestedFeeRecipient hexutil.Bytes `json:"suggestedFeeRecipient"`
|
||||
}
|
||||
|
||||
type payloadAttributesV2JSON struct {
|
||||
Timestamp hexutil.Uint64 `json:"timestamp"`
|
||||
PrevRandao hexutil.Bytes `json:"prevRandao"`
|
||||
SuggestedFeeRecipient hexutil.Bytes `json:"suggestedFeeRecipient"`
|
||||
Withdrawals []*Withdrawal `json:"withdrawals"`
|
||||
}
|
||||
|
||||
// MarshalJSON --
|
||||
func (p *PayloadAttributes) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(payloadAttributesJSON{
|
||||
@@ -346,6 +494,16 @@ func (p *PayloadAttributes) MarshalJSON() ([]byte, error) {
|
||||
})
|
||||
}
|
||||
|
||||
// MarshalJSON --
|
||||
func (p *PayloadAttributesV2) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(payloadAttributesV2JSON{
|
||||
Timestamp: hexutil.Uint64(p.Timestamp),
|
||||
PrevRandao: p.PrevRandao,
|
||||
SuggestedFeeRecipient: p.SuggestedFeeRecipient,
|
||||
Withdrawals: p.Withdrawals,
|
||||
})
|
||||
}
|
||||
|
||||
// UnmarshalJSON --
|
||||
func (p *PayloadAttributes) UnmarshalJSON(enc []byte) error {
|
||||
dec := payloadAttributesJSON{}
|
||||
@@ -359,6 +517,19 @@ func (p *PayloadAttributes) UnmarshalJSON(enc []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PayloadAttributesV2) UnmarshalJSON(enc []byte) error {
|
||||
dec := payloadAttributesV2JSON{}
|
||||
if err := json.Unmarshal(enc, &dec); err != nil {
|
||||
return err
|
||||
}
|
||||
*p = PayloadAttributesV2{}
|
||||
p.Timestamp = uint64(dec.Timestamp)
|
||||
p.PrevRandao = dec.PrevRandao
|
||||
p.SuggestedFeeRecipient = dec.SuggestedFeeRecipient
|
||||
p.Withdrawals = dec.Withdrawals
|
||||
return nil
|
||||
}
|
||||
|
||||
type payloadStatusJSON struct {
|
||||
LatestValidHash *common.Hash `json:"latestValidHash"`
|
||||
Status string `json:"status"`
|
||||
|
||||
@@ -139,6 +139,63 @@ func TestJsonMarshalUnmarshal(t *testing.T) {
|
||||
require.DeepEqual(t, hash, payloadPb.BlockHash)
|
||||
require.DeepEqual(t, [][]byte{[]byte("hi")}, payloadPb.Transactions)
|
||||
})
|
||||
t.Run("execution payload Capella", func(t *testing.T) {
|
||||
baseFeePerGas := big.NewInt(1770307273)
|
||||
parentHash := bytesutil.PadTo([]byte("parent"), fieldparams.RootLength)
|
||||
feeRecipient := bytesutil.PadTo([]byte("feeRecipient"), fieldparams.FeeRecipientLength)
|
||||
stateRoot := bytesutil.PadTo([]byte("stateRoot"), fieldparams.RootLength)
|
||||
receiptsRoot := bytesutil.PadTo([]byte("receiptsRoot"), fieldparams.RootLength)
|
||||
logsBloom := bytesutil.PadTo([]byte("logs"), fieldparams.LogsBloomLength)
|
||||
random := bytesutil.PadTo([]byte("random"), fieldparams.RootLength)
|
||||
extra := bytesutil.PadTo([]byte("extraData"), fieldparams.RootLength)
|
||||
hash := bytesutil.PadTo([]byte("hash"), fieldparams.RootLength)
|
||||
jsonPayload := &enginev1.ExecutionPayloadCapella{
|
||||
ParentHash: parentHash,
|
||||
FeeRecipient: feeRecipient,
|
||||
StateRoot: stateRoot,
|
||||
ReceiptsRoot: receiptsRoot,
|
||||
LogsBloom: logsBloom,
|
||||
PrevRandao: random,
|
||||
BlockNumber: 1,
|
||||
GasLimit: 2,
|
||||
GasUsed: 3,
|
||||
Timestamp: 4,
|
||||
ExtraData: extra,
|
||||
BaseFeePerGas: baseFeePerGas.Bytes(),
|
||||
BlockHash: hash,
|
||||
Transactions: [][]byte{[]byte("hi")},
|
||||
Withdrawals: []*enginev1.Withdrawal{{
|
||||
Index: 1,
|
||||
ValidatorIndex: 1,
|
||||
Address: bytesutil.PadTo([]byte("address"), 20),
|
||||
Amount: 1,
|
||||
}},
|
||||
}
|
||||
enc, err := json.Marshal(jsonPayload)
|
||||
require.NoError(t, err)
|
||||
payloadPb := &enginev1.ExecutionPayloadCapella{}
|
||||
require.NoError(t, json.Unmarshal(enc, payloadPb))
|
||||
require.DeepEqual(t, parentHash, payloadPb.ParentHash)
|
||||
require.DeepEqual(t, feeRecipient, payloadPb.FeeRecipient)
|
||||
require.DeepEqual(t, stateRoot, payloadPb.StateRoot)
|
||||
require.DeepEqual(t, receiptsRoot, payloadPb.ReceiptsRoot)
|
||||
require.DeepEqual(t, logsBloom, payloadPb.LogsBloom)
|
||||
require.DeepEqual(t, random, payloadPb.PrevRandao)
|
||||
require.DeepEqual(t, uint64(1), payloadPb.BlockNumber)
|
||||
require.DeepEqual(t, uint64(2), payloadPb.GasLimit)
|
||||
require.DeepEqual(t, uint64(3), payloadPb.GasUsed)
|
||||
require.DeepEqual(t, uint64(4), payloadPb.Timestamp)
|
||||
require.DeepEqual(t, extra, payloadPb.ExtraData)
|
||||
require.DeepEqual(t, bytesutil.PadTo(baseFeePerGas.Bytes(), fieldparams.RootLength), payloadPb.BaseFeePerGas)
|
||||
require.DeepEqual(t, hash, payloadPb.BlockHash)
|
||||
require.DeepEqual(t, [][]byte{[]byte("hi")}, payloadPb.Transactions)
|
||||
require.Equal(t, 1, len(payloadPb.Withdrawals))
|
||||
withdrawal := payloadPb.Withdrawals[0]
|
||||
require.Equal(t, uint64(1), withdrawal.Index)
|
||||
require.Equal(t, types.ValidatorIndex(1), withdrawal.ValidatorIndex)
|
||||
require.DeepEqual(t, bytesutil.PadTo([]byte("address"), 20), withdrawal.Address)
|
||||
require.Equal(t, uint64(1), withdrawal.Amount)
|
||||
})
|
||||
t.Run("execution block", func(t *testing.T) {
|
||||
baseFeePerGas := big.NewInt(1770307273)
|
||||
want := &gethtypes.Header{
|
||||
|
||||
14
proto/eth/ext/options.pb.go
generated
14
proto/eth/ext/options.pb.go
generated
@@ -9,9 +9,9 @@ package ext
|
||||
import (
|
||||
reflect "reflect"
|
||||
|
||||
descriptor "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -23,7 +23,7 @@ const (
|
||||
|
||||
var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
{
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50000,
|
||||
Name: "ethereum.eth.ext.cast_type",
|
||||
@@ -31,7 +31,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
Filename: "proto/eth/ext/options.proto",
|
||||
},
|
||||
{
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50001,
|
||||
Name: "ethereum.eth.ext.ssz_size",
|
||||
@@ -39,7 +39,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
Filename: "proto/eth/ext/options.proto",
|
||||
},
|
||||
{
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50002,
|
||||
Name: "ethereum.eth.ext.ssz_max",
|
||||
@@ -47,7 +47,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
Filename: "proto/eth/ext/options.proto",
|
||||
},
|
||||
{
|
||||
ExtendedType: (*descriptorpb.FieldOptions)(nil),
|
||||
ExtendedType: (*descriptor.FieldOptions)(nil),
|
||||
ExtensionType: (*string)(nil),
|
||||
Field: 50003,
|
||||
Name: "ethereum.eth.ext.spec_name",
|
||||
@@ -56,7 +56,7 @@ var file_proto_eth_ext_options_proto_extTypes = []protoimpl.ExtensionInfo{
|
||||
},
|
||||
}
|
||||
|
||||
// Extension fields to descriptorpb.FieldOptions.
|
||||
// Extension fields to descriptor.FieldOptions.
|
||||
var (
|
||||
// optional string cast_type = 50000;
|
||||
E_CastType = &file_proto_eth_ext_options_proto_extTypes[0]
|
||||
@@ -103,7 +103,7 @@ var file_proto_eth_ext_options_proto_rawDesc = []byte{
|
||||
}
|
||||
|
||||
var file_proto_eth_ext_options_proto_goTypes = []interface{}{
|
||||
(*descriptorpb.FieldOptions)(nil), // 0: google.protobuf.FieldOptions
|
||||
(*descriptor.FieldOptions)(nil), // 0: google.protobuf.FieldOptions
|
||||
}
|
||||
var file_proto_eth_ext_options_proto_depIdxs = []int32{
|
||||
0, // 0: ethereum.eth.ext.cast_type:extendee -> google.protobuf.FieldOptions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: ea151ac65a951845c7bff5e78aea6951ca6a0674af711b1b14fea69df1829e84
|
||||
// Hash: fb4dd6cca9018196eaa56d51f14f2e924edf2ea0e1e19e262b24651d34d0fbfd
|
||||
package v1
|
||||
|
||||
import (
|
||||
|
||||
@@ -54,7 +54,7 @@ message BeaconBlockContainerV2 {
|
||||
v1.BeaconBlock phase0_block = 1;
|
||||
BeaconBlockAltair altair_block = 2;
|
||||
BeaconBlockBellatrix bellatrix_block = 3;
|
||||
BeaconBlockCapella capella_block = 4;
|
||||
BeaconBlockCapella capella_block = 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: b0e2b862b471992f748a849f7e9246f72d77985e5d7e83fc704efd1aa1eeb9fa
|
||||
// Hash: 2cffd3782cc740917010a8b85ccc87672ec44cc715579f88b69b3974fd618353
|
||||
package eth
|
||||
|
||||
import (
|
||||
|
||||
@@ -11,7 +11,9 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//beacon-chain/state:go_default_library",
|
||||
"//config/fieldparams:go_default_library",
|
||||
"//consensus-types/interfaces:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//encoding/ssz:go_default_library",
|
||||
"//proto/engine/v1:go_default_library",
|
||||
|
||||
@@ -3,6 +3,8 @@ package migration
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
||||
fieldparams "github.com/prysmaticlabs/prysm/v3/config/fieldparams"
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/v3/encoding/ssz"
|
||||
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
|
||||
@@ -316,6 +318,201 @@ func V1Alpha1BeaconBlockBellatrixToV2Blinded(v1alpha1Block *ethpbalpha.BeaconBlo
|
||||
return v2Block, nil
|
||||
}
|
||||
|
||||
// V1Alpha1BeaconBlockCapellaToV2Blinded converts a v1alpha1 Capella beacon block to a v2
|
||||
// blinded Capella block.
|
||||
func V1Alpha1BeaconBlockCapellaToV2Blinded(v1alpha1Block *ethpbalpha.BeaconBlockCapella) (*ethpbv2.BlindedBeaconBlockCapella, error) {
|
||||
sourceProposerSlashings := v1alpha1Block.Body.ProposerSlashings
|
||||
resultProposerSlashings := make([]*ethpbv1.ProposerSlashing, len(sourceProposerSlashings))
|
||||
for i, s := range sourceProposerSlashings {
|
||||
resultProposerSlashings[i] = ðpbv1.ProposerSlashing{
|
||||
SignedHeader_1: ðpbv1.SignedBeaconBlockHeader{
|
||||
Message: ðpbv1.BeaconBlockHeader{
|
||||
Slot: s.Header_1.Header.Slot,
|
||||
ProposerIndex: s.Header_1.Header.ProposerIndex,
|
||||
ParentRoot: bytesutil.SafeCopyBytes(s.Header_1.Header.ParentRoot),
|
||||
StateRoot: bytesutil.SafeCopyBytes(s.Header_1.Header.StateRoot),
|
||||
BodyRoot: bytesutil.SafeCopyBytes(s.Header_1.Header.BodyRoot),
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(s.Header_1.Signature),
|
||||
},
|
||||
SignedHeader_2: ðpbv1.SignedBeaconBlockHeader{
|
||||
Message: ðpbv1.BeaconBlockHeader{
|
||||
Slot: s.Header_2.Header.Slot,
|
||||
ProposerIndex: s.Header_2.Header.ProposerIndex,
|
||||
ParentRoot: bytesutil.SafeCopyBytes(s.Header_2.Header.ParentRoot),
|
||||
StateRoot: bytesutil.SafeCopyBytes(s.Header_2.Header.StateRoot),
|
||||
BodyRoot: bytesutil.SafeCopyBytes(s.Header_2.Header.BodyRoot),
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(s.Header_2.Signature),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
sourceAttesterSlashings := v1alpha1Block.Body.AttesterSlashings
|
||||
resultAttesterSlashings := make([]*ethpbv1.AttesterSlashing, len(sourceAttesterSlashings))
|
||||
for i, s := range sourceAttesterSlashings {
|
||||
att1Indices := make([]uint64, len(s.Attestation_1.AttestingIndices))
|
||||
copy(att1Indices, s.Attestation_1.AttestingIndices)
|
||||
att2Indices := make([]uint64, len(s.Attestation_2.AttestingIndices))
|
||||
copy(att2Indices, s.Attestation_2.AttestingIndices)
|
||||
resultAttesterSlashings[i] = ðpbv1.AttesterSlashing{
|
||||
Attestation_1: ðpbv1.IndexedAttestation{
|
||||
AttestingIndices: att1Indices,
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: s.Attestation_1.Data.Slot,
|
||||
Index: s.Attestation_1.Data.CommitteeIndex,
|
||||
BeaconBlockRoot: bytesutil.SafeCopyBytes(s.Attestation_1.Data.BeaconBlockRoot),
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: s.Attestation_1.Data.Source.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(s.Attestation_1.Data.Source.Root),
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: s.Attestation_1.Data.Target.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(s.Attestation_1.Data.Target.Root),
|
||||
},
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(s.Attestation_1.Signature),
|
||||
},
|
||||
Attestation_2: ðpbv1.IndexedAttestation{
|
||||
AttestingIndices: att2Indices,
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: s.Attestation_2.Data.Slot,
|
||||
Index: s.Attestation_2.Data.CommitteeIndex,
|
||||
BeaconBlockRoot: bytesutil.SafeCopyBytes(s.Attestation_2.Data.BeaconBlockRoot),
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: s.Attestation_2.Data.Source.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(s.Attestation_2.Data.Source.Root),
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: s.Attestation_2.Data.Target.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(s.Attestation_2.Data.Target.Root),
|
||||
},
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(s.Attestation_2.Signature),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
sourceAttestations := v1alpha1Block.Body.Attestations
|
||||
resultAttestations := make([]*ethpbv1.Attestation, len(sourceAttestations))
|
||||
for i, a := range sourceAttestations {
|
||||
resultAttestations[i] = ðpbv1.Attestation{
|
||||
AggregationBits: bytesutil.SafeCopyBytes(a.AggregationBits),
|
||||
Data: ðpbv1.AttestationData{
|
||||
Slot: a.Data.Slot,
|
||||
Index: a.Data.CommitteeIndex,
|
||||
BeaconBlockRoot: bytesutil.SafeCopyBytes(a.Data.BeaconBlockRoot),
|
||||
Source: ðpbv1.Checkpoint{
|
||||
Epoch: a.Data.Source.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(a.Data.Source.Root),
|
||||
},
|
||||
Target: ðpbv1.Checkpoint{
|
||||
Epoch: a.Data.Target.Epoch,
|
||||
Root: bytesutil.SafeCopyBytes(a.Data.Target.Root),
|
||||
},
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(a.Signature),
|
||||
}
|
||||
}
|
||||
|
||||
sourceDeposits := v1alpha1Block.Body.Deposits
|
||||
resultDeposits := make([]*ethpbv1.Deposit, len(sourceDeposits))
|
||||
for i, d := range sourceDeposits {
|
||||
resultDeposits[i] = ðpbv1.Deposit{
|
||||
Proof: bytesutil.SafeCopy2dBytes(d.Proof),
|
||||
Data: ðpbv1.Deposit_Data{
|
||||
Pubkey: bytesutil.SafeCopyBytes(d.Data.PublicKey),
|
||||
WithdrawalCredentials: bytesutil.SafeCopyBytes(d.Data.WithdrawalCredentials),
|
||||
Amount: d.Data.Amount,
|
||||
Signature: bytesutil.SafeCopyBytes(d.Data.Signature),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
sourceExits := v1alpha1Block.Body.VoluntaryExits
|
||||
resultExits := make([]*ethpbv1.SignedVoluntaryExit, len(sourceExits))
|
||||
for i, e := range sourceExits {
|
||||
resultExits[i] = ðpbv1.SignedVoluntaryExit{
|
||||
Message: ðpbv1.VoluntaryExit{
|
||||
Epoch: e.Exit.Epoch,
|
||||
ValidatorIndex: e.Exit.ValidatorIndex,
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(e.Signature),
|
||||
}
|
||||
}
|
||||
|
||||
transactionsRoot, err := ssz.TransactionsRoot(v1alpha1Block.Body.ExecutionPayload.Transactions)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not calculate transactions root")
|
||||
}
|
||||
|
||||
withdrawalsRoot, err := ssz.WithdrawalSliceRoot(
|
||||
hash.CustomSHA256Hasher(),
|
||||
v1alpha1Block.Body.ExecutionPayload.Withdrawals,
|
||||
fieldparams.MaxWithdrawalsPerPayload,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not calculate transactions root")
|
||||
}
|
||||
|
||||
changes := make([]*ethpbv2.SignedBLSToExecutionChange, len(v1alpha1Block.Body.BlsToExecutionChanges))
|
||||
for i, change := range v1alpha1Block.Body.BlsToExecutionChanges {
|
||||
changes[i] = ðpbv2.SignedBLSToExecutionChange{
|
||||
Message: ðpbv2.BLSToExecutionChange{
|
||||
ValidatorIndex: change.Message.ValidatorIndex,
|
||||
FromBlsPubkey: bytesutil.SafeCopyBytes(change.Message.FromBlsPubkey),
|
||||
ToExecutionAddress: bytesutil.SafeCopyBytes(change.Message.ToExecutionAddress),
|
||||
},
|
||||
Signature: bytesutil.SafeCopyBytes(change.Signature),
|
||||
}
|
||||
}
|
||||
|
||||
resultBlockBody := ðpbv2.BlindedBeaconBlockBodyCapella{
|
||||
RandaoReveal: bytesutil.SafeCopyBytes(v1alpha1Block.Body.RandaoReveal),
|
||||
Eth1Data: ðpbv1.Eth1Data{
|
||||
DepositRoot: bytesutil.SafeCopyBytes(v1alpha1Block.Body.Eth1Data.DepositRoot),
|
||||
DepositCount: v1alpha1Block.Body.Eth1Data.DepositCount,
|
||||
BlockHash: bytesutil.SafeCopyBytes(v1alpha1Block.Body.Eth1Data.BlockHash),
|
||||
},
|
||||
Graffiti: bytesutil.SafeCopyBytes(v1alpha1Block.Body.Graffiti),
|
||||
ProposerSlashings: resultProposerSlashings,
|
||||
AttesterSlashings: resultAttesterSlashings,
|
||||
Attestations: resultAttestations,
|
||||
Deposits: resultDeposits,
|
||||
VoluntaryExits: resultExits,
|
||||
SyncAggregate: ðpbv1.SyncAggregate{
|
||||
SyncCommitteeBits: bytesutil.SafeCopyBytes(v1alpha1Block.Body.SyncAggregate.SyncCommitteeBits),
|
||||
SyncCommitteeSignature: bytesutil.SafeCopyBytes(v1alpha1Block.Body.SyncAggregate.SyncCommitteeSignature),
|
||||
},
|
||||
ExecutionPayloadHeader: &enginev1.ExecutionPayloadHeaderCapella{
|
||||
ParentHash: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.ParentHash),
|
||||
FeeRecipient: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.FeeRecipient),
|
||||
StateRoot: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.StateRoot),
|
||||
ReceiptsRoot: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.ReceiptsRoot),
|
||||
LogsBloom: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.LogsBloom),
|
||||
PrevRandao: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.PrevRandao),
|
||||
BlockNumber: v1alpha1Block.Body.ExecutionPayload.BlockNumber,
|
||||
GasLimit: v1alpha1Block.Body.ExecutionPayload.GasLimit,
|
||||
GasUsed: v1alpha1Block.Body.ExecutionPayload.GasUsed,
|
||||
Timestamp: v1alpha1Block.Body.ExecutionPayload.Timestamp,
|
||||
ExtraData: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.ExtraData),
|
||||
BaseFeePerGas: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.BaseFeePerGas),
|
||||
BlockHash: bytesutil.SafeCopyBytes(v1alpha1Block.Body.ExecutionPayload.BlockHash),
|
||||
TransactionsRoot: transactionsRoot[:],
|
||||
WithdrawalsRoot: withdrawalsRoot[:],
|
||||
},
|
||||
BlsToExecutionChanges: changes,
|
||||
}
|
||||
v2Block := ðpbv2.BlindedBeaconBlockCapella{
|
||||
Slot: v1alpha1Block.Slot,
|
||||
ProposerIndex: v1alpha1Block.ProposerIndex,
|
||||
ParentRoot: bytesutil.SafeCopyBytes(v1alpha1Block.ParentRoot),
|
||||
StateRoot: bytesutil.SafeCopyBytes(v1alpha1Block.StateRoot),
|
||||
Body: resultBlockBody,
|
||||
}
|
||||
return v2Block, nil
|
||||
}
|
||||
|
||||
// BeaconStateAltairToProto converts a state.BeaconState object to its protobuf equivalent.
|
||||
func BeaconStateAltairToProto(altairState state.BeaconState) (*ethpbv2.BeaconState, error) {
|
||||
sourceFork := altairState.Fork()
|
||||
|
||||
1
proto/prysm/storage/beacon_storage.pb.go
generated
1
proto/prysm/storage/beacon_storage.pb.go
generated
@@ -27,6 +27,7 @@ type BeaconStateForStorage struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to StorageState:
|
||||
//
|
||||
// *BeaconStateForStorage_StateV1
|
||||
StorageState isBeaconStateForStorage_StorageState `protobuf_oneof:"storageState"`
|
||||
}
|
||||
|
||||
2
proto/prysm/v1alpha1/beacon_block.pb.go
generated
2
proto/prysm/v1alpha1/beacon_block.pb.go
generated
@@ -31,6 +31,7 @@ type GenericSignedBeaconBlock struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Block:
|
||||
//
|
||||
// *GenericSignedBeaconBlock_Phase0
|
||||
// *GenericSignedBeaconBlock_Altair
|
||||
// *GenericSignedBeaconBlock_Bellatrix
|
||||
@@ -167,6 +168,7 @@ type GenericBeaconBlock struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Block:
|
||||
//
|
||||
// *GenericBeaconBlock_Phase0
|
||||
// *GenericBeaconBlock_Altair
|
||||
// *GenericBeaconBlock_Bellatrix
|
||||
|
||||
2286
proto/prysm/v1alpha1/beacon_chain.pb.go
generated
2286
proto/prysm/v1alpha1/beacon_chain.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -762,6 +762,42 @@ func local_request_BeaconChain_GetIndividualVotes_0(ctx context.Context, marshal
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_BeaconChain_SubmitBLSToExecutionChange_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_BeaconChain_SubmitBLSToExecutionChange_0(ctx context.Context, marshaler runtime.Marshaler, client BeaconChainClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SignedBLSToExecutionChange
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_BeaconChain_SubmitBLSToExecutionChange_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.SubmitBLSToExecutionChange(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_BeaconChain_SubmitBLSToExecutionChange_0(ctx context.Context, marshaler runtime.Marshaler, server BeaconChainServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq SignedBLSToExecutionChange
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_BeaconChain_SubmitBLSToExecutionChange_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.SubmitBLSToExecutionChange(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterBeaconChainHandlerServer registers the http handlers for service BeaconChain to "mux".
|
||||
// UnaryRPC :call BeaconChainServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
@@ -1217,6 +1253,29 @@ func RegisterBeaconChainHandlerServer(ctx context.Context, mux *runtime.ServeMux
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_SubmitBLSToExecutionChange_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/ethereum.eth.v1alpha1.BeaconChain/SubmitBLSToExecutionChange")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_BeaconChain_SubmitBLSToExecutionChange_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_BeaconChain_SubmitBLSToExecutionChange_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1718,6 +1777,26 @@ func RegisterBeaconChainHandlerClient(ctx context.Context, mux *runtime.ServeMux
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_BeaconChain_SubmitBLSToExecutionChange_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/ethereum.eth.v1alpha1.BeaconChain/SubmitBLSToExecutionChange")
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_BeaconChain_SubmitBLSToExecutionChange_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_BeaconChain_SubmitBLSToExecutionChange_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1767,6 +1846,8 @@ var (
|
||||
pattern_BeaconChain_SubmitProposerSlashing_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"eth", "v1alpha1", "beacon", "slashings", "proposer", "submit"}, ""))
|
||||
|
||||
pattern_BeaconChain_GetIndividualVotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"eth", "v1alpha1", "beacon", "individual_votes"}, ""))
|
||||
|
||||
pattern_BeaconChain_SubmitBLSToExecutionChange_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"eth", "v1alpha1", "beacon", "pool", "bls_to_execution_changes", "submit"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -1815,4 +1896,6 @@ var (
|
||||
forward_BeaconChain_SubmitProposerSlashing_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_BeaconChain_GetIndividualVotes_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_BeaconChain_SubmitBLSToExecutionChange_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
||||
@@ -22,6 +22,7 @@ import "proto/eth/ext/options.proto";
|
||||
import "proto/prysm/v1alpha1/attestation.proto";
|
||||
import "proto/prysm/v1alpha1/beacon_block.proto";
|
||||
import "proto/prysm/v1alpha1/validator.proto";
|
||||
import "proto/prysm/v1alpha1/withdrawals.proto";
|
||||
|
||||
option csharp_namespace = "Ethereum.Eth.v1alpha1";
|
||||
option go_package = "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1;eth";
|
||||
@@ -258,6 +259,14 @@ service BeaconChain {
|
||||
get: "/eth/v1alpha1/beacon/individual_votes"
|
||||
};
|
||||
}
|
||||
|
||||
// Submit a BLS_TO_EXECUTION_CHANGE object to the beacon node.
|
||||
rpc SubmitBLSToExecutionChange(SignedBLSToExecutionChange) returns (BLSToExecutionChangeResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/eth/v1alpha1/beacon/pool/bls_to_execution_changes/submit"
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// SetAction defines the type of action that should be applied to the keys in a validator change set.
|
||||
@@ -834,6 +843,10 @@ message SubmitSlashingResponse {
|
||||
repeated uint64 slashed_indices = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"];
|
||||
}
|
||||
|
||||
message BLSToExecutionChangeResponse {
|
||||
}
|
||||
|
||||
|
||||
message IndividualVotesRequest {
|
||||
// Epoch of the request.
|
||||
uint64 epoch = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.Epoch"];
|
||||
@@ -880,4 +893,4 @@ message IndividualVotesRespond {
|
||||
}
|
||||
|
||||
repeated IndividualVote individual_votes = 1;
|
||||
}
|
||||
}
|
||||
|
||||
225
proto/prysm/v1alpha1/beacon_state.pb.go
generated
225
proto/prysm/v1alpha1/beacon_state.pb.go
generated
@@ -1340,6 +1340,7 @@ type BeaconStateCapella struct {
|
||||
LatestExecutionPayloadHeader *v1.ExecutionPayloadHeaderCapella `protobuf:"bytes,10001,opt,name=latest_execution_payload_header,json=latestExecutionPayloadHeader,proto3" json:"latest_execution_payload_header,omitempty"`
|
||||
NextWithdrawalIndex uint64 `protobuf:"varint,11001,opt,name=next_withdrawal_index,json=nextWithdrawalIndex,proto3" json:"next_withdrawal_index,omitempty"`
|
||||
NextWithdrawalValidatorIndex github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex `protobuf:"varint,11002,opt,name=next_withdrawal_validator_index,json=nextWithdrawalValidatorIndex,proto3" json:"next_withdrawal_validator_index,omitempty" cast-type:"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"`
|
||||
HistoricalSummaries []*HistoricalSummary `protobuf:"bytes,11003,rep,name=historical_summaries,json=historicalSummaries,proto3" json:"historical_summaries,omitempty" ssz-max:"16777216"`
|
||||
}
|
||||
|
||||
func (x *BeaconStateCapella) Reset() {
|
||||
@@ -1563,6 +1564,13 @@ func (x *BeaconStateCapella) GetNextWithdrawalValidatorIndex() github_com_prysma
|
||||
return github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(0)
|
||||
}
|
||||
|
||||
func (x *BeaconStateCapella) GetHistoricalSummaries() []*HistoricalSummary {
|
||||
if x != nil {
|
||||
return x.HistoricalSummaries
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type PowBlock struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -1626,6 +1634,61 @@ func (x *PowBlock) GetTotalDifficulty() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
type HistoricalSummary struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BlockSummaryRoot []byte `protobuf:"bytes,1,opt,name=block_summary_root,json=blockSummaryRoot,proto3" json:"block_summary_root,omitempty" ssz-size:"32"`
|
||||
StateSummaryRoot []byte `protobuf:"bytes,2,opt,name=state_summary_root,json=stateSummaryRoot,proto3" json:"state_summary_root,omitempty" ssz-size:"32"`
|
||||
}
|
||||
|
||||
func (x *HistoricalSummary) Reset() {
|
||||
*x = HistoricalSummary{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *HistoricalSummary) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*HistoricalSummary) ProtoMessage() {}
|
||||
|
||||
func (x *HistoricalSummary) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[15]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use HistoricalSummary.ProtoReflect.Descriptor instead.
|
||||
func (*HistoricalSummary) Descriptor() ([]byte, []int) {
|
||||
return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *HistoricalSummary) GetBlockSummaryRoot() []byte {
|
||||
if x != nil {
|
||||
return x.BlockSummaryRoot
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *HistoricalSummary) GetStateSummaryRoot() []byte {
|
||||
if x != nil {
|
||||
return x.StateSummaryRoot
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_proto_prysm_v1alpha1_beacon_state_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{
|
||||
@@ -2073,7 +2136,7 @@ var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{
|
||||
0x69, 0x6e, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x1c, 0x6c,
|
||||
0x61, 0x74, 0x65, 0x73, 0x74, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61,
|
||||
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0x9d, 0x10, 0x0a, 0x12,
|
||||
0x79, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x22, 0x89, 0x11, 0x0a, 0x12,
|
||||
0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x61, 0x70, 0x65, 0x6c,
|
||||
0x6c, 0x61, 0x12, 0x22, 0x0a, 0x0c, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x5f, 0x74, 0x69,
|
||||
0x6d, 0x65, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x67, 0x65, 0x6e, 0x65, 0x73,
|
||||
@@ -2203,27 +2266,41 @@ var file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc = []byte{
|
||||
0x70, 0x65, 0x73, 0x2f, 0x70, 0x72, 0x69, 0x6d, 0x69, 0x74, 0x69, 0x76, 0x65, 0x73, 0x2e, 0x56,
|
||||
0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x1c, 0x6e,
|
||||
0x65, 0x78, 0x74, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x61, 0x6c, 0x56, 0x61, 0x6c,
|
||||
0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x8d, 0x01, 0x0a, 0x08,
|
||||
0x50, 0x6f, 0x77, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63,
|
||||
0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5,
|
||||
0x18, 0x02, 0x33, 0x32, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12,
|
||||
0x27, 0x0a, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61,
|
||||
0x72, 0x65, 0x6e, 0x74, 0x48, 0x61, 0x73, 0x68, 0x12, 0x31, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61,
|
||||
0x6c, 0x5f, 0x64, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x74, 0x6f, 0x74, 0x61,
|
||||
0x6c, 0x44, 0x69, 0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x42, 0x9b, 0x01, 0x0a, 0x19,
|
||||
0x6f, 0x72, 0x67, 0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x10, 0x42, 0x65, 0x61, 0x63, 0x6f,
|
||||
0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61,
|
||||
0x74, 0x69, 0x63, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x33,
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61,
|
||||
0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65,
|
||||
0x72, 0x65, 0x75, 0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x31, 0x41, 0x6c, 0x70, 0x68, 0x61,
|
||||
0x31, 0xca, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68,
|
||||
0x5c, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x6a, 0x0a, 0x14, 0x68,
|
||||
0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72,
|
||||
0x69, 0x65, 0x73, 0x18, 0xfb, 0x55, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x65, 0x74, 0x68,
|
||||
0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
|
||||
0x61, 0x31, 0x2e, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d,
|
||||
0x6d, 0x61, 0x72, 0x79, 0x42, 0x0c, 0x92, 0xb5, 0x18, 0x08, 0x31, 0x36, 0x37, 0x37, 0x37, 0x32,
|
||||
0x31, 0x36, 0x52, 0x13, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75,
|
||||
0x6d, 0x6d, 0x61, 0x72, 0x69, 0x65, 0x73, 0x22, 0x8d, 0x01, 0x0a, 0x08, 0x50, 0x6f, 0x77, 0x42,
|
||||
0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61,
|
||||
0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32,
|
||||
0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x27, 0x0a, 0x0b, 0x70,
|
||||
0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0a, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74,
|
||||
0x48, 0x61, 0x73, 0x68, 0x12, 0x31, 0x0a, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x64, 0x69,
|
||||
0x66, 0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
|
||||
0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x44, 0x69, 0x66,
|
||||
0x66, 0x69, 0x63, 0x75, 0x6c, 0x74, 0x79, 0x22, 0x7f, 0x0a, 0x11, 0x48, 0x69, 0x73, 0x74, 0x6f,
|
||||
0x72, 0x69, 0x63, 0x61, 0x6c, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x34, 0x0a, 0x12,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x6f,
|
||||
0x6f, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06, 0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32,
|
||||
0x52, 0x10, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x6f,
|
||||
0x6f, 0x74, 0x12, 0x34, 0x0a, 0x12, 0x73, 0x74, 0x61, 0x74, 0x65, 0x5f, 0x73, 0x75, 0x6d, 0x6d,
|
||||
0x61, 0x72, 0x79, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x06,
|
||||
0x8a, 0xb5, 0x18, 0x02, 0x33, 0x32, 0x52, 0x10, 0x73, 0x74, 0x61, 0x74, 0x65, 0x53, 0x75, 0x6d,
|
||||
0x6d, 0x61, 0x72, 0x79, 0x52, 0x6f, 0x6f, 0x74, 0x42, 0x9b, 0x01, 0x0a, 0x19, 0x6f, 0x72, 0x67,
|
||||
0x2e, 0x65, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x2e, 0x65, 0x74, 0x68, 0x2e, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x10, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x53, 0x74,
|
||||
0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68,
|
||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x61, 0x74, 0x69, 0x63,
|
||||
0x6c, 0x61, 0x62, 0x73, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x2f, 0x70, 0x72, 0x79, 0x73, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68,
|
||||
0x61, 0x31, 0x3b, 0x65, 0x74, 0x68, 0xaa, 0x02, 0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75,
|
||||
0x6d, 0x2e, 0x45, 0x74, 0x68, 0x2e, 0x56, 0x31, 0x41, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xca, 0x02,
|
||||
0x15, 0x45, 0x74, 0x68, 0x65, 0x72, 0x65, 0x75, 0x6d, 0x5c, 0x45, 0x74, 0x68, 0x5c, 0x76, 0x31,
|
||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -2238,7 +2315,7 @@ func file_proto_prysm_v1alpha1_beacon_state_proto_rawDescGZIP() []byte {
|
||||
return file_proto_prysm_v1alpha1_beacon_state_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
|
||||
var file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
|
||||
var file_proto_prysm_v1alpha1_beacon_state_proto_goTypes = []interface{}{
|
||||
(*BeaconState)(nil), // 0: ethereum.eth.v1alpha1.BeaconState
|
||||
(*BeaconStateAltair)(nil), // 1: ethereum.eth.v1alpha1.BeaconStateAltair
|
||||
@@ -2255,64 +2332,66 @@ var file_proto_prysm_v1alpha1_beacon_state_proto_goTypes = []interface{}{
|
||||
(*BeaconStateBellatrix)(nil), // 12: ethereum.eth.v1alpha1.BeaconStateBellatrix
|
||||
(*BeaconStateCapella)(nil), // 13: ethereum.eth.v1alpha1.BeaconStateCapella
|
||||
(*PowBlock)(nil), // 14: ethereum.eth.v1alpha1.PowBlock
|
||||
(*BeaconBlockHeader)(nil), // 15: ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
(*Eth1Data)(nil), // 16: ethereum.eth.v1alpha1.Eth1Data
|
||||
(*Validator)(nil), // 17: ethereum.eth.v1alpha1.Validator
|
||||
(*Checkpoint)(nil), // 18: ethereum.eth.v1alpha1.Checkpoint
|
||||
(*AttestationData)(nil), // 19: ethereum.eth.v1alpha1.AttestationData
|
||||
(*v1.ExecutionPayloadHeader)(nil), // 20: ethereum.engine.v1.ExecutionPayloadHeader
|
||||
(*v1.ExecutionPayloadHeaderCapella)(nil), // 21: ethereum.engine.v1.ExecutionPayloadHeaderCapella
|
||||
(*HistoricalSummary)(nil), // 15: ethereum.eth.v1alpha1.HistoricalSummary
|
||||
(*BeaconBlockHeader)(nil), // 16: ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
(*Eth1Data)(nil), // 17: ethereum.eth.v1alpha1.Eth1Data
|
||||
(*Validator)(nil), // 18: ethereum.eth.v1alpha1.Validator
|
||||
(*Checkpoint)(nil), // 19: ethereum.eth.v1alpha1.Checkpoint
|
||||
(*AttestationData)(nil), // 20: ethereum.eth.v1alpha1.AttestationData
|
||||
(*v1.ExecutionPayloadHeader)(nil), // 21: ethereum.engine.v1.ExecutionPayloadHeader
|
||||
(*v1.ExecutionPayloadHeaderCapella)(nil), // 22: ethereum.engine.v1.ExecutionPayloadHeaderCapella
|
||||
}
|
||||
var file_proto_prysm_v1alpha1_beacon_state_proto_depIdxs = []int32{
|
||||
2, // 0: ethereum.eth.v1alpha1.BeaconState.fork:type_name -> ethereum.eth.v1alpha1.Fork
|
||||
15, // 1: ethereum.eth.v1alpha1.BeaconState.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
16, // 2: ethereum.eth.v1alpha1.BeaconState.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
16, // 3: ethereum.eth.v1alpha1.BeaconState.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 4: ethereum.eth.v1alpha1.BeaconState.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
16, // 1: ethereum.eth.v1alpha1.BeaconState.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
17, // 2: ethereum.eth.v1alpha1.BeaconState.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 3: ethereum.eth.v1alpha1.BeaconState.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
18, // 4: ethereum.eth.v1alpha1.BeaconState.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
3, // 5: ethereum.eth.v1alpha1.BeaconState.previous_epoch_attestations:type_name -> ethereum.eth.v1alpha1.PendingAttestation
|
||||
3, // 6: ethereum.eth.v1alpha1.BeaconState.current_epoch_attestations:type_name -> ethereum.eth.v1alpha1.PendingAttestation
|
||||
18, // 7: ethereum.eth.v1alpha1.BeaconState.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 8: ethereum.eth.v1alpha1.BeaconState.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 9: ethereum.eth.v1alpha1.BeaconState.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 7: ethereum.eth.v1alpha1.BeaconState.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 8: ethereum.eth.v1alpha1.BeaconState.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 9: ethereum.eth.v1alpha1.BeaconState.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
2, // 10: ethereum.eth.v1alpha1.BeaconStateAltair.fork:type_name -> ethereum.eth.v1alpha1.Fork
|
||||
15, // 11: ethereum.eth.v1alpha1.BeaconStateAltair.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
16, // 12: ethereum.eth.v1alpha1.BeaconStateAltair.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
16, // 13: ethereum.eth.v1alpha1.BeaconStateAltair.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 14: ethereum.eth.v1alpha1.BeaconStateAltair.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
18, // 15: ethereum.eth.v1alpha1.BeaconStateAltair.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 16: ethereum.eth.v1alpha1.BeaconStateAltair.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 17: ethereum.eth.v1alpha1.BeaconStateAltair.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
16, // 11: ethereum.eth.v1alpha1.BeaconStateAltair.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
17, // 12: ethereum.eth.v1alpha1.BeaconStateAltair.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 13: ethereum.eth.v1alpha1.BeaconStateAltair.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
18, // 14: ethereum.eth.v1alpha1.BeaconStateAltair.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
19, // 15: ethereum.eth.v1alpha1.BeaconStateAltair.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 16: ethereum.eth.v1alpha1.BeaconStateAltair.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 17: ethereum.eth.v1alpha1.BeaconStateAltair.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
10, // 18: ethereum.eth.v1alpha1.BeaconStateAltair.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee
|
||||
10, // 19: ethereum.eth.v1alpha1.BeaconStateAltair.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee
|
||||
19, // 20: ethereum.eth.v1alpha1.PendingAttestation.data:type_name -> ethereum.eth.v1alpha1.AttestationData
|
||||
20, // 20: ethereum.eth.v1alpha1.PendingAttestation.data:type_name -> ethereum.eth.v1alpha1.AttestationData
|
||||
2, // 21: ethereum.eth.v1alpha1.CheckPtInfo.fork:type_name -> ethereum.eth.v1alpha1.Fork
|
||||
2, // 22: ethereum.eth.v1alpha1.BeaconStateBellatrix.fork:type_name -> ethereum.eth.v1alpha1.Fork
|
||||
15, // 23: ethereum.eth.v1alpha1.BeaconStateBellatrix.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
16, // 24: ethereum.eth.v1alpha1.BeaconStateBellatrix.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
16, // 25: ethereum.eth.v1alpha1.BeaconStateBellatrix.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 26: ethereum.eth.v1alpha1.BeaconStateBellatrix.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
18, // 27: ethereum.eth.v1alpha1.BeaconStateBellatrix.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 28: ethereum.eth.v1alpha1.BeaconStateBellatrix.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 29: ethereum.eth.v1alpha1.BeaconStateBellatrix.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
16, // 23: ethereum.eth.v1alpha1.BeaconStateBellatrix.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
17, // 24: ethereum.eth.v1alpha1.BeaconStateBellatrix.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 25: ethereum.eth.v1alpha1.BeaconStateBellatrix.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
18, // 26: ethereum.eth.v1alpha1.BeaconStateBellatrix.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
19, // 27: ethereum.eth.v1alpha1.BeaconStateBellatrix.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 28: ethereum.eth.v1alpha1.BeaconStateBellatrix.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 29: ethereum.eth.v1alpha1.BeaconStateBellatrix.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
10, // 30: ethereum.eth.v1alpha1.BeaconStateBellatrix.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee
|
||||
10, // 31: ethereum.eth.v1alpha1.BeaconStateBellatrix.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee
|
||||
20, // 32: ethereum.eth.v1alpha1.BeaconStateBellatrix.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeader
|
||||
21, // 32: ethereum.eth.v1alpha1.BeaconStateBellatrix.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeader
|
||||
2, // 33: ethereum.eth.v1alpha1.BeaconStateCapella.fork:type_name -> ethereum.eth.v1alpha1.Fork
|
||||
15, // 34: ethereum.eth.v1alpha1.BeaconStateCapella.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
16, // 35: ethereum.eth.v1alpha1.BeaconStateCapella.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
16, // 36: ethereum.eth.v1alpha1.BeaconStateCapella.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 37: ethereum.eth.v1alpha1.BeaconStateCapella.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
18, // 38: ethereum.eth.v1alpha1.BeaconStateCapella.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 39: ethereum.eth.v1alpha1.BeaconStateCapella.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
18, // 40: ethereum.eth.v1alpha1.BeaconStateCapella.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
16, // 34: ethereum.eth.v1alpha1.BeaconStateCapella.latest_block_header:type_name -> ethereum.eth.v1alpha1.BeaconBlockHeader
|
||||
17, // 35: ethereum.eth.v1alpha1.BeaconStateCapella.eth1_data:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
17, // 36: ethereum.eth.v1alpha1.BeaconStateCapella.eth1_data_votes:type_name -> ethereum.eth.v1alpha1.Eth1Data
|
||||
18, // 37: ethereum.eth.v1alpha1.BeaconStateCapella.validators:type_name -> ethereum.eth.v1alpha1.Validator
|
||||
19, // 38: ethereum.eth.v1alpha1.BeaconStateCapella.previous_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 39: ethereum.eth.v1alpha1.BeaconStateCapella.current_justified_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
19, // 40: ethereum.eth.v1alpha1.BeaconStateCapella.finalized_checkpoint:type_name -> ethereum.eth.v1alpha1.Checkpoint
|
||||
10, // 41: ethereum.eth.v1alpha1.BeaconStateCapella.current_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee
|
||||
10, // 42: ethereum.eth.v1alpha1.BeaconStateCapella.next_sync_committee:type_name -> ethereum.eth.v1alpha1.SyncCommittee
|
||||
21, // 43: ethereum.eth.v1alpha1.BeaconStateCapella.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella
|
||||
44, // [44:44] is the sub-list for method output_type
|
||||
44, // [44:44] is the sub-list for method input_type
|
||||
44, // [44:44] is the sub-list for extension type_name
|
||||
44, // [44:44] is the sub-list for extension extendee
|
||||
0, // [0:44] is the sub-list for field type_name
|
||||
22, // 43: ethereum.eth.v1alpha1.BeaconStateCapella.latest_execution_payload_header:type_name -> ethereum.engine.v1.ExecutionPayloadHeaderCapella
|
||||
15, // 44: ethereum.eth.v1alpha1.BeaconStateCapella.historical_summaries:type_name -> ethereum.eth.v1alpha1.HistoricalSummary
|
||||
45, // [45:45] is the sub-list for method output_type
|
||||
45, // [45:45] is the sub-list for method input_type
|
||||
45, // [45:45] is the sub-list for extension type_name
|
||||
45, // [45:45] is the sub-list for extension extendee
|
||||
0, // [0:45] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_proto_prysm_v1alpha1_beacon_state_proto_init() }
|
||||
@@ -2504,6 +2583,18 @@ func file_proto_prysm_v1alpha1_beacon_state_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_proto_prysm_v1alpha1_beacon_state_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*HistoricalSummary); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@@ -2511,7 +2602,7 @@ func file_proto_prysm_v1alpha1_beacon_state_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_proto_prysm_v1alpha1_beacon_state_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 15,
|
||||
NumMessages: 16,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@@ -286,6 +286,7 @@ message BeaconStateCapella {
|
||||
// Capella fields [11001-12000]
|
||||
uint64 next_withdrawal_index = 11001; // [New in Capella]
|
||||
uint64 next_withdrawal_validator_index = 11002 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives.ValidatorIndex"]; // [New in Capella]
|
||||
repeated HistoricalSummary historical_summaries = 11003 [(ethereum.eth.ext.ssz_max) = "16777216"];
|
||||
}
|
||||
|
||||
// PowBlock is a definition from Bellatrix fork choice spec to represent a block with total difficulty in the PoW chain.
|
||||
@@ -299,3 +300,9 @@ message PowBlock {
|
||||
bytes parent_hash = 2 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes total_difficulty = 3 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
}
|
||||
|
||||
// HistoricalSummary matches the components of the phase0 `HistoricalBatch` making the two hash_tree_root-compatible.
|
||||
message HistoricalSummary {
|
||||
bytes block_summary_root = 1 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
bytes state_summary_root = 2 [(ethereum.eth.ext.ssz_size) = "32"];
|
||||
}
|
||||
@@ -698,3 +698,18 @@ func CopyBLSToExecutionChanges(changes []*SignedBLSToExecutionChange) []*SignedB
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// CopyHistoricalSummaries copies the historical summaries.
|
||||
func CopyHistoricalSummaries(summaries []*HistoricalSummary) []*HistoricalSummary {
|
||||
if summaries == nil {
|
||||
return nil
|
||||
}
|
||||
newSummaries := make([]*HistoricalSummary, len(summaries))
|
||||
for i, s := range summaries {
|
||||
newSummaries[i] = &HistoricalSummary{
|
||||
BlockSummaryRoot: bytesutil.SafeCopyBytes(s.BlockSummaryRoot),
|
||||
StateSummaryRoot: bytesutil.SafeCopyBytes(s.StateSummaryRoot),
|
||||
}
|
||||
}
|
||||
return newSummaries
|
||||
}
|
||||
|
||||
1
proto/prysm/v1alpha1/debug.pb.go
generated
1
proto/prysm/v1alpha1/debug.pb.go
generated
@@ -186,6 +186,7 @@ type BeaconStateRequest struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to QueryFilter:
|
||||
//
|
||||
// *BeaconStateRequest_Slot
|
||||
// *BeaconStateRequest_BlockRoot
|
||||
QueryFilter isBeaconStateRequest_QueryFilter `protobuf_oneof:"query_filter"`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Code generated by fastssz. DO NOT EDIT.
|
||||
// Hash: 8962105c98680286d2c628c358c5a37aeef5a3f92bfab69b89b13a7510b05da4
|
||||
// Hash: d08fae486cc93e452a2ed773d23d61d03d7435cf9b90e75d7967557b80e7484b
|
||||
package eth
|
||||
|
||||
import (
|
||||
@@ -10070,7 +10070,7 @@ func (b *BeaconStateCapella) MarshalSSZ() ([]byte, error) {
|
||||
// MarshalSSZTo ssz marshals the BeaconStateCapella object to a target array
|
||||
func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
offset := int(2736649)
|
||||
offset := int(2736653)
|
||||
|
||||
// Field (0) 'GenesisTime'
|
||||
dst = ssz.MarshalUint64(dst, b.GenesisTime)
|
||||
@@ -10248,6 +10248,10 @@ func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
// Field (26) 'NextWithdrawalValidatorIndex'
|
||||
dst = ssz.MarshalUint64(dst, uint64(b.NextWithdrawalValidatorIndex))
|
||||
|
||||
// Offset (27) 'HistoricalSummaries'
|
||||
dst = ssz.WriteOffset(dst, offset)
|
||||
offset += len(b.HistoricalSummaries) * 64
|
||||
|
||||
// Field (7) 'HistoricalRoots'
|
||||
if size := len(b.HistoricalRoots); size > 16777216 {
|
||||
err = ssz.ErrListTooBigFn("--.HistoricalRoots", size, 16777216)
|
||||
@@ -10320,6 +10324,17 @@ func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Field (27) 'HistoricalSummaries'
|
||||
if size := len(b.HistoricalSummaries); size > 16777216 {
|
||||
err = ssz.ErrListTooBigFn("--.HistoricalSummaries", size, 16777216)
|
||||
return
|
||||
}
|
||||
for ii := 0; ii < len(b.HistoricalSummaries); ii++ {
|
||||
if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -10327,12 +10342,12 @@ func (b *BeaconStateCapella) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size < 2736649 {
|
||||
if size < 2736653 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
tail := buf
|
||||
var o7, o9, o11, o12, o15, o16, o21, o24 uint64
|
||||
var o7, o9, o11, o12, o15, o16, o21, o24, o27 uint64
|
||||
|
||||
// Field (0) 'GenesisTime'
|
||||
b.GenesisTime = ssz.UnmarshallUint64(buf[0:8])
|
||||
@@ -10385,7 +10400,7 @@ func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
if o7 < 2736649 {
|
||||
if o7 < 2736653 {
|
||||
return ssz.ErrInvalidVariableOffset
|
||||
}
|
||||
|
||||
@@ -10502,6 +10517,11 @@ func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error {
|
||||
// Field (26) 'NextWithdrawalValidatorIndex'
|
||||
b.NextWithdrawalValidatorIndex = github_com_prysmaticlabs_prysm_v3_consensus_types_primitives.ValidatorIndex(ssz.UnmarshallUint64(buf[2736641:2736649]))
|
||||
|
||||
// Offset (27) 'HistoricalSummaries'
|
||||
if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 {
|
||||
return ssz.ErrOffset
|
||||
}
|
||||
|
||||
// Field (7) 'HistoricalRoots'
|
||||
{
|
||||
buf = tail[o7:o9]
|
||||
@@ -10606,7 +10626,7 @@ func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error {
|
||||
|
||||
// Field (24) 'LatestExecutionPayloadHeader'
|
||||
{
|
||||
buf = tail[o24:]
|
||||
buf = tail[o24:o27]
|
||||
if b.LatestExecutionPayloadHeader == nil {
|
||||
b.LatestExecutionPayloadHeader = new(v1.ExecutionPayloadHeaderCapella)
|
||||
}
|
||||
@@ -10614,12 +10634,30 @@ func (b *BeaconStateCapella) UnmarshalSSZ(buf []byte) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Field (27) 'HistoricalSummaries'
|
||||
{
|
||||
buf = tail[o27:]
|
||||
num, err := ssz.DivideInt2(len(buf), 64, 16777216)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.HistoricalSummaries = make([]*HistoricalSummary, num)
|
||||
for ii := 0; ii < num; ii++ {
|
||||
if b.HistoricalSummaries[ii] == nil {
|
||||
b.HistoricalSummaries[ii] = new(HistoricalSummary)
|
||||
}
|
||||
if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateCapella object
|
||||
func (b *BeaconStateCapella) SizeSSZ() (size int) {
|
||||
size = 2736649
|
||||
size = 2736653
|
||||
|
||||
// Field (7) 'HistoricalRoots'
|
||||
size += len(b.HistoricalRoots) * 32
|
||||
@@ -10648,6 +10686,9 @@ func (b *BeaconStateCapella) SizeSSZ() (size int) {
|
||||
}
|
||||
size += b.LatestExecutionPayloadHeader.SizeSSZ()
|
||||
|
||||
// Field (27) 'HistoricalSummaries'
|
||||
size += len(b.HistoricalSummaries) * 64
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -10953,6 +10994,26 @@ func (b *BeaconStateCapella) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
// Field (26) 'NextWithdrawalValidatorIndex'
|
||||
hh.PutUint64(uint64(b.NextWithdrawalValidatorIndex))
|
||||
|
||||
// Field (27) 'HistoricalSummaries'
|
||||
{
|
||||
subIndx := hh.Index()
|
||||
num := uint64(len(b.HistoricalSummaries))
|
||||
if num > 16777216 {
|
||||
err = ssz.ErrIncorrectListSize
|
||||
return
|
||||
}
|
||||
for _, elem := range b.HistoricalSummaries {
|
||||
if err = elem.HashTreeRootWith(hh); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if ssz.EnableVectorizedHTR {
|
||||
hh.MerkleizeWithMixinVectorizedHTR(subIndx, num, 16777216)
|
||||
} else {
|
||||
hh.MerkleizeWithMixin(subIndx, num, 16777216)
|
||||
}
|
||||
}
|
||||
|
||||
if ssz.EnableVectorizedHTR {
|
||||
hh.MerkleizeVectorizedHTR(indx)
|
||||
} else {
|
||||
@@ -11067,6 +11128,92 @@ func (p *PowBlock) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the HistoricalSummary object
|
||||
func (h *HistoricalSummary) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(h)
|
||||
}
|
||||
|
||||
// MarshalSSZTo ssz marshals the HistoricalSummary object to a target array
|
||||
func (h *HistoricalSummary) MarshalSSZTo(buf []byte) (dst []byte, err error) {
|
||||
dst = buf
|
||||
|
||||
// Field (0) 'BlockSummaryRoot'
|
||||
if size := len(h.BlockSummaryRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockSummaryRoot", size, 32)
|
||||
return
|
||||
}
|
||||
dst = append(dst, h.BlockSummaryRoot...)
|
||||
|
||||
// Field (1) 'StateSummaryRoot'
|
||||
if size := len(h.StateSummaryRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateSummaryRoot", size, 32)
|
||||
return
|
||||
}
|
||||
dst = append(dst, h.StateSummaryRoot...)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UnmarshalSSZ ssz unmarshals the HistoricalSummary object
|
||||
func (h *HistoricalSummary) UnmarshalSSZ(buf []byte) error {
|
||||
var err error
|
||||
size := uint64(len(buf))
|
||||
if size != 64 {
|
||||
return ssz.ErrSize
|
||||
}
|
||||
|
||||
// Field (0) 'BlockSummaryRoot'
|
||||
if cap(h.BlockSummaryRoot) == 0 {
|
||||
h.BlockSummaryRoot = make([]byte, 0, len(buf[0:32]))
|
||||
}
|
||||
h.BlockSummaryRoot = append(h.BlockSummaryRoot, buf[0:32]...)
|
||||
|
||||
// Field (1) 'StateSummaryRoot'
|
||||
if cap(h.StateSummaryRoot) == 0 {
|
||||
h.StateSummaryRoot = make([]byte, 0, len(buf[32:64]))
|
||||
}
|
||||
h.StateSummaryRoot = append(h.StateSummaryRoot, buf[32:64]...)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// SizeSSZ returns the ssz encoded size in bytes for the HistoricalSummary object
|
||||
func (h *HistoricalSummary) SizeSSZ() (size int) {
|
||||
size = 64
|
||||
return
|
||||
}
|
||||
|
||||
// HashTreeRoot ssz hashes the HistoricalSummary object
|
||||
func (h *HistoricalSummary) HashTreeRoot() ([32]byte, error) {
|
||||
return ssz.HashWithDefaultHasher(h)
|
||||
}
|
||||
|
||||
// HashTreeRootWith ssz hashes the HistoricalSummary object with a hasher
|
||||
func (h *HistoricalSummary) HashTreeRootWith(hh *ssz.Hasher) (err error) {
|
||||
indx := hh.Index()
|
||||
|
||||
// Field (0) 'BlockSummaryRoot'
|
||||
if size := len(h.BlockSummaryRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.BlockSummaryRoot", size, 32)
|
||||
return
|
||||
}
|
||||
hh.PutBytes(h.BlockSummaryRoot)
|
||||
|
||||
// Field (1) 'StateSummaryRoot'
|
||||
if size := len(h.StateSummaryRoot); size != 32 {
|
||||
err = ssz.ErrBytesLengthFn("--.StateSummaryRoot", size, 32)
|
||||
return
|
||||
}
|
||||
hh.PutBytes(h.StateSummaryRoot)
|
||||
|
||||
if ssz.EnableVectorizedHTR {
|
||||
hh.MerkleizeVectorizedHTR(indx)
|
||||
} else {
|
||||
hh.Merkleize(indx)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// MarshalSSZ ssz marshals the Status object
|
||||
func (s *Status) MarshalSSZ() ([]byte, error) {
|
||||
return ssz.MarshalSSZ(s)
|
||||
|
||||
@@ -138,6 +138,7 @@ type SignRequest struct {
|
||||
SigningRoot []byte `protobuf:"bytes,2,opt,name=signing_root,json=signingRoot,proto3" json:"signing_root,omitempty"`
|
||||
SignatureDomain []byte `protobuf:"bytes,3,opt,name=signature_domain,json=signatureDomain,proto3" json:"signature_domain,omitempty"`
|
||||
// Types that are assignable to Object:
|
||||
//
|
||||
// *SignRequest_Block
|
||||
// *SignRequest_AttestationData
|
||||
// *SignRequest_AggregateAttestationAndProof
|
||||
|
||||
1672
proto/prysm/v1alpha1/validator.pb.go
generated
1672
proto/prysm/v1alpha1/validator.pb.go
generated
File diff suppressed because it is too large
Load Diff
@@ -349,6 +349,9 @@ message StreamBlocksResponse {
|
||||
|
||||
// Representing a bellatrix block.
|
||||
SignedBeaconBlockBellatrix bellatrix_block = 3;
|
||||
|
||||
// Representing a capella block.
|
||||
SignedBeaconBlockCapella capella_block = 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,5 +44,3 @@ message SignedBLSToExecutionChange {
|
||||
// The 96 byte BLS signature from the withdrawal address requesting the change
|
||||
bytes signature = 2 [(ethereum.eth.ext.ssz_size) = "96"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ go_library(
|
||||
"//proto/engine/v1:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//time:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//common/hexutil:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
package interop
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/v3/async"
|
||||
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/signing"
|
||||
@@ -36,9 +40,27 @@ func GenerateGenesisState(ctx context.Context, genesisTime, numValidators uint64
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "could not generate deposit data from keys")
|
||||
}
|
||||
if err := outputPrivateKeys(privKeys); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return GenerateGenesisStateFromDepositData(ctx, genesisTime, depositDataItems, depositDataRoots)
|
||||
}
|
||||
|
||||
func outputPrivateKeys(keys []bls.SecretKey) error {
|
||||
f, err := os.Create("/tmp/privkeys")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w := bufio.NewWriter(f)
|
||||
for _, key := range keys {
|
||||
if _, err := w.WriteString(hexutil.Encode(key.Marshal()) + "\n"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
log.Printf("Done writing genesis state to /tmp/privkeys")
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
// GenerateGenesisStateFromDepositData creates a genesis state given a list of
|
||||
// deposit data items and their corresponding roots.
|
||||
func GenerateGenesisStateFromDepositData(
|
||||
@@ -193,5 +215,5 @@ func createDepositData(privKey bls.SecretKey, pubKey bls.PublicKey) (*ethpb.Depo
|
||||
// where withdrawal_credentials is of type bytes32.
|
||||
func withdrawalCredentialsHash(pubKey []byte) []byte {
|
||||
h := hash.Hash(pubKey)
|
||||
return append([]byte{blsWithdrawalPrefixByte}, h[1:]...)[:32]
|
||||
return append([]byte{0}, h[1:]...)[:32]
|
||||
}
|
||||
|
||||
@@ -13,10 +13,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/crypto/hash"
|
||||
)
|
||||
|
||||
const (
|
||||
blsWithdrawalPrefixByte = byte(0)
|
||||
)
|
||||
|
||||
// DeterministicallyGenerateKeys creates BLS private keys using a fixed curve order according to
|
||||
// the algorithm specified in the Ethereum beacon chain specification interop mock start section found here:
|
||||
// https://github.com/ethereum/eth2.0-pm/blob/a085c9870f3956d6228ed2a40cd37f0c6580ecd7/interop/mocked_start/README.md
|
||||
|
||||
@@ -6,7 +6,7 @@ go_test(
|
||||
srcs = [
|
||||
"effective_balance_updates_test.go",
|
||||
"eth1_data_reset_test.go",
|
||||
"historical_roots_update_test.go",
|
||||
"historical_summaries_update_test.go",
|
||||
"inactivity_updates_test.go",
|
||||
"justification_and_finalization_test.go",
|
||||
"participation_flag_updates_test.go",
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_HistoricalRootsUpdate(t *testing.T) {
|
||||
epoch_processing.RunHistoricalRootsUpdateTests(t, "mainnet")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMainnet_Capella_EpochProcessing_HistoricalSummariesUpdate(t *testing.T) {
|
||||
epoch_processing.RunHistoricalSummariesUpdateTests(t, "mainnet")
|
||||
}
|
||||
@@ -6,7 +6,7 @@ go_test(
|
||||
srcs = [
|
||||
"effective_balance_updates_test.go",
|
||||
"eth1_data_reset_test.go",
|
||||
"historical_roots_update_test.go",
|
||||
"historical_roots_summaries_test.go",
|
||||
"inactivity_updates_test.go",
|
||||
"justification_and_finalization_test.go",
|
||||
"participation_flag_updates_test.go",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_HistoricalSummariesUpdate(t *testing.T) {
|
||||
epoch_processing.RunHistoricalSummariesUpdateTests(t, "minimal")
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package epoch_processing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/shared/capella/epoch_processing"
|
||||
)
|
||||
|
||||
func TestMinimal_Capella_EpochProcessing_HistoricalRootsUpdate(t *testing.T) {
|
||||
epoch_processing.RunHistoricalRootsUpdateTests(t, "minimal")
|
||||
}
|
||||
@@ -27,7 +27,7 @@ func RunHistoricalRootsUpdateTests(t *testing.T, config string) {
|
||||
}
|
||||
|
||||
func processHistoricalRootsUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessHistoricalRootsUpdate(st)
|
||||
st, err := epoch.ProcessHistoricalDataUpdate(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func RunHistoricalRootsUpdateTests(t *testing.T, config string) {
|
||||
}
|
||||
|
||||
func processHistoricalRootsUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessHistoricalRootsUpdate(st)
|
||||
st, err := epoch.ProcessHistoricalDataUpdate(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ go_library(
|
||||
"effective_balance_updates.go",
|
||||
"eth1_data_reset.go",
|
||||
"helpers.go",
|
||||
"historical_roots_update.go",
|
||||
"historical_summaries_update.go",
|
||||
"inactivity_updates.go",
|
||||
"justification_and_finalization.go",
|
||||
"participation_flag_updates.go",
|
||||
|
||||
@@ -10,24 +10,24 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/v3/testing/spectest/utils"
|
||||
)
|
||||
|
||||
// RunHistoricalRootsUpdateTests executes "epoch_processing/historical_roots_update" tests.
|
||||
func RunHistoricalRootsUpdateTests(t *testing.T, config string) {
|
||||
// RunHistoricalSummariesUpdateTests executes "epoch_processing/historical_summaries_update" tests.
|
||||
func RunHistoricalSummariesUpdateTests(t *testing.T, config string) {
|
||||
require.NoError(t, utils.SetConfig(t, config))
|
||||
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/historical_roots_update/pyspec_tests")
|
||||
testFolders, testsFolderPath := utils.TestFolders(t, config, "capella", "epoch_processing/historical_summaries_update/pyspec_tests")
|
||||
if len(testFolders) == 0 {
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/historical_roots_update/pyspec_tests")
|
||||
t.Fatalf("No test folders found for %s/%s/%s", config, "capella", "epoch_processing/historical_summaries_update/pyspec_tests")
|
||||
}
|
||||
for _, folder := range testFolders {
|
||||
t.Run(folder.Name(), func(t *testing.T) {
|
||||
folderPath := path.Join(testsFolderPath, folder.Name())
|
||||
RunEpochOperationTest(t, folderPath, processHistoricalRootsUpdateWrapper)
|
||||
RunEpochOperationTest(t, folderPath, processHistoricalSummariesUpdateWrapper)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func processHistoricalRootsUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessHistoricalRootsUpdate(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
func processHistoricalSummariesUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessHistoricalDataUpdate(st)
|
||||
require.NoError(t, err, "Could not process historical summary updates")
|
||||
return st, nil
|
||||
}
|
||||
@@ -107,6 +107,8 @@ func unmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i
|
||||
obj = ðpb.SyncAggregatorSelectionData{}
|
||||
case "SyncCommittee":
|
||||
obj = ðpb.SyncCommittee{}
|
||||
case "HistoricalSummary":
|
||||
obj = ðpb.HistoricalSummary{}
|
||||
case "LightClientOptimisticUpdate":
|
||||
t.Skip("not a beacon node type, this is a light node type")
|
||||
return nil, nil
|
||||
|
||||
@@ -2,6 +2,7 @@ package forkchoice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@@ -81,15 +82,20 @@ type engineMock struct {
|
||||
func (m *engineMock) GetPayload(context.Context, [8]byte, types.Slot) (interfaces.ExecutionData, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *engineMock) GetPayloadV2(context.Context, [8]byte) (*pb.ExecutionPayloadCapella, error) {
|
||||
return nil, nil
|
||||
}
|
||||
func (m *engineMock) ForkchoiceUpdated(context.Context, *pb.ForkchoiceState, payloadattribute.Attributer) (*pb.PayloadIDBytes, []byte, error) {
|
||||
return nil, m.latestValidHash, m.payloadStatus
|
||||
}
|
||||
func (m *engineMock) ForkchoiceUpdatedV2(context.Context, *pb.ForkchoiceState, *pb.PayloadAttributesV2) (*pb.PayloadIDBytes, []byte, error) {
|
||||
return nil, m.latestValidHash, m.payloadStatus
|
||||
}
|
||||
func (m *engineMock) NewPayload(context.Context, interfaces.ExecutionData) ([]byte, error) {
|
||||
return m.latestValidHash, m.payloadStatus
|
||||
}
|
||||
|
||||
func (m *engineMock) LatestExecutionBlock() (*pb.ExecutionBlock, error) {
|
||||
func (m *engineMock) LatestExecutionBlock(context.Context) (*pb.ExecutionBlock, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -103,7 +109,7 @@ func (m *engineMock) ExecutionBlockByHash(_ context.Context, hash common.Hash, _
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
td := bytesutil.LittleEndianBytesToBigInt(b.TotalDifficulty)
|
||||
td := new(big.Int).SetBytes(bytesutil.ReverseByteOrder(b.TotalDifficulty))
|
||||
tdHex := hexutil.EncodeBig(td)
|
||||
return &pb.ExecutionBlock{
|
||||
Header: gethtypes.Header{
|
||||
|
||||
@@ -27,7 +27,7 @@ func RunHistoricalRootsUpdateTests(t *testing.T, config string) {
|
||||
}
|
||||
|
||||
func processHistoricalRootsUpdateWrapper(t *testing.T, st state.BeaconState) (state.BeaconState, error) {
|
||||
st, err := epoch.ProcessHistoricalRootsUpdate(st)
|
||||
st, err := epoch.ProcessHistoricalDataUpdate(st)
|
||||
require.NoError(t, err, "Could not process final updates")
|
||||
return st, nil
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ func (v *validator) ProposeBlock(ctx context.Context, slot types.Slot, pubKey [f
|
||||
if p.GasLimit() != 0 {
|
||||
log = log.WithField("gasUtilized", float64(p.GasUsed())/float64(p.GasLimit()))
|
||||
}
|
||||
|
||||
if blk.Version() >= version.Capella && !blk.IsBlinded() {
|
||||
withdrawals, err := p.Withdrawals()
|
||||
if err != nil {
|
||||
|
||||
@@ -345,6 +345,8 @@ func (v *validator) ReceiveBlocks(ctx context.Context, connectionErrorChannel ch
|
||||
blk, err = blocks.NewSignedBeaconBlock(b.AltairBlock)
|
||||
case *ethpb.StreamBlocksResponse_BellatrixBlock:
|
||||
blk, err = blocks.NewSignedBeaconBlock(b.BellatrixBlock)
|
||||
case *ethpb.StreamBlocksResponse_CapellaBlock:
|
||||
blk, err = blocks.NewSignedBeaconBlock(b.CapellaBlock)
|
||||
}
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to wrap signed block")
|
||||
|
||||
Reference in New Issue
Block a user