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

Add Debug State Transition Method #13495

Merged
merged 2 commits into from Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 30 additions & 1 deletion tools/pcli/main.go
Expand Up @@ -242,7 +242,7 @@ func main() {
blkRoot,
preStateRoot,
)
postState, err := transition.ExecuteStateTransition(context.Background(), stateObj, block)
postState, err := debugStateTransition(context.Background(), stateObj, block)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -355,3 +355,32 @@ func benchmarkHash(sszPath string, sszType string) {
log.Fatal("Invalid type")
}
}

func debugStateTransition(
ctx context.Context,
st state.BeaconState,
signed interfaces.ReadOnlySignedBeaconBlock,
) (state.BeaconState, error) {
var err error

parentRoot := signed.Block().ParentRoot()
st, err = transition.ProcessSlotsUsingNextSlotCache(ctx, st, parentRoot[:], signed.Block().Slot())
if err != nil {
return st, errors.Wrap(err, "could not process slots")
}

// Execute per block transition.
set, st, err := transition.ProcessBlockNoVerifyAnySig(ctx, st, signed)
if err != nil {
return st, errors.Wrap(err, "could not process block")
}
var valid bool
valid, err = set.VerifyVerbosely()
if err != nil {
return st, errors.Wrap(err, "could not batch verify signature")
}
if !valid {
return st, errors.New("signature in block failed to verify")
}
return st, nil
}