From 562d3325cf65319f7f08c89a8113f403b4603473 Mon Sep 17 00:00:00 2001 From: Nate Beauregard Date: Fri, 1 Nov 2024 14:10:30 -0400 Subject: [PATCH] Remove duplicate error logs in x/rollup --- x/rollup/keeper/deposits.go | 12 ------------ x/rollup/keeper/msg_server.go | 11 +---------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/x/rollup/keeper/deposits.go b/x/rollup/keeper/deposits.go index 553def92..42a0b086 100644 --- a/x/rollup/keeper/deposits.go +++ b/x/rollup/keeper/deposits.go @@ -41,17 +41,14 @@ func (k *Keeper) setL1BlockInfo(ctx sdk.Context, info types.L1BlockInfo) error { func (k *Keeper) processL1AttributesTx(ctx sdk.Context, txBytes []byte) (*types.L1BlockInfo, error) { //nolint:gocritic // hugeParam var tx ethtypes.Transaction if err := tx.UnmarshalBinary(txBytes); err != nil { - ctx.Logger().Error("Failed to unmarshal L1 attributes transaction", "index", 0, "err", err, "txBytes", txBytes) return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal L1 attributes transaction: %v", err) } if !tx.IsDepositTx() { - ctx.Logger().Error("First L1 tx must be a L1 attributes tx", "type", tx.Type()) return nil, types.WrapError(types.ErrInvalidL1Txs, "first L1 tx must be a L1 attributes tx, but got type %d", tx.Type()) } l1blockInfo, err := derive.L1BlockInfoFromBytes(k.rollupCfg, uint64(ctx.BlockTime().Unix()), tx.Data()) if err != nil { - ctx.Logger().Error("Failed to derive L1 block info from L1 Info Deposit tx", "err", err, "txBytes", txBytes) return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to derive L1 block info from L1 Info Deposit tx: %v", err) } @@ -91,22 +88,18 @@ func (k *Keeper) processL1UserDepositTxs( txBytes := txs[i] var tx ethtypes.Transaction if err := tx.UnmarshalBinary(txBytes); err != nil { - ctx.Logger().Error("Failed to unmarshal user deposit transaction", "index", i, "err", err, "txBytes", txBytes) return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal user deposit transaction", "index", i, "err", err) } if !tx.IsDepositTx() { - ctx.Logger().Error("L1 tx must be a user deposit tx", "index", i, "type", tx.Type()) return nil, types.WrapError(types.ErrInvalidL1Txs, "L1 tx must be a user deposit tx, index:%d, type:%d", i, tx.Type()) } if tx.IsSystemTx() { - ctx.Logger().Error("L1 tx must be a user deposit tx", "type", tx.Type()) return nil, types.WrapError(types.ErrInvalidL1Txs, "L1 tx must be a user deposit tx, type %d", tx.Type()) } ctx.Logger().Debug("User deposit tx", "index", i, "tx", string(lo.Must(tx.MarshalJSON()))) // if the receipient is nil, it means the tx is creating a contract which we don't support, so return an error. // see https://github.com/ethereum-optimism/op-geth/blob/v1.101301.0-rc.2/core/state_processor.go#L154 if tx.To() == nil { - ctx.Logger().Error("Contract creation txs are not supported", "index", i) return nil, types.WrapError(types.ErrInvalidL1Txs, "Contract creation txs are not supported, index:%d", i) } @@ -117,26 +110,22 @@ func (k *Keeper) processL1UserDepositTxs( l1blockInfo.Time, ).Sender(&tx) if err != nil { - ctx.Logger().Error("Failed to get sender address", "evmAddress", from, "err", err) return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to get sender address: %v", err) } addrPrefix := sdk.GetConfig().GetBech32AccountAddrPrefix() mintAddr, err := monomer.CosmosETHAddress(from).Encode(addrPrefix) if err != nil { - ctx.Logger().Error("Failed to convert EVM to Cosmos address", "err", err) return nil, fmt.Errorf("evm to cosmos address: %v", err) } mintAmount := sdkmath.NewIntFromBigInt(tx.Mint()) recipientAddr, err := monomer.CosmosETHAddress(*tx.To()).Encode(addrPrefix) if err != nil { - ctx.Logger().Error("Failed to convert EVM to Cosmos address", "err", err) return nil, fmt.Errorf("evm to cosmos address: %v", err) } transferAmount := sdkmath.NewIntFromBigInt(tx.Value()) mintEvent, err := k.mintETH(ctx, mintAddr, recipientAddr, mintAmount, transferAmount) if err != nil { - ctx.Logger().Error("Failed to mint ETH", "evmAddress", from, "cosmosAddress", mintAddr, "err", err) return nil, types.WrapError(types.ErrMintETH, "failed to mint ETH for cosmosAddress: %v; err: %v", mintAddr, err) } mintEvents = append(mintEvents, *mintEvent) @@ -150,7 +139,6 @@ func (k *Keeper) processL1UserDepositTxs( erc20mintEvent, err := k.parseAndExecuteCrossDomainMessage(ctx, tx.Data()) // TODO: Investigate when to return an error if a cross domain message can't be parsed or executed - look at OP Spec if err != nil { - ctx.Logger().Error("Failed to parse or execute cross domain message", "err", err) return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to parse or execute cross domain message: %v", err) } else { mintEvents = append(mintEvents, *erc20mintEvent) diff --git a/x/rollup/keeper/msg_server.go b/x/rollup/keeper/msg_server.go index e60520cf..cbb8df3d 100644 --- a/x/rollup/keeper/msg_server.go +++ b/x/rollup/keeper/msg_server.go @@ -23,22 +23,19 @@ func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *types.MsgApplyL1Txs) (*t // process L1 attributes tx and get L1 block info l1blockInfo, err := k.processL1AttributesTx(ctx, msg.TxBytes[0]) if err != nil { - ctx.Logger().Error("Failed to process L1 system deposit tx", "err", err) return nil, types.WrapError(types.ErrProcessL1SystemDepositTx, "err: %v", err) } // save L1 block info to AppState if err = k.setL1BlockInfo(ctx, *l1blockInfo); err != nil { - ctx.Logger().Error("Failed to save L1 block info to AppState", "err", err) return nil, types.WrapError(types.ErrL1BlockInfo, "save error: %v", err) } - ctx.Logger().Info("Save L1 block info", "l1blockInfo", string(lo.Must(l1blockInfo.Marshal()))) + ctx.Logger().Debug("Save L1 block info", "l1blockInfo", string(lo.Must(l1blockInfo.Marshal()))) // process L1 user deposit txs mintEvents, err := k.processL1UserDepositTxs(ctx, msg.TxBytes, l1blockInfo) if err != nil { - ctx.Logger().Error("Failed to process L1 user deposit txs", "err", err) return nil, types.WrapError(types.ErrProcessL1UserDepositTxs, "err: %v", err) } @@ -56,12 +53,10 @@ func (k *Keeper) InitiateWithdrawal( cosmAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { - ctx.Logger().Error("Invalid sender address", "sender", msg.Sender, "err", err) return nil, types.WrapError(types.ErrInvalidSender, "failed to create cosmos address for sender: %v; error: %v", msg.Sender, err) } if err = k.burnETH(ctx, cosmAddr, msg.Value); err != nil { - ctx.Logger().Error("Failed to burn ETH", "cosmosAddress", cosmAddr, "evmAddress", msg.Target, "err", err) return nil, types.WrapError(types.ErrBurnETH, "failed to burn ETH for cosmosAddress: %v; err: %v", cosmAddr, err) } @@ -102,13 +97,11 @@ func (k *Keeper) InitiateFeeWithdrawal( feeCollectorAddr := k.accountkeeper.GetModuleAddress(authtypes.FeeCollectorName) if feeCollectorAddr == nil { - ctx.Logger().Error("Failed to get fee collector address") return nil, types.WrapError(types.ErrInitiateFeeWithdrawal, "failed to get fee collector address") } feeCollectorBalance := k.bankkeeper.GetBalance(ctx, feeCollectorAddr, types.WEI) if feeCollectorBalance.Amount.LT(math.NewInt(minWithdrawalAmount)) { - ctx.Logger().Error("Fee collector balance is below the minimum withdrawal amount", "balance", feeCollectorBalance.String()) return nil, types.WrapError( types.ErrInitiateFeeWithdrawal, "fee collector balance is below the minimum withdrawal amount: %v", feeCollectorBalance.String(), @@ -121,14 +114,12 @@ func (k *Keeper) InitiateFeeWithdrawal( // FeeCollector module account, they will first be sent to the rollup module account before being burned. fees := sdk.NewCoins(feeCollectorBalance) if err := k.bankkeeper.SendCoinsFromModuleToModule(ctx, authtypes.FeeCollectorName, types.ModuleName, fees); err != nil { - ctx.Logger().Error("Failed to send withdrawn fees from fee collector account to rollup module", "err", err) return nil, types.WrapError( types.ErrInitiateFeeWithdrawal, "failed to send withdrawn fees from fee collector account to rollup module: %v", err, ) } if err := k.bankkeeper.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(feeCollectorBalance)); err != nil { - ctx.Logger().Error("Failed to burn withdrawn fees from rollup module", "err", err) return nil, types.WrapError(types.ErrInitiateFeeWithdrawal, "failed to burn withdrawn fees from rollup module: %v", err) }