mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-26 05:17:22 +00:00
e30349d410
* Refactor attestation packing slightly to reduce the skip slot / HTR of process slots * Merge branch 'master' into refactor-attestation-packing * gofmt * Merge branch 'refactor-attestation-packing' of github.com:prysmaticlabs/prysm into refactor-attestation-packing * Merge branch 'master' of github.com:prysmaticlabs/prysm into refactor-attestation-packing * Add static analysis to enforce usage of InitWithReset * Add comment / lint * fix a few usages * more fixes for featureconfig.Init * Fix analyzer * Merge branch 'sa-fc-init' of github.com:prysmaticlabs/prysm into sa-fc-init * Merge refs/heads/master into sa-fc-init * Merge refs/heads/master into sa-fc-init
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/cache"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/filters"
|
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
|
)
|
|
|
|
var (
|
|
// Required fields
|
|
datadir = flag.String("datadir", "", "Path to data directory.")
|
|
|
|
state = flag.Uint("state", 0, "Extract state at this slot.")
|
|
)
|
|
|
|
func main() {
|
|
resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{WriteSSZStateTransitions: true})
|
|
defer resetCfg()
|
|
flag.Parse()
|
|
fmt.Println("Starting process...")
|
|
d, err := db.NewDB(*datadir, cache.NewStateSummaryCache())
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
ctx := context.Background()
|
|
slot := uint64(*state)
|
|
roots, err := d.BlockRoots(ctx, filters.NewFilter().SetStartSlot(slot).SetEndSlot(slot))
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if len(roots) != 1 {
|
|
fmt.Printf("Expected 1 block root for slot %d, got %d roots", *state, len(roots))
|
|
}
|
|
s, err := d.State(ctx, roots[0])
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
interop.WriteStateToDisk(s)
|
|
fmt.Println("done")
|
|
}
|