Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinxie authored Dec 24, 2024
2 parents f69980e + e53ef04 commit 6939b92
Show file tree
Hide file tree
Showing 83 changed files with 1,878 additions and 1,340 deletions.
2 changes: 1 addition & 1 deletion action/envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ type (
Nonce() uint64
Gas() uint64
GasPrice() *big.Int
EffectiveGasPrice(*big.Int) *big.Int
TxDynamicGas
AccessList() types.AccessList
TxBlob
Expand All @@ -71,6 +70,7 @@ type (
TxDynamicGas interface {
GasTipCap() *big.Int
GasFeeCap() *big.Int
EffectiveGasPrice(*big.Int) *big.Int
}

TxBlob interface {
Expand Down
15 changes: 8 additions & 7 deletions action/protocol/execution/evm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func ExecuteContract(
if err != nil {
return nil, nil, err
}
retval, depositGas, remainingGas, contractAddress, statusCode, err := executeInEVM(ps, stateDB)
retval, depositGas, remainingGas, contractAddress, statusCode, err := executeInEVM(ctx, ps, stateDB)
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -380,6 +380,7 @@ func prepareStateDB(ctx context.Context, sm protocol.StateManager) (*StateDBAdap
}
if featureCtx.FixRevertSnapshot || actionCtx.ReadOnly {
opts = append(opts, FixRevertSnapshotOption())
opts = append(opts, WithContext(ctx))
}
return NewStateDBAdapter(
sm,
Expand Down Expand Up @@ -427,7 +428,7 @@ func getChainConfig(g genesis.Blockchain, height uint64, id uint32, getBlockTime
}

// Error in executeInEVM is a consensus issue
func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, uint64, string, iotextypes.ReceiptStatus, error) {
func executeInEVM(ctx context.Context, evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, uint64, string, iotextypes.ReceiptStatus, error) {
var (
gasLimit = evmParams.blkCtx.GasLimit
blockHeight = evmParams.blkCtx.BlockHeight
Expand All @@ -436,7 +437,7 @@ func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, u
chainConfig = evmParams.chainConfig
)
if err := securityDeposit(evmParams, stateDB, gasLimit); err != nil {
log.L().Warn("unexpected error: not enough security deposit", zap.Error(err))
log.T(ctx).Warn("unexpected error: not enough security deposit", zap.Error(err))
return nil, 0, 0, action.EmptyAddress, iotextypes.ReceiptStatus_Failure, err
}
var (
Expand Down Expand Up @@ -472,7 +473,7 @@ func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, u
// create contract
var evmContractAddress common.Address
_, evmContractAddress, remainingGas, evmErr = evm.Create(executor, evmParams.data, remainingGas, amount)
log.L().Debug("evm Create.", log.Hex("addrHash", evmContractAddress[:]))
log.T(ctx).Debug("evm Create.", log.Hex("addrHash", evmContractAddress[:]))
if evmErr == nil {
if contractAddress, err := address.FromBytes(evmContractAddress.Bytes()); err == nil {
contractRawAddress = contractAddress.String()
Expand All @@ -484,7 +485,7 @@ func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, u
ret, remainingGas, evmErr = evm.Call(executor, *evmParams.contract, evmParams.data, remainingGas, amount)
}
if evmErr != nil {
log.L().Debug("evm error", zap.Error(evmErr))
log.T(ctx).Debug("evm error", zap.Error(evmErr))
// The only possible consensus-error would be if there wasn't
// sufficient balance to make the transfer happen.
// Should be a hard fork (Bering)
Expand All @@ -493,7 +494,7 @@ func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, u
}
}
if stateDB.Error() != nil {
log.L().Debug("statedb error", zap.Error(stateDB.Error()))
log.T(ctx).Debug("statedb error", zap.Error(stateDB.Error()))
}
if !rules.IsLondon {
// Before EIP-3529: refunds were capped to gasUsed / 2
Expand Down Expand Up @@ -532,7 +533,7 @@ func executeInEVM(evmParams *Params, stateDB *StateDBAdapter) ([]byte, uint64, u
} else {
addr = "contract creation"
}
log.L().Warn("evm internal error", zap.Error(evmErr),
log.T(ctx).Warn("evm internal error", zap.Error(evmErr),
zap.String("address", addr),
log.Hex("calldata", evmParams.data))
}
Expand Down
4 changes: 2 additions & 2 deletions action/protocol/execution/evm/evm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ func TestConstantinople(t *testing.T) {
},
{
"io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y",
41174200,
33730920,
},
// after Vanuatu
{
action.EmptyAddress,
41174201,
33730921,
},
{
"io1pcg2ja9krrhujpazswgz77ss46xgt88afqlk6y",
Expand Down
Loading

0 comments on commit 6939b92

Please sign in to comment.