@@ -207,34 +207,32 @@ internal static IEnumerable<ActionEvaluation> EvaluateActions(
207
207
{
208
208
IActionContext CreateActionContext (
209
209
IWorld prevState ,
210
- int randomSeed ,
211
- long actionGasLimit )
210
+ int randomSeed )
212
211
{
213
212
return new ActionContext (
214
213
signer : tx ? . Signer ?? block . Miner ,
215
214
txid : tx ? . Id ?? null ,
216
215
miner : block . Miner ,
217
216
blockIndex : block . Index ,
218
217
blockProtocolVersion : block . ProtocolVersion ,
218
+ lastCommit : block . LastCommit ,
219
219
txs : block . Transactions ,
220
220
previousState : prevState ,
221
221
isPolicyAction : isPolicyAction ,
222
222
randomSeed : randomSeed ,
223
- gasLimit : actionGasLimit ,
223
+ maxGasPrice : tx ? . MaxGasPrice ,
224
224
evidence : block . Evidence ) ;
225
225
}
226
226
227
- long gasLimit = tx ? . GasLimit ?? long . MaxValue ;
228
-
229
227
byte [ ] preEvaluationHashBytes = block . PreEvaluationHash . ToByteArray ( ) ;
230
228
byte [ ] signature = tx ? . Signature ?? Array . Empty < byte > ( ) ;
231
229
int seed = GenerateRandomSeed ( preEvaluationHashBytes , signature , 0 ) ;
232
230
233
231
IWorld state = previousState ;
234
232
foreach ( IAction action in actions )
235
233
{
236
- IActionContext context = CreateActionContext ( state , seed , gasLimit ) ;
237
- ( ActionEvaluation Evaluation , long NextGasLimit ) result = EvaluateAction (
234
+ IActionContext context = CreateActionContext ( state , seed ) ;
235
+ ActionEvaluation evaluation = EvaluateAction (
238
236
block ,
239
237
tx ,
240
238
context ,
@@ -243,10 +241,9 @@ IActionContext CreateActionContext(
243
241
isPolicyAction ,
244
242
logger ) ;
245
243
246
- yield return result . Evaluation ;
244
+ yield return evaluation ;
247
245
248
- state = result . Evaluation . OutputState ;
249
- gasLimit = result . NextGasLimit ;
246
+ state = evaluation . OutputState ;
250
247
251
248
unchecked
252
249
{
@@ -255,7 +252,7 @@ IActionContext CreateActionContext(
255
252
}
256
253
}
257
254
258
- internal static ( ActionEvaluation Evaluation , long NextGasLimit ) EvaluateAction (
255
+ internal static ActionEvaluation EvaluateAction (
259
256
IPreEvaluationBlock block ,
260
257
ITransaction ? tx ,
261
258
IActionContext context ,
@@ -274,7 +271,6 @@ internal static (ActionEvaluation Evaluation, long NextGasLimit) EvaluateAction(
274
271
IActionContext inputContext = context ;
275
272
IWorld state = inputContext . PreviousState ;
276
273
Exception ? exc = null ;
277
- IFeeCollector feeCollector = new FeeCollector ( context , tx ? . MaxGasPrice ) ;
278
274
279
275
IActionContext CreateActionContext ( IWorld newPrevState )
280
276
{
@@ -284,10 +280,11 @@ IActionContext CreateActionContext(IWorld newPrevState)
284
280
miner : inputContext . Miner ,
285
281
blockIndex : inputContext . BlockIndex ,
286
282
blockProtocolVersion : inputContext . BlockProtocolVersion ,
283
+ lastCommit : inputContext . LastCommit ,
287
284
previousState : newPrevState ,
288
285
randomSeed : inputContext . RandomSeed ,
289
286
isPolicyAction : isPolicyAction ,
290
- gasLimit : inputContext . GasLimit ( ) ,
287
+ maxGasPrice : tx ? . MaxGasPrice ,
291
288
txs : inputContext . Txs ,
292
289
evidence : inputContext . Evidence ) ;
293
290
}
@@ -297,9 +294,7 @@ IActionContext CreateActionContext(IWorld newPrevState)
297
294
Stopwatch stopwatch = new Stopwatch ( ) ;
298
295
stopwatch . Start ( ) ;
299
296
AccountMetrics . Initialize ( ) ;
300
- state = feeCollector . Mortgage ( state ) ;
301
297
context = CreateActionContext ( state ) ;
302
- feeCollector = feeCollector . Next ( context ) ;
303
298
state = action . Execute ( context ) ;
304
299
logger ?
305
300
. ForContext ( "Tag" , "Metric" )
@@ -361,8 +356,6 @@ IActionContext CreateActionContext(IWorld newPrevState)
361
356
e ) ;
362
357
}
363
358
364
- state = feeCollector . Refund ( state ) ;
365
- state = feeCollector . Reward ( state ) ;
366
359
state = stateStore . CommitWorld ( state ) ;
367
360
368
361
if ( ! state . Trie . Recorded )
@@ -371,13 +364,11 @@ IActionContext CreateActionContext(IWorld newPrevState)
371
364
$ "Failed to record { nameof ( IAccount ) } 's { nameof ( ITrie ) } .") ;
372
365
}
373
366
374
- return (
375
- new ActionEvaluation (
367
+ return new ActionEvaluation (
376
368
action : action ,
377
369
inputContext : inputContext ,
378
370
outputState : state ,
379
- exception : exc ) ,
380
- context . GasLimit ( ) - context . GasUsed ( ) ) ;
371
+ exception : exc ) ;
381
372
}
382
373
383
374
/// <summary>
@@ -479,6 +470,8 @@ internal IEnumerable<ActionEvaluation> EvaluateTx(
479
470
ITransaction tx ,
480
471
IWorld previousState )
481
472
{
473
+ GasTracer . Initialize ( tx . GasLimit ?? long . MaxValue ) ;
474
+ GasTracer . StartTrace ( ) ;
482
475
var evaluations = ImmutableList < ActionEvaluation > . Empty ;
483
476
if ( _policyActionsRegistry . BeginTxActions . Length > 0 )
484
477
{
@@ -507,6 +500,8 @@ internal IEnumerable<ActionEvaluation> EvaluateTx(
507
500
EvaluatePolicyEndTxActions ( block , tx , previousState ) ) ;
508
501
}
509
502
503
+ GasTracer . EndTrace ( ) ;
504
+
510
505
return evaluations ;
511
506
}
512
507
0 commit comments