prysm-pulse/tools/extractor/main.go
kasey 737e0e0d3a
Use functional options for --blob-retention-epochs (#13283)
* blob retention period functional opts

* missed unstaged change

* missed other init after cleardb

* fix ineffassign

* fix dup import

* config failsafe for tests

---------

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
2023-12-06 20:20:34 +00:00

47 lines
1.1 KiB
Go

package main
import (
"context"
"flag"
"fmt"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/core/transition/interop"
"github.com/prysmaticlabs/prysm/v4/beacon-chain/db/kv"
"github.com/prysmaticlabs/prysm/v4/config/features"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
)
var (
// Required fields
datadir = flag.String("datadir", "", "Path to data directory.")
state = flag.Uint("state", 0, "Extract state at this slot.")
)
func main() {
resetCfg := features.InitWithReset(&features.Flags{WriteSSZStateTransitions: true})
defer resetCfg()
flag.Parse()
fmt.Println("Starting process...")
d, err := kv.NewKVStore(context.Background(), *datadir)
if err != nil {
panic(err)
}
ctx := context.Background()
slot := primitives.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")
}