-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
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 938fca1
env var to control log path with unique paths
kasey 11cbe8f
WIP - grabbing changes from rm-pre-genesis branch
kasey 42808a0
combine bellatrix state w/ rm-pre-genesis branch
kasey 4bae07f
WIP
kasey ed65688
use encoding/detect for genesis state bytes
kasey 2654e3f
WIP more fixes towards start from bellatrix
kasey 166c284
remove debug wrapping
kasey f52dbe3
WIP
kasey 3ab486e
multiple bugfixes
kasey d51fb3a
fix fork ordering bug and bellatrix genesis blocks
kasey c0297ca
send deposits, spam tx to advance, fix miner alloc
kasey 9108224
WIP
kasey 5cb5ce7
WIP mess
kasey c8f1d51
WIP
kasey 3040f3a
Print process ID information for purposes of attaching a debugger
prestonvanloon 016a027
bugs: genesis body_root and deposit index mismatch
kasey 7d3e627
fix voting period start, skip altair check
kasey 837fac6
Merge branch 'develop' of https://github.com/prysmaticlabs/geth-shard…
nisdas 1f87322
add changes
nisdas aa2bbb6
make it better
nisdas 3ef53cb
rm startup FCU, rm logs
kasey 0eed3e8
Merge branch 'develop' into post-merge-genesis-mess2
kasey ac1fe8e
cleanup import grouping&ordering
kasey 6200a7e
restore FCU log, get rid of tmp var
kasey 095a577
rm newline
kasey 902f05a
restore newline
kasey f565cf1
restore wrapped error
kasey 54cf8e0
rm newline
kasey e6ca0a0
removing boot node version override
kasey 8d8b08b
add issue number to todo comment
kasey 26805d7
rm commented code
kasey d228a9e
rm vmdebug geth flag
kasey d464d52
unexport values only used with genesis test pkg
kasey a662191
adding comments to special cases for testnets
kasey 7a24876
migrate comments from PR to actual code :)
kasey 8707cde
rm unused test param
kasey e25e080
mark e2e spawns exempt from gosec warning
kasey fa0c0ea
Fix DeepSource errors in `proposer_bellatrix.go` (#11739)
PatriceVignola 5c4f137
Remove `Test_IsExecutionEnabledCapella` (#11752)
terencechain 066ff97
Add REST implementation for Validator's `ProposeBeaconBlock` (#11731)
PatriceVignola 1530dcc
fix validator client (#11755)
rkapka e5b002b
API `finalized` metadata field - update protos (#11749)
rkapka 1e2cdf3
log breaks unit tests that don't do full arg setup
kasey 1c79dbe
restore prior behavior of phase0 block for altair
kasey d8894be
update unit tests to account for special case
kasey 959c448
loosen condition for fork version to match config
kasey b1bd3e4
skip until we can mod configs at runtime
kasey dddf9cc
Merge branch 'develop' into post-merge-genesis-mess2
kasey 27b5fc3
NewGenesisBlockForState computes state root itself
kasey 3b13278
rm noisy log
kasey 72aef87
this log would be noisy in mainnet
kasey e02d199
fix format specifier, []byte -> string
kasey be516d0
core.Genesis UnmarshalJson has a value receiver :)
kasey b9c3d38
no longer needs to be exported
kasey da24dd6
Merge branch 'develop' into post-merge-genesis-mess2
kasey daf7846
Merge branch 'develop' into post-merge-genesis-mess2
kasey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
) | ||
|
||
|
@@ -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(ðpb.SignedBeaconBlock{ | ||
Block: ðpb.BeaconBlock{ | ||
ParentRoot: params.BeaconConfig().ZeroHash[:], | ||
StateRoot: root[:], | ||
Body: ðpb.BeaconBlockBody{ | ||
RandaoReveal: make([]byte, fieldparams.BLSSignatureLength), | ||
Eth1Data: ðpb.Eth1Data{ | ||
DepositRoot: make([]byte, 32), | ||
BlockHash: make([]byte, 32), | ||
}, | ||
Graffiti: make([]byte, 32), | ||
}, | ||
}, | ||
Signature: params.BeaconConfig().EmptySignature[:], | ||
}) | ||
case *ethpb.BeaconStateBellatrix: | ||
return blocks.NewSignedBeaconBlock(ðpb.SignedBeaconBlockBellatrix{ | ||
Block: ðpb.BeaconBlockBellatrix{ | ||
ParentRoot: params.BeaconConfig().ZeroHash[:], | ||
StateRoot: root[:], | ||
Body: ðpb.BeaconBlockBodyBellatrix{ | ||
RandaoReveal: make([]byte, 96), | ||
Eth1Data: ðpb.Eth1Data{ | ||
DepositRoot: make([]byte, 32), | ||
BlockHash: make([]byte, 32), | ||
}, | ||
Graffiti: make([]byte, 32), | ||
SyncAggregate: ðpb.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[:], | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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