@@ -147,37 +147,37 @@ func (t *StateTest) Subtests() []StateSubtest {
147147}
148148
149149// Run executes a specific subtest and verifies the post-state and logs
150- func (t * StateTest ) Run (subtest StateSubtest , vmconfig vm.Config , snapshotter bool ) (* state.StateDB , error ) {
151- statedb , root , err := t .RunNoVerify (subtest , vmconfig , snapshotter )
150+ func (t * StateTest ) Run (subtest StateSubtest , vmconfig vm.Config , snapshotter bool ) (* snapshot. Tree , * state.StateDB , error ) {
151+ snaps , statedb , root , err := t .RunNoVerify (subtest , vmconfig , snapshotter )
152152 if err != nil {
153- return statedb , err
153+ return snaps , statedb , err
154154 }
155155 post := t .json .Post [subtest .Fork ][subtest .Index ]
156156 // N.B: We need to do this in a two-step process, because the first Commit takes care
157157 // of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
158158 if root != common .Hash (post .Root ) {
159- return statedb , fmt .Errorf ("post state root mismatch: got %x, want %x" , root , post .Root )
159+ return snaps , statedb , fmt .Errorf ("post state root mismatch: got %x, want %x" , root , post .Root )
160160 }
161161 if logs := rlpHash (statedb .Logs ()); logs != common .Hash (post .Logs ) {
162- return statedb , fmt .Errorf ("post state logs hash mismatch: got %x, want %x" , logs , post .Logs )
162+ return snaps , statedb , fmt .Errorf ("post state logs hash mismatch: got %x, want %x" , logs , post .Logs )
163163 }
164- return statedb , nil
164+ return snaps , statedb , nil
165165}
166166
167167// RunNoVerify runs a specific subtest and returns the statedb and post-state root
168- func (t * StateTest ) RunNoVerify (subtest StateSubtest , vmconfig vm.Config , snapshotter bool ) (* state.StateDB , common.Hash , error ) {
168+ func (t * StateTest ) RunNoVerify (subtest StateSubtest , vmconfig vm.Config , snapshotter bool ) (* snapshot. Tree , * state.StateDB , common.Hash , error ) {
169169 config , eips , err := getVMConfig (subtest .Fork )
170170 if err != nil {
171- return nil , common.Hash {}, UnsupportedForkError {subtest .Fork }
171+ return nil , nil , common.Hash {}, UnsupportedForkError {subtest .Fork }
172172 }
173173 vmconfig .ExtraEips = eips
174174 block := t .genesis (config ).ToBlock (nil )
175- statedb := MakePreState (rawdb .NewMemoryDatabase (), t .json .Pre , snapshotter )
175+ snaps , statedb := MakePreState (rawdb .NewMemoryDatabase (), t .json .Pre , snapshotter )
176176
177177 post := t .json .Post [subtest .Fork ][subtest .Index ]
178178 msg , err := t .json .Tx .toMessage (post )
179179 if err != nil {
180- return nil , common.Hash {}, err
180+ return nil , nil , common.Hash {}, err
181181 }
182182 context := core .NewEVMContext (msg , block .Header (), nil , & t .json .Env .Coinbase )
183183 context .GetHash = vmTestBlockHash
@@ -199,14 +199,14 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
199199 statedb .AddBalance (block .Coinbase (), new (big.Int ))
200200 // And _now_ get the state root
201201 root := statedb .IntermediateRoot (config .IsEIP158 (block .Number ()))
202- return statedb , root , nil
202+ return snaps , statedb , root , nil
203203}
204204
205205func (t * StateTest ) gasLimit (subtest StateSubtest ) uint64 {
206206 return t .json .Tx .GasLimit [t .json .Post [subtest .Fork ][subtest .Index ].Indexes .Gas ]
207207}
208208
209- func MakePreState (db ethdb.Database , accounts core.GenesisAlloc , snapshotter bool ) * state.StateDB {
209+ func MakePreState (db ethdb.Database , accounts core.GenesisAlloc , snapshotter bool ) ( * snapshot. Tree , * state.StateDB ) {
210210 sdb := state .NewDatabase (db )
211211 statedb , _ := state .New (common.Hash {}, sdb , nil )
212212 for addr , a := range accounts {
@@ -225,7 +225,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter boo
225225 snaps = snapshot .New (db , sdb .TrieDB (), 1 , root , false )
226226 }
227227 statedb , _ = state .New (root , sdb , snaps )
228- return statedb
228+ return snaps , statedb
229229}
230230
231231func (t * StateTest ) genesis (config * params.ChainConfig ) * core.Genesis {
0 commit comments