Skip to content

Commit 3564331

Browse files
committed
feat: added info, warn, error and debug level logs
1 parent bfed65a commit 3564331

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1014
-22
lines changed

app/ante/account_init_decorator.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func NewAccountInitDecorator(ak AccountKeeper, signModeHandler *txsigning.Handle
3131
func (aid AccountInitDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
3232
if !txpolicy.IsGaslessTx(tx) {
3333
// Skip account initialization for non-gasless transactions
34+
ctx.Logger().Debug("account init decorator: non-gasless tx, skipping account init")
3435
return next(ctx, tx, simulate)
3536
}
3637

@@ -41,23 +42,41 @@ func (aid AccountInitDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
4142

4243
signers, err := sigTx.GetSigners()
4344
if err != nil || len(signers) != 1 {
45+
ctx.Logger().Debug("account init decorator: could not get unique signer, passing to next handler",
46+
"num_signers", len(signers),
47+
"error", err,
48+
)
4449
return next(ctx, tx, simulate)
4550
}
4651

4752
newAccAddr := signers[0]
4853
if !aid.ak.HasAccount(ctx, newAccAddr) {
54+
ctx.Logger().Debug("account init decorator: new account detected on gasless tx, verifying signature",
55+
"address", sdk.AccAddress(newAccAddr).String(),
56+
"simulate", simulate,
57+
)
4958
// if account does not exist on chain, bypass rest of ante chain (especially gas and signature verification) here.
5059
// Perform signature verification on account number e and sequence number e instead.
5160
if err := aid.verifySignatureForNewAccount(ctx, tx, simulate); err != nil {
61+
ctx.Logger().Debug("account init decorator: signature verification failed for new account",
62+
"address", sdk.AccAddress(newAccAddr).String(),
63+
"error", err,
64+
)
5265
return ctx, err
5366
}
5467

5568
acc := aid.ak.NewAccountWithAddress(ctx, newAccAddr)
5669
acc.SetSequence(1)
5770
aid.ak.SetAccount(ctx, acc)
71+
ctx.Logger().Info("account init decorator: new account created via gasless tx",
72+
"address", sdk.AccAddress(newAccAddr).String(),
73+
)
5874
return ctx, nil
5975
}
6076

77+
ctx.Logger().Debug("account init decorator: existing account on gasless tx, passing to next handler",
78+
"address", sdk.AccAddress(newAccAddr).String(),
79+
)
6180
return next(ctx, tx, simulate)
6281
}
6382

@@ -115,6 +134,12 @@ func (aid AccountInitDecorator) verifySignatureForNewAccount(ctx sdk.Context, tx
115134
return fmt.Errorf("expected tx to implement V2AdaptableTx, got %T", tx)
116135
}
117136
txData := adaptableTx.GetSigningTxData()
137+
ctx.Logger().Debug("account init decorator: verifying signature for new account",
138+
"address", newAccAddr.String(),
139+
"chain_id", chainID,
140+
"acc_num", accNum,
141+
"sequence", accSequence,
142+
)
118143
err = authsigning.VerifySignature(ctx, pubKey, signerData, sig.Data, aid.signModeHandler, txData)
119144
if err != nil {
120145
var errMsg string
@@ -125,9 +150,20 @@ func (aid AccountInitDecorator) verifySignatureForNewAccount(ctx sdk.Context, tx
125150
} else {
126151
errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s): (%s)", accNum, chainID, err.Error())
127152
}
153+
ctx.Logger().Debug("account init decorator: signature invalid for new account",
154+
"address", newAccAddr.String(),
155+
"chain_id", chainID,
156+
)
128157
return errorsmod.Wrap(sdkerrors.ErrUnauthorized, errMsg)
129158

130159
}
160+
} else {
161+
ctx.Logger().Debug("account init decorator: skipping signature verification",
162+
"address", newAccAddr.String(),
163+
"simulate", simulate,
164+
"is_recheck_tx", ctx.IsReCheckTx(),
165+
"is_sigverify_tx", ctx.IsSigverifyTx(),
166+
)
131167
}
132168
}
133169
return nil

app/ante/fee.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,35 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
5959
// Check if this is a gasless transaction
6060
if txpolicy.IsGaslessTx(tx) {
6161
// Skip fee deduction for Gasless messages
62+
ctx.Logger().Debug("deduct fee decorator: gasless tx detected, skipping fee deduction")
6263
return next(ctx, tx, simulate)
6364
}
6465

