Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start chain from bellatrix state #11746

Merged
merged 57 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
604688a
WIP trying to start from bellatrix state
kasey Nov 23, 2022
938fca1
env var to control log path with unique paths
kasey Nov 23, 2022
11cbe8f
WIP - grabbing changes from rm-pre-genesis branch
kasey Nov 28, 2022
42808a0
combine bellatrix state w/ rm-pre-genesis branch
kasey Nov 28, 2022
4bae07f
WIP
kasey Nov 29, 2022
ed65688
use encoding/detect for genesis state bytes
kasey Nov 29, 2022
2654e3f
WIP more fixes towards start from bellatrix
kasey Nov 30, 2022
166c284
remove debug wrapping
kasey Nov 30, 2022
f52dbe3
WIP
kasey Nov 30, 2022
3ab486e
multiple bugfixes
kasey Nov 30, 2022
d51fb3a
fix fork ordering bug and bellatrix genesis blocks
kasey Dec 1, 2022
c0297ca
send deposits, spam tx to advance, fix miner alloc
kasey Dec 2, 2022
9108224
WIP
kasey Dec 6, 2022
5cb5ce7
WIP mess
kasey Dec 7, 2022
c8f1d51
WIP
kasey Dec 7, 2022
3040f3a
Print process ID information for purposes of attaching a debugger
prestonvanloon Dec 7, 2022
016a027
bugs: genesis body_root and deposit index mismatch
kasey Dec 7, 2022
7d3e627
fix voting period start, skip altair check
kasey Dec 8, 2022
837fac6
Merge branch 'develop' of https://github.com/prysmaticlabs/geth-shard…
nisdas Dec 8, 2022
1f87322
add changes
nisdas Dec 8, 2022
aa2bbb6
make it better
nisdas Dec 8, 2022
3ef53cb
rm startup FCU, rm logs
kasey Dec 8, 2022
0eed3e8
Merge branch 'develop' into post-merge-genesis-mess2
kasey Dec 9, 2022
ac1fe8e
cleanup import grouping&ordering
kasey Dec 9, 2022
6200a7e
restore FCU log, get rid of tmp var
kasey Dec 9, 2022
095a577
rm newline
kasey Dec 9, 2022
902f05a
restore newline
kasey Dec 9, 2022
f565cf1
restore wrapped error
kasey Dec 9, 2022
54cf8e0
rm newline
kasey Dec 9, 2022
e6ca0a0
removing boot node version override
kasey Dec 12, 2022
8d8b08b
add issue number to todo comment
kasey Dec 12, 2022
26805d7
rm commented code
kasey Dec 12, 2022
d228a9e
rm vmdebug geth flag
kasey Dec 12, 2022
d464d52
unexport values only used with genesis test pkg
kasey Dec 12, 2022
a662191
adding comments to special cases for testnets
kasey Dec 12, 2022
7a24876
migrate comments from PR to actual code :)
kasey Dec 12, 2022
8707cde
rm unused test param
kasey Dec 12, 2022
e25e080
mark e2e spawns exempt from gosec warning
kasey Dec 12, 2022
fa0c0ea
Fix DeepSource errors in `proposer_bellatrix.go` (#11739)
PatriceVignola Dec 10, 2022
5c4f137
Remove `Test_IsExecutionEnabledCapella` (#11752)
terencechain Dec 11, 2022
066ff97
Add REST implementation for Validator's `ProposeBeaconBlock` (#11731)
PatriceVignola Dec 12, 2022
1530dcc
fix validator client (#11755)
rkapka Dec 12, 2022
e5b002b
API `finalized` metadata field - update protos (#11749)
rkapka Dec 12, 2022
1e2cdf3
log breaks unit tests that don't do full arg setup
kasey Dec 12, 2022
1c79dbe
restore prior behavior of phase0 block for altair
kasey Dec 12, 2022
d8894be
update unit tests to account for special case
kasey Dec 13, 2022
959c448
loosen condition for fork version to match config
kasey Dec 13, 2022
b1bd3e4
skip until we can mod configs at runtime
kasey Dec 13, 2022
dddf9cc
Merge branch 'develop' into post-merge-genesis-mess2
kasey Dec 13, 2022
27b5fc3
NewGenesisBlockForState computes state root itself
kasey Dec 13, 2022
3b13278
rm noisy log
kasey Dec 13, 2022
72aef87
this log would be noisy in mainnet
kasey Dec 13, 2022
e02d199
fix format specifier, []byte -> string
kasey Dec 13, 2022
be516d0
core.Genesis UnmarshalJson has a value receiver :)
kasey Dec 13, 2022
b9c3d38
no longer needs to be exported
kasey Dec 13, 2022
da24dd6
Merge branch 'develop' into post-merge-genesis-mess2
kasey Dec 13, 2022
daf7846
Merge branch 'develop' into post-merge-genesis-mess2
kasey Dec 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions beacon-chain/blockchain/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func logBlockSyncStatus(block interfaces.BeaconBlock, blockRoot [32]byte, justif
"version": version.String(block.Version()),
"sinceSlotStartTime": prysmTime.Now().Sub(startTime),
"chainServiceProcessedTime": prysmTime.Now().Sub(receivedTime),
"deposits": len(block.Body().Deposits()),
Copy link
Contributor Author

@kasey kasey Dec 12, 2022

Choose a reason for hiding this comment

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

adding count of deposits in block to this "block synced" log

}).Debug("Synced new block")
} else {
log.WithFields(logrus.Fields{
Expand Down
7 changes: 1 addition & 6 deletions beacon-chain/core/blocks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ go_library(
"withdrawals.go",
],
importpath = "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks",
visibility = [
"//beacon-chain:__subpackages__",
"//testing/spectest:__subpackages__",
"//testing/util:__pkg__",
"//validator:__subpackages__",
],
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/core/helpers:go_default_library",
"//beacon-chain/core/signing:go_default_library",
Expand Down
68 changes: 68 additions & 0 deletions beacon-chain/core/blocks/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
package blocks

import (
"context"

"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/config/params"
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
"github.com/prysmaticlabs/prysm/v3/consensus-types/interfaces"
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
enginev1 "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
)

Expand All @@ -29,3 +36,64 @@ func NewGenesisBlock(stateRoot []byte) *ethpb.SignedBeaconBlock {
}
return block
}

var ErrUnrecognizedState = errors.New("uknonwn underlying type for state.BeaconState value")

func NewGenesisBlockForState(ctx context.Context, st state.BeaconState) (interfaces.SignedBeaconBlock, error) {
root, err := st.HashTreeRoot(ctx)
if err != nil {
return nil, err
}
ps := st.ToProto()
switch ps.(type) {
case *ethpb.BeaconState, *ethpb.BeaconStateAltair:
return blocks.NewSignedBeaconBlock(&ethpb.SignedBeaconBlock{
Block: &ethpb.BeaconBlock{
ParentRoot: params.BeaconConfig().ZeroHash[:],
StateRoot: root[:],
Body: &ethpb.BeaconBlockBody{
RandaoReveal: make([]byte, fieldparams.BLSSignatureLength),
Eth1Data: &ethpb.Eth1Data{
DepositRoot: make([]byte, 32),
BlockHash: make([]byte, 32),
},
Graffiti: make([]byte, 32),
},
},
Signature: params.BeaconConfig().EmptySignature[:],
})
case *ethpb.BeaconStateBellatrix:
return blocks.NewSignedBeaconBlock(&ethpb.SignedBeaconBlockBellatrix{
Block: &ethpb.BeaconBlockBellatrix{
ParentRoot: params.BeaconConfig().ZeroHash[:],
StateRoot: root[:],
Body: &ethpb.BeaconBlockBodyBellatrix{
RandaoReveal: make([]byte, 96),
Eth1Data: &ethpb.Eth1Data{
DepositRoot: make([]byte, 32),
BlockHash: make([]byte, 32),
},
Graffiti: make([]byte, 32),
SyncAggregate: &ethpb.SyncAggregate{
SyncCommitteeBits: make([]byte, fieldparams.SyncCommitteeLength/8),
SyncCommitteeSignature: make([]byte, fieldparams.BLSSignatureLength),
},
ExecutionPayload: &enginev1.ExecutionPayload{
ParentHash: make([]byte, 32),
FeeRecipient: make([]byte, 20),
StateRoot: make([]byte, 32),
ReceiptsRoot: make([]byte, 32),
LogsBloom: make([]byte, 256),
PrevRandao: make([]byte, 32),
BaseFeePerGas: make([]byte, 32),
BlockHash: make([]byte, 32),
Transactions: make([][]byte, 0),
},
},
},
Signature: params.BeaconConfig().EmptySignature[:],
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to add support for the other forks, this can come with the PR to start from other forks (soon).

default:
return nil, ErrUnrecognizedState
}
}
3 changes: 3 additions & 0 deletions beacon-chain/core/transition/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
"log.go",
"skip_slot_cache.go",
"state.go",
"state-bellatrix.go",
"trailing_slot_state_cache.go",
"transition.go",
"transition_no_verify_sig.go",
Expand Down Expand Up @@ -36,6 +37,7 @@ go_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/blocks:go_default_library",
"//consensus-types/interfaces:go_default_library",
Expand All @@ -45,6 +47,7 @@ go_library(
"//encoding/bytesutil:go_default_library",
"//math:go_default_library",
"//monitoring/tracing:go_default_library",
"//proto/engine/v1:go_default_library",
"//proto/prysm/v1alpha1:go_default_library",
"//runtime/version:go_default_library",
"@com_github_pkg_errors//:go_default_library",
Expand Down
Loading