Skip to content

Commit

Permalink
fix ps.helperCtx.DepositGasFunc == nil
Browse files Browse the repository at this point in the history
  • Loading branch information
millken committed Nov 21, 2023
1 parent 4c3aa58 commit 87d436b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion action/protocol/execution/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ func ExecuteContract(
receiver address.Address
sharedGas uint64
sharedGasFee, totalGasFee *big.Int
depositGasFunc DepositGasWithSGD
)
if ps.featureCtx.SharedGasWithDapp && sgd != nil {

Check warning on line 283 in action/protocol/execution/evm/evm.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/execution/evm/evm.go#L276-L283

Added lines #L276 - L283 were not covered by tests
// TODO: sgd is whether nil should be checked in processSGD
Expand All @@ -291,7 +292,14 @@ func ExecuteContract(
sharedGasFee.Mul(sharedGasFee, ps.txCtx.GasPrice)

Check warning on line 292 in action/protocol/execution/evm/evm.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/execution/evm/evm.go#L290-L292

Added lines #L290 - L292 were not covered by tests
}
totalGasFee = new(big.Int).Mul(new(big.Int).SetUint64(consumedGas), ps.txCtx.GasPrice)
depositLog, err = ps.helperCtx.DepositGasFunc(ctx, sm, receiver, totalGasFee, sharedGasFee)
if ps.helperCtx.DepositGasFunc == nil {
depositGasFunc = func(ctx context.Context, sm protocol.StateManager, a address.Address, i1, i2 *big.Int) (*action.TransactionLog, error) {
return nil, nil

Check warning on line 297 in action/protocol/execution/evm/evm.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/execution/evm/evm.go#L294-L297

Added lines #L294 - L297 were not covered by tests
}
} else {
depositGasFunc = ps.helperCtx.DepositGasFunc

Check warning on line 300 in action/protocol/execution/evm/evm.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/execution/evm/evm.go#L299-L300

Added lines #L299 - L300 were not covered by tests
}
depositLog, err = depositGasFunc(ctx, sm, receiver, totalGasFee, sharedGasFee)

Check warning on line 302 in action/protocol/execution/evm/evm.go

View check run for this annotation

Codecov / codecov/patch

action/protocol/execution/evm/evm.go#L302

Added line #L302 was not covered by tests
if err != nil {
return nil, nil, err
}
Expand Down

0 comments on commit 87d436b

Please sign in to comment.