@@ -75,10 +75,11 @@ var (
7575)
7676
7777type input struct {
78- Alloc types.GenesisAlloc `json:"alloc,omitempty"`
79- Env * stEnv `json:"env,omitempty"`
80- Txs []* txWithKey `json:"txs,omitempty"`
81- TxRlp string `json:"txsRlp,omitempty"`
78+ Alloc types.GenesisAlloc `json:"alloc,omitempty"`
79+ Env * stEnv `json:"env,omitempty"`
80+ VKT map [common.Hash ]hexutil.Bytes `json:"vkt,omitempty"`
81+ Txs []* txWithKey `json:"txs,omitempty"`
82+ TxRlp string `json:"txsRlp,omitempty"`
8283}
8384
8485func Transition (ctx * cli.Context ) error {
@@ -90,16 +91,16 @@ func Transition(ctx *cli.Context) error {
9091 // stdin input or in files.
9192 // Check if anything needs to be read from stdin
9293 var (
93- prestate Prestate
94- txIt txIterator // txs to apply
95- allocStr = ctx .String (InputAllocFlag .Name )
96-
94+ prestate Prestate
95+ txIt txIterator // txs to apply
96+ allocStr = ctx .String (InputAllocFlag .Name )
97+ vktStr = ctx . String ( InputVKTFlag . Name )
9798 envStr = ctx .String (InputEnvFlag .Name )
9899 txStr = ctx .String (InputTxsFlag .Name )
99100 inputData = & input {}
100101 )
101102 // Figure out the prestate alloc
102- if allocStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector {
103+ if allocStr == stdinSelector || vktStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector {
103104 decoder := json .NewDecoder (os .Stdin )
104105 if err := decoder .Decode (inputData ); err != nil {
105106 return NewError (ErrorJson , fmt .Errorf ("failed unmarshalling stdin: %v" , err ))
@@ -110,8 +111,18 @@ func Transition(ctx *cli.Context) error {
110111 return err
111112 }
112113 }
114+ if vktStr != stdinSelector {
115+ if err := readFile (vktStr , "VKT" , & inputData .Alloc ); err != nil {
116+ return err
117+ }
118+ }
113119 prestate .Pre = inputData .Alloc
114-
120+ if vktStr != stdinSelector && vktStr != "" {
121+ if err := readFile (vktStr , "VKT" , & inputData .VKT ); err != nil {
122+ return err
123+ }
124+ }
125+ prestate .VKT = inputData .VKT
115126 // Set the block environment
116127 if envStr != stdinSelector {
117128 var env stEnv
@@ -183,8 +194,14 @@ func Transition(ctx *cli.Context) error {
183194 }
184195 // Dump the execution result
185196 collector := make (Alloc )
186- s .DumpToCollector (collector , nil )
187- return dispatchOutput (ctx , baseDir , result , collector , body )
197+ var vktleaves map [common.Hash ]hexutil.Bytes
198+ if ! chainConfig .IsVerkle (big .NewInt (int64 (prestate .Env .Number )), prestate .Env .Timestamp ) {
199+ s .DumpToCollector (collector , nil )
200+ } else {
201+ vktleaves = make (map [common.Hash ]hexutil.Bytes )
202+ s .DumpVKTLeaves (vktleaves )
203+ }
204+ return dispatchOutput (ctx , baseDir , result , collector , body , vktleaves )
188205}
189206
190207func applyLondonChecks (env * stEnv , chainConfig * params.ChainConfig ) error {
@@ -306,7 +323,7 @@ func saveFile(baseDir, filename string, data interface{}) error {
306323
307324// dispatchOutput writes the output data to either stderr or stdout, or to the specified
308325// files
309- func dispatchOutput (ctx * cli.Context , baseDir string , result * ExecutionResult , alloc Alloc , body hexutil.Bytes ) error {
326+ func dispatchOutput (ctx * cli.Context , baseDir string , result * ExecutionResult , alloc Alloc , body hexutil.Bytes , vkt map [common. Hash ]hexutil. Bytes ) error {
310327 stdOutObject := make (map [string ]interface {})
311328 stdErrObject := make (map [string ]interface {})
312329 dispatch := func (baseDir , fName , name string , obj interface {}) error {
@@ -333,6 +350,11 @@ func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, a
333350 if err := dispatch (baseDir , ctx .String (OutputBodyFlag .Name ), "body" , body ); err != nil {
334351 return err
335352 }
353+ if vkt != nil {
354+ if err := dispatch (baseDir , ctx .String (OutputVKTFlag .Name ), "vkt" , vkt ); err != nil {
355+ return err
356+ }
357+ }
336358 if len (stdOutObject ) > 0 {
337359 b , err := json .MarshalIndent (stdOutObject , "" , " " )
338360 if err != nil {
0 commit comments