@@ -107,7 +107,7 @@ func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, ak authkeeper.
107107 genBlock := ethcore .DefaultGenesisBlock ()
108108 ms := cms .CacheMultiStore ()
109109 ctx := sdk .NewContext (ms , tmproto.Header {}, false , logger )
110- evmKeeper .CommitStateDB . WithContext (ctx )
110+ evmKeeper .WithContext (ctx )
111111
112112 // Set the default Ethermint parameters to the parameter keeper store
113113 evmKeeper .SetParams (ctx , evmtypes .DefaultParams ())
@@ -126,25 +126,19 @@ func createAndTestGenesis(t *testing.T, cms sdk.CommitMultiStore, ak authkeeper.
126126 addr := ethcmn .HexToAddress (addrStr )
127127 acc := genBlock .Alloc [addr ]
128128
129- evmKeeper .CommitStateDB . AddBalance (addr , acc .Balance )
130- evmKeeper .CommitStateDB . SetCode (addr , acc .Code )
131- evmKeeper .CommitStateDB . SetNonce (addr , acc .Nonce )
129+ evmKeeper .AddBalance (addr , acc .Balance )
130+ evmKeeper .SetCode (addr , acc .Code )
131+ evmKeeper .SetNonce (addr , acc .Nonce )
132132
133133 for key , value := range acc .Storage {
134- evmKeeper .CommitStateDB . SetState (addr , key , value )
134+ evmKeeper .SetState (addr , key , value )
135135 }
136136 }
137137
138138 // get balance of one of the genesis account having 400 ETH
139- b := evmKeeper .CommitStateDB . GetBalance (genInvestor )
139+ b := evmKeeper .GetBalance (genInvestor )
140140 require .Equal (t , "200000000000000000000" , b .String ())
141141
142- // commit the stateDB with 'false' to delete empty objects
143- //
144- // NOTE: Commit does not yet return the intra merkle root (version)
145- _ , err := evmKeeper .CommitStateDB .Commit (false )
146- require .NoError (t , err )
147-
148142 // persist multi-store cache state
149143 ms .Write ()
150144
@@ -267,15 +261,13 @@ func TestImportBlocks(t *testing.T) {
267261 ms := cms .CacheMultiStore ()
268262 ctx := sdk .NewContext (ms , tmproto.Header {}, false , logger )
269263 ctx = ctx .WithBlockHeight (int64 (block .NumberU64 ()))
270- evmKeeper .CommitStateDB . WithContext (ctx )
264+ evmKeeper .WithContext (ctx )
271265
272266 if chainConfig .DAOForkSupport && chainConfig .DAOForkBlock != nil && chainConfig .DAOForkBlock .Cmp (block .Number ()) == 0 {
273267 applyDAOHardFork (evmKeeper )
274268 }
275269
276- for i , tx := range block .Transactions () {
277- evmKeeper .CommitStateDB .Prepare (tx .Hash (), block .Hash (), i )
278- // evmKeeper.CommitStateDB.Set(block.Hash())
270+ for _ , tx := range block .Transactions () {
279271
280272 receipt , gas , err := applyTransaction (
281273 chainConfig , chainContext , nil , gp , evmKeeper , header , tx , usedGas , vmConfig ,
@@ -287,10 +279,6 @@ func TestImportBlocks(t *testing.T) {
287279 // apply mining rewards
288280 accumulateRewards (chainConfig , evmKeeper , header , block .Uncles ())
289281
290- // commit stateDB
291- _ , err := evmKeeper .CommitStateDB .Commit (chainConfig .IsEIP158 (block .Number ()))
292- require .NoError (t , err , "failed to commit StateDB" )
293-
294282 // simulate BaseApp EndBlocker commitment
295283 ms .Write ()
296284 cms .Commit ()
@@ -325,12 +313,12 @@ func accumulateRewards(
325313 r .Sub (r , header .Number )
326314 r .Mul (r , blockReward )
327315 r .Div (r , rewardBig8 )
328- evmKeeper .CommitStateDB . AddBalance (uncle .Coinbase , r )
316+ evmKeeper .AddBalance (uncle .Coinbase , r )
329317 r .Div (blockReward , rewardBig32 )
330318 reward .Add (reward , r )
331319 }
332320
333- evmKeeper .CommitStateDB . AddBalance (header .Coinbase , reward )
321+ evmKeeper .AddBalance (header .Coinbase , reward )
334322}
335323
336324// ApplyDAOHardFork modifies the state database according to the DAO hard-fork
@@ -341,14 +329,13 @@ func accumulateRewards(
341329// Ref: https://github.com/ethereum/go-ethereum/blob/52f2461774bcb8cdd310f86b4bc501df5b783852/consensus/misc/dao.go#L74
342330func applyDAOHardFork (evmKeeper * evmkeeper.Keeper ) {
343331 // Retrieve the contract to refund balances into
344- if ! evmKeeper .CommitStateDB . Exist (ethparams .DAORefundContract ) {
345- evmKeeper .CommitStateDB . CreateAccount (ethparams .DAORefundContract )
332+ if ! evmKeeper .Exist (ethparams .DAORefundContract ) {
333+ evmKeeper .CreateAccount (ethparams .DAORefundContract )
346334 }
347335
348336 // Move every DAO account and extra-balance account funds into the refund contract
349337 for _ , addr := range ethparams .DAODrainList () {
350- evmKeeper .CommitStateDB .AddBalance (ethparams .DAORefundContract , evmKeeper .CommitStateDB .GetBalance (addr ))
351- evmKeeper .CommitStateDB .SetBalance (addr , new (big.Int ))
338+ evmKeeper .AddBalance (ethparams .DAORefundContract , evmKeeper .GetBalance (addr ))
352339 }
353340}
354341
@@ -374,7 +361,7 @@ func applyTransaction(
374361
375362 // Create a new environment which holds all relevant information
376363 // about the transaction and calling mechanisms.
377- vmenv := ethvm .NewEVM (blockCtx , txCtx , evmKeeper . CommitStateDB , config , cfg )
364+ vmenv := ethvm .NewEVM (blockCtx , txCtx , evmKeeper , config , cfg )
378365
379366 // Apply the transaction to the current state (included in the env)
380367 execResult , err := ethcore .ApplyMessage (vmenv , msg , gp )
@@ -383,19 +370,11 @@ func applyTransaction(
383370 return & ethtypes.Receipt {}, 0 , nil
384371 }
385372
386- // Update the state with pending changes
387- var intRoot ethcmn.Hash
388- if config .IsByzantium (header .Number ) {
389- err = evmKeeper .CommitStateDB .Finalise (true )
390- } else {
391- intRoot , err = evmKeeper .CommitStateDB .IntermediateRoot (config .IsEIP158 (header .Number ))
392- }
393-
394373 if err != nil {
395374 return nil , execResult .UsedGas , err
396375 }
397376
398- root := intRoot .Bytes ()
377+ root := ethcmn. Hash {} .Bytes ()
399378 * usedGas += execResult .UsedGas
400379
401380 // Create a new receipt for the transaction, storing the intermediate root and gas used by the tx
@@ -410,11 +389,11 @@ func applyTransaction(
410389 }
411390
412391 // Set the receipt logs and create a bloom for filtering
413- receipt .Logs , err = evmKeeper .CommitStateDB . GetLogs (tx .Hash ())
392+ receipt .Logs = evmKeeper .GetTxLogs (tx .Hash ())
414393 receipt .Bloom = ethtypes .CreateBloom (ethtypes.Receipts {receipt })
415- receipt .BlockHash = evmKeeper . CommitStateDB . BlockHash ()
394+ receipt .BlockHash = header . Hash ()
416395 receipt .BlockNumber = header .Number
417- receipt .TransactionIndex = uint (evmKeeper .CommitStateDB . TxIndex ())
396+ receipt .TransactionIndex = uint (evmKeeper .GetTxIndexTransient ())
418397
419398 return receipt , execResult .UsedGas , err
420399}
0 commit comments