mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
9f423617cb
* Added blockBySlot and blockRootBySlot * Changed to BlocksBySlot and BlockRootsBySlot * Updated to use BlocksBySlot and BlockRootsBySlot * Added missing passthrough to karfa exporter * Return hasBlocks/hasBlockRoots in the new getters * Fixed CI lint * Replace call to bytes.Compare with bytes.Equal * Reordered the returns of the new getters Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
46 lines
1006 B
Go
46 lines
1006 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/state/interop"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
|
"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)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
ctx := context.Background()
|
|
slot := uint64(*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")
|
|
}
|