6566
fee := feeTx.GetFee()
6667
if !simulate {
6768
fee, priority, err = dfd.txFeeChecker(ctx, tx)
6869
if err != nil {
70+
ctx.Logger().Debug("deduct fee decorator: tx fee check failed",
71+
"fee", feeTx.GetFee().String(),
72+
"gas", feeTx.GetGas(),
73+
"error", err,
74+
)
6975
return ctx, err
7076
}
7177
}
7278

79+
ctx.Logger().Debug("deduct fee decorator: deducting fees",
80+
"fee", fee.String(),
81+
"gas", feeTx.GetGas(),
82+
"simulate", simulate,
83+
"priority", priority,
84+
)
85+
7386
if err := dfd.checkDeductFee(ctx, tx, fee); err != nil {
87+
ctx.Logger().Debug("deduct fee decorator: fee deduction failed",
88+
"fee", fee.String(),
89+
"error", err,
90+
)
7491
return ctx, err
7592
}
7693

@@ -101,8 +118,18 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
101118
if dfd.feegrantKeeper == nil {
102119
return sdkerrors.ErrInvalidRequest.Wrap("fee grants are not enabled")
103120
} else if !bytes.Equal(feeGranterAddr, feePayer) {
121+
ctx.Logger().Debug("deduct fee decorator: using fee grant",
122+
"fee_granter", feeGranterAddr.String(),
123+
"fee_payer", sdk.AccAddress(feePayer).String(),
124+
"fee", fee.String(),
125+
)
104126
err := dfd.feegrantKeeper.UseGrantedFees(ctx, feeGranterAddr, feePayer, fee, sdkTx.GetMsgs())
105127
if err != nil {
128+
ctx.Logger().Debug("deduct fee decorator: fee grant use failed",
129+
"fee_granter", feeGranterAddr.String(),
130+
"fee_payer", sdk.AccAddress(feePayer).String(),
131+
"error", err,
132+
)
106133
return errorsmod.Wrapf(err, "%s does not allow to pay fees for %s", feeGranter, feePayer)
107134
}
108135
}
@@ -117,10 +144,23 @@ func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee
117144

118145
// deduct the fees
119146
if !fee.IsZero() {
147+
ctx.Logger().Debug("deduct fee decorator: sending fees to fee collector",
148+
"from", sdk.AccAddress(deductFeesFrom).String(),
149+
"fee", fee.String(),
150+
)
120151
err := DeductFees(dfd.bankKeeper, ctx, deductFeesFromAcc, fee)
121152
if err != nil {
153+
ctx.Logger().Debug("deduct fee decorator: failed to send fees to fee collector",
154+
"from", sdk.AccAddress(deductFeesFrom).String(),
155+
"fee", fee.String(),
156+
"error", err,
157+
)
122158
return err
123159
}
160+
} else {
161+
ctx.Logger().Debug("deduct fee decorator: zero fee, skipping bank transfer",
162+
"from", sdk.AccAddress(deductFeesFrom).String(),
163+
)
124164
}
125165

126166
events := sdk.Events{

app/ante/validator_tx_fee.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins,
2121
feeCoins := feeTx.GetFee()
2222
gas := feeTx.GetGas()
2323

24+
ctx.Logger().Debug("validator min gas price check",
25+
"fee", feeCoins.String(),
26+
"gas", gas,
27+
"is_check_tx", ctx.IsCheckTx(),
28+
)
29+
2430
// Ensure that the provided fees meet a minimum threshold for the validator,
2531
// if this is a CheckTx. This is only for local mempool purposes, and thus
2632
// is only ran on check tx.
@@ -38,12 +44,30 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins,
3844
}
3945

4046
if !feeCoins.IsAnyGTE(requiredFees) {
47+
ctx.Logger().Debug("validator min gas price check: insufficient fee rejected",
48+
"fee_provided", feeCoins.String(),
49+
"fee_required", requiredFees.String(),
50+
"gas", gas,
51+
)
4152
return nil, 0, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees)
4253
}
54+
55+
ctx.Logger().Debug("validator min gas price check: fee meets minimum",
56+
"fee_provided", feeCoins.String(),
57+
"fee_required", requiredFees.String(),
58+
"gas", gas,
59+
)
60+
} else {
61+
ctx.Logger().Debug("validator min gas price check: no min gas price set, bypassing check")
4362
}
4463
}
4564

