From 22da911510956dd3596c9be8a9bbc154e80fcea5 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 19 Dec 2023 19:42:37 +0800 Subject: [PATCH] remove stateless executer command --- cmd/stateless/main.go | 102 ------------------------------------------ 1 file changed, 102 deletions(-) delete mode 100644 cmd/stateless/main.go diff --git a/cmd/stateless/main.go b/cmd/stateless/main.go deleted file mode 100644 index 766ff0cd48..0000000000 --- a/cmd/stateless/main.go +++ /dev/null @@ -1,102 +0,0 @@ -package main - -import ( - "fmt" - "github.com/ethereum/go-ethereum/console/prompt" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/eth/ethconfig" - "github.com/ethereum/go-ethereum/internal/debug" - "github.com/ethereum/go-ethereum/internal/flags" - "github.com/ethereum/go-ethereum/params" - "github.com/urfave/cli/v2" - "go.uber.org/automaxprocs/maxprocs" - "os" -) - -var ( - BlockWitnessFlag = &cli.StringFlag{ - Name: "block-witness", - Usage: "foo bar", - } -) - -var app = flags.NewApp("stateless block executor") - -func init() { - // Initialize the CLI app and start Geth - app.Action = stateless - app.Copyright = "Copyright 2013-2023 The go-ethereum Authors" - - app.Flags = []cli.Flag{ - BlockWitnessFlag, - } - - app.Before = func(ctx *cli.Context) error { - maxprocs.Set() // Automatically set GOMAXPROCS to match Linux container CPU quota. - if err := debug.Setup(ctx); err != nil { - return err - } - return nil - } - app.After = func(ctx *cli.Context) error { - debug.Exit() - prompt.Stdin.Close() // Resets terminal mode. - return nil - } -} - -func stateless(ctx *cli.Context) error { - var vmConfig vm.Config - - blockWitnessPath := ctx.String(BlockWitnessFlag.Name) - if blockWitnessPath == "" { - panic("block witness required") - } - - b, err := os.ReadFile(blockWitnessPath) - if err != nil { - panic(err) - } - - block, witness, err := state.DecodeWitnessRLP(b) - if err != nil { - panic(err) - } - - memoryDb := witness.PopulateMemoryDB() - db, err := state.New(witness.Root(), state.NewDatabase(memoryDb), nil) - if err != nil { - panic(err) - } - - // TODO: we will want to parameterize the chain config. hard-coding here for testing in the mean-time. - chainConfig := params.AllDevChainProtocolChanges //params.MainnetChainConfig - engine, err := ethconfig.CreateConsensusEngine(chainConfig, memoryDb) - if err != nil { - panic(err) - } - validator := core.NewBlockValidator(chainConfig, nil, engine) - processor := core.NewStateProcessor(chainConfig, nil, engine) - - receipts, logs, usedGas, err := processor.ProcessStateless(witness, block, db, vmConfig) - if err != nil { - panic(err) - } - - _ = logs - - if err := validator.ValidateState(block, db, receipts, usedGas); err != nil { - panic(err) - } - - return nil -} - -func main() { - if err := app.Run(os.Args); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -}