2019-10-30 23:05:37 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
|
2021-02-22 23:20:57 +00:00
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
2019-10-30 23:05:37 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
2021-02-15 20:29:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
2019-10-30 23:05:37 +00:00
|
|
|
"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() {
|
2020-04-28 01:13:33 +00:00
|
|
|
resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{WriteSSZStateTransitions: true})
|
|
|
|
defer resetCfg()
|
2019-10-30 23:05:37 +00:00
|
|
|
flag.Parse()
|
|
|
|
fmt.Println("Starting process...")
|
2021-02-15 20:29:47 +00:00
|
|
|
d, err := db.NewDB(context.Background(), *datadir, &kv.Config{})
|
2019-10-30 23:05:37 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
ctx := context.Background()
|
2021-02-16 07:45:34 +00:00
|
|
|
slot := types.Slot(*state)
|
2021-01-12 18:31:15 +00:00
|
|
|
_, roots, err := d.BlockRootsBySlot(ctx, slot)
|
2019-10-30 23:05:37 +00:00
|
|
|
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")
|
|
|
|
}
|