4665
priority := getTxPriority(feeCoins, int64(gas))
66+
ctx.Logger().Debug("validator min gas price check: computed tx priority",
67+
"fee", feeCoins.String(),
68+
"gas", gas,
69+
"priority", priority,
70+
)
4771
return feeCoins, priority, nil
4872
}
4973

x/uexecutor/keeper/chain_meta.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ func (k Keeper) VoteChainMeta(ctx context.Context, universalValidator sdk.ValAdd
5353

5454
if !found {
5555
// First vote for this chain — no height check needed yet.
56+
k.Logger().Info("chain meta first vote, initializing entry",
57+
"chain_id", observedChainId,
58+
"validator", universalValidator.String(),
59+
"price", price,
60+
"block_number", blockNumber,
61+
)
5662
priceBig := math.NewUint(price).BigInt()
5763
chainHeightBig := math.NewUint(blockNumber).BigInt()
5864
if _, evmErr := k.CallUniversalCoreSetChainMeta(sdkCtx, observedChainId, priceBig, chainHeightBig); evmErr != nil {
@@ -77,6 +83,12 @@ func (k Keeper) VoteChainMeta(ctx context.Context, universalValidator sdk.ValAdd
7783

7884
// Reject votes whose chain height has already been committed to the contract.
7985
if blockNumber <= entry.LastAppliedChainHeight {
86+
k.Logger().Warn("chain meta vote rejected: stale block height",
87+
"chain_id", observedChainId,
88+
"validator", universalValidator.String(),
89+
"vote_height", blockNumber,
90+
"last_applied_height", entry.LastAppliedChainHeight,
91+
)
8092
return fmt.Errorf(
8193
"vote chain height %d is not greater than last applied chain height %d; re-vote with a newer block",
8294
blockNumber, entry.LastAppliedChainHeight,
@@ -122,6 +134,10 @@ func (k Keeper) VoteChainMeta(ctx context.Context, universalValidator sdk.ValAdd
122134
}
123135

124136
if len(fresh) == 0 {
137+
k.Logger().Debug("chain meta vote recorded, no fresh votes for EVM update",
138+
"chain_id", observedChainId,
139+
"validator", universalValidator.String(),
140+
)
125141
// No fresh votes — persist the updated entry but skip EVM call.
126142
if err := k.SetChainMeta(ctx, observedChainId, entry); err != nil {
127143
return sdkerrors.Wrap(err, "failed to set updated chain meta entry")
@@ -133,6 +149,13 @@ func (k Keeper) VoteChainMeta(ctx context.Context, universalValidator sdk.ValAdd
133149
medianPrice := upperMedianUint64(fresh, func(v voteSnapshot) uint64 { return v.price })
134150
medianChainHeight := upperMedianUint64(fresh, func(v voteSnapshot) uint64 { return v.chainHeight })
135151

152+
k.Logger().Debug("chain meta medians computed",
153+
"chain_id", observedChainId,
154+
"fresh_votes", len(fresh),
155+
"median_price", medianPrice,
156+
"median_chain_height", medianChainHeight,
157+
)
158+
136159
// Update MedianIndex to reflect the price median position in the full slice
137160
// (best-effort; used for storage/querying only).
138161
entry.MedianIndex = uint64(computeMedianIndex(entry.Prices))
@@ -148,6 +171,12 @@ func (k Keeper) VoteChainMeta(ctx context.Context, universalValidator sdk.ValAdd
148171
return sdkerrors.Wrap(err, "failed to set updated chain meta entry")
149172
}
150173

174+
k.Logger().Info("chain meta updated",
175+
"chain_id", observedChainId,
176+
"median_price", medianPrice,
177+
"median_chain_height", medianChainHeight,
178+
)
179+
151180
return nil
152181
}
153182

@@ -167,10 +196,12 @@ func upperMedianUint64[T any](items []T, key func(T) uint64) uint64 {
167196
// Called once during the chain-meta upgrade. Existing gas price data (prices, block_nums, median_index)
168197
// is carried over; StoredAts defaults to zero (treated as stale until validators re-vote).
169198
func (k Keeper) MigrateGasPricesToChainMeta(ctx context.Context) error {
199+
k.Logger().Info("migrating gas prices to chain metas")
170200
return k.GasPrices.Walk(ctx, nil, func(chainID string, gp types.GasPrice) (bool, error) {
171201
// Skip if already migrated
172202
existing, err := k.ChainMetas.Get(ctx, chainID)
173203
if err == nil && existing.ObservedChainId != "" {
204+
k.Logger().Debug("chain meta migration skipped: already exists", "chain_id", chainID)
174205
return false, nil // already exists, skip
175206
}
176207

@@ -190,6 +221,7 @@ func (k Keeper) MigrateGasPricesToChainMeta(ctx context.Context) error {
190221
return true, err
191222
}
192223

224+
k.Logger().Info("chain meta migrated from gas price", "chain_id", chainID, "signer_count", len(gp.Signers))
193225
return false, nil
194226
})
195227
}

x/uexecutor/keeper/create_outbound.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func (k Keeper) BuildOutboundsFromReceipt(
2222
outbounds := []*types.OutboundTx{}
2323
universalGatewayPC := strings.ToLower(uregistrytypes.SYSTEM_CONTRACTS["UNIVERSAL_GATEWAY_PC"].Address)
2424

25+
k.Logger().Debug("building outbounds from receipt", "utx_id", utxId, "tx_hash", receipt.Hash, "log_count", len(receipt.Logs))
26+
2527
for _, lg := range receipt.Logs {
2628
if lg.Removed {
2729
continue
@@ -50,6 +52,7 @@ func (k Keeper) BuildOutboundsFromReceipt(
5052
return nil, fmt.Errorf("failed to check outbound enabled for chain %s: %w", event.ChainId, err)
5153
}
5254
if !outboundEnabled {
55+
k.Logger().Warn("outbound disabled for chain", "chain_id", event.ChainId, "utx_id", utxId)
5356
return nil, fmt.Errorf("outbound is disabled for chain %s", event.ChainId)
5457
}
5558

@@ -87,9 +90,17 @@ func (k Keeper) BuildOutboundsFromReceipt(
8790
Id: strings.TrimPrefix(event.TxID, "0x"),
8891
}
8992

93+
k.Logger().Debug("outbound built from receipt",
94+
"utx_id", utxId,
95+
"outbound_id", outbound.Id,
96+
"dest_chain", outbound.DestinationChain,
97+
"amount", outbound.Amount,
98+
"tx_type", outbound.TxType.String(),
99+
)
90100
outbounds = append(outbounds, outbound)
91101
}
92102

103+
k.Logger().Debug("outbounds built from receipt", "utx_id", utxId, "count", len(outbounds))
93104
return outbounds, nil
94105
}
95106

@@ -112,16 +123,18 @@ func (k Keeper) CreateUniversalTxFromPCTx(
112123
}
113124

114125
utx := types.UniversalTx{
115-
Id: universalTxKey,
116-
InboundTx: nil, // no inbound
117-
PcTx: []*types.PCTx{&pcTx}, // origin is PC
118-
OutboundTx: nil,
126+
Id: universalTxKey,
127+
InboundTx: nil, // no inbound
128+
PcTx: []*types.PCTx{&pcTx}, // origin is PC
129+
OutboundTx: nil,
119130
}
120131

121132
if err := k.CreateUniversalTx(ctx, universalTxKey, utx); err != nil {
122133
return nil, err
123134
}
124135

136+
k.Logger().Info("utx created from pc tx", "utx_key", universalTxKey, "pc_tx_hash", pcTx.TxHash)
137+
125138
return &utx, nil
126139
}
127140

@@ -248,13 +261,22 @@ func (k Keeper) AttachRescueOutboundFromReceipt(
248261
}
249262
}
250263

264+
k.Logger().Info("rescue outbound detected",
265+
"original_utx_id", originalUtxId,
266+
"pc_tx_hash", receipt.Hash,
267+
)
268+
251269
// Guard against duplicate rescue outbounds: reject if an active rescue
252270
// (PENDING or OBSERVED) already exists. A REVERTED rescue may be retried.
253271
for _, ob := range originalUtx.OutboundTx {
254272
if ob == nil || ob.TxType != types.TxType_RESCUE_FUNDS {
255273
continue
256274
}
257275
if ob.OutboundStatus == types.Status_PENDING || ob.OutboundStatus == types.Status_OBSERVED {
276+
k.Logger().Warn("rescue outbound rejected: active rescue already exists",
277+
"original_utx_id", originalUtxId,
278+
"existing_outbound_id", ob.Id,
279+
)
258280
return fmt.Errorf("rescue: UTX %s already has an active rescue outbound (%s)", originalUtxId, ob.Id)
259281
}
260282
}

0 commit comments

Comments
 (0)