Skip to content

Commit

Permalink
move to Params struct
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc committed Nov 1, 2023
1 parent eec33c3 commit 0403f9b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions action/protocol/execution/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ type (
evmConfig vm.Config
chainConfig *params.ChainConfig
blkCtx protocol.BlockCtx
genesis genesis.Blockchain
featureCtx protocol.FeatureCtx
actionCtx protocol.ActionCtx
}
)

Expand Down Expand Up @@ -190,6 +193,9 @@ func newParams(
vmConfig,
chainConfig,
blkCtx,
g.Blockchain,
featureCtx,
actionCtx,
}, nil
}

Expand Down Expand Up @@ -222,10 +228,7 @@ func ExecuteContract(
) ([]byte, *action.Receipt, error) {
ctx, span := tracer.NewSpan(ctx, "evm.ExecuteContract")
defer span.End()
actionCtx := protocol.MustGetActionCtx(ctx)
blkCtx := protocol.MustGetBlockCtx(ctx)
g := genesis.MustExtractGenesisContext(ctx)
featureCtx := protocol.MustGetFeatureCtx(ctx)

stateDB, err := prepareStateDB(ctx, sm)
if err != nil {
return nil, nil, err
Expand All @@ -234,7 +237,10 @@ func ExecuteContract(
if err != nil {
return nil, nil, err
}
retval, depositGas, remainingGas, contractAddress, statusCode, err := executeInEVM(ctx, ps, stateDB, g.Blockchain)
actionCtx := ps.actionCtx
blkCtx := ps.blkCtx
featureCtx := ps.featureCtx
retval, depositGas, remainingGas, contractAddress, statusCode, err := executeInEVM(ps, stateDB)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -416,9 +422,10 @@ func getChainConfig(g genesis.Blockchain, height uint64, id uint32) *params.Chai
}

// Error in executeInEVM is a consensus issue
func executeInEVM(ctx context.Context, evmParams *Params, stateDB *StateDBAdapter, g genesis.Blockchain) ([]byte, uint64, uint64, string, iotextypes.ReceiptStatus, error) {
func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, uint64, string, iotextypes.ReceiptStatus, error) {
gasLimit := evmParams.blkCtx.GasLimit
blockHeight := evmParams.blkCtx.BlockHeight
g := evmParams.genesis
remainingGas := evmParams.gas
if err := securityDeposit(evmParams, stateDB, gasLimit); err != nil {
log.L().Warn("unexpected error: not enough security deposit", zap.Error(err))
Expand Down Expand Up @@ -493,7 +500,7 @@ func executeInEVM(ctx context.Context, evmParams *Params, stateDB *StateDBAdapte
// the tx is reverted. After Okhotsk height, it is fixed inside RevertToSnapshot()
var (
deltaRefundByDynamicGas = evm.DeltaRefundByDynamicGas
featureCtx = protocol.MustGetFeatureCtx(ctx)
featureCtx = evmParams.featureCtx
)
if !featureCtx.CorrectGasRefund && deltaRefundByDynamicGas != 0 {
if deltaRefundByDynamicGas > 0 {
Expand Down

0 comments on commit 0403f9b

Please sign in to comment.