prysm-pulse/tools/extractor/main.go
Victor Farazdagi b577869ed6
Fixes import aliases (#8497)
* Fixes import aliases

* another fix

* reset gw files

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-02-22 23:20:57 +00:00

48 lines
1.1 KiB
Go

package main
import (
"context"
"flag"
"fmt"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
"github.com/prysmaticlabs/prysm/beacon-chain/db"
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
"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(context.Background(), *datadir, &kv.Config{})
if err != nil {
panic(err)
}
ctx := context.Background()
slot := types.Slot(*state)
_, roots, err := d.BlockRootsBySlot(ctx, 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")
}