Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions evmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"github.com/cosmos/evm/x/feemarket"
feemarketkeeper "github.com/cosmos/evm/x/feemarket/keeper"
feemarkettypes "github.com/cosmos/evm/x/feemarket/types"

Check failure on line 35 in evmd/app.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gci)
// NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens
"github.com/cosmos/evm/x/ibc/transfer"
transferkeeper "github.com/cosmos/evm/x/ibc/transfer/keeper"
Expand Down
31 changes: 31 additions & 0 deletions rpc/backend/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,38 @@
ethMsg.Hash = additional.Hash.Hex()
ethMsg.From = additional.Sender.Hex()
return ethMsg
}

Check failure on line 341 in rpc/backend/blocks.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

File is not properly formatted (gofumpt)
func (b *Backend) parseDerivedTxFromAdditionalFieldsForTrace(

Check failure on line 342 in rpc/backend/blocks.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

func `(*Backend).parseDerivedTxFromAdditionalFieldsForTrace` is unused (unused)
additional *rpctypes.TxResultAdditionalFields,
) *evmtypes.MsgEthereumTx {
recipient := additional.Recipient

// for transactions before v31 this value was mistakenly used for Gas field
gas := additional.GasUsed
if additional.GasLimit != nil {
gas = *additional.GasLimit
}
t := ethtypes.NewTx(&ethtypes.LegacyTx{
Nonce: additional.Nonce,
Data: additional.Data,
Gas: gas,
To: &recipient,
GasPrice: nil,
Value: additional.Value,
V: big.NewInt(0),
R: big.NewInt(0),
S: big.NewInt(0),
})
ethMsg := &evmtypes.MsgEthereumTx{}
err := ethMsg.FromEthereumTx(t)
if err != nil {
b.logger.Error("can not create eth msg", err.Error())
return nil
}
ethMsg.Hash = additional.Hash.Hex()
ethMsg.From = additional.Sender.Hex()
return ethMsg
}

// gasForDerivedEthTx returns the gas value to use for a derived Ethereum transaction.
//
Expand Down
1 change: 1 addition & 0 deletions rpc/backend/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

var predecessors []*evmtypes.MsgEthereumTx
for i := 0; i < int(transaction.TxIndex); i++ {
predecessorTx, txAdditional, err := b.GetTxByTxIndex(blk.Block.Height, uint(i))

Check failure on line 53 in rpc/backend/tracing.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

G115: integer overflow conversion int -> uint (gosec)
if err != nil {
b.logger.Debug("failed to get tx by index",
"height", blk.Block.Height,
Expand Down Expand Up @@ -127,6 +127,7 @@

// add predecessor messages in current cosmos tx
index := int(transaction.MsgIndex) // #nosec G115

for i := 0; i < index; i++ {
msg := tx.GetMsgs()[i]
// Check if it's a normal Ethereum tx
Expand Down
26 changes: 26 additions & 0 deletions x/vm/keeper/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
"github.com/cosmos/evm/x/vm/types"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

Check failure on line 20 in x/vm/keeper/state_transition.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

ST1019: package "cosmossdk.io/math" is being imported more than once (stylecheck)
sdkmath "cosmossdk.io/math"

Check failure on line 21 in x/vm/keeper/state_transition.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

ST1019(related information): other import of "cosmossdk.io/math" (stylecheck)

sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// NewEVM generates a go-ethereum VM from the provided Message fields and the chain parameters
Expand Down Expand Up @@ -243,6 +245,30 @@
if err = k.RefundGas(ctx, msg, msg.Gas()-res.GasUsed, evmDenom); err != nil {
return nil, errorsmod.Wrapf(err, "failed to refund gas leftover gas to sender %s", msg.From())
}
// burn base fee (EIP-1559): baseFee * gasUsed
if cfg.BaseFee != nil && cfg.BaseFee.Sign() > 0 && res.GasUsed > 0 {
// compute amount = baseFee * gasUsed
burnAmt := new(big.Int).Mul(cfg.BaseFee, new(big.Int).SetUint64(res.GasUsed))

// create coin in EVM denom
burnCoin := sdk.Coin{Denom: types.GetEVMCoinDenom(), Amount: sdkmath.NewIntFromBigInt(burnAmt)}

// convert to extended denom (chain denom) and burn from fee collector
converted, err := types.ConvertEvmCoinDenomToExtendedDenom(burnCoin)
if err != nil {
// handle error (log and/or return). If you return, it may fail the tx; choose behavior.
k.Logger(ctx).Error("failed to convert evm denom for base fee burn", "err", err)
} else {
burnCoins := sdk.Coins{converted}
evmmodAddr := authtypes.NewModuleAddress(types.ModuleName)
if err := k.bankWrapper.SendCoinsFromModuleToAccount(ctx, authtypes.FeeCollectorName, evmmodAddr, burnCoins); err != nil {
k.Logger(ctx).Error("failed to move base fee to evm module account", "err", err)
} else if err := k.bankWrapper.BurnCoins(ctx, types.ModuleName, burnCoins); err != nil {
// handle error - either log or return error. Logging avoids failing block.
k.Logger(ctx).Error("failed to burn base fee from evm module account", "err", err)
}
}
}

if len(logs) > 0 {
// Update transient block bloom filter
Expand Down
Loading