Skip to content

Commit 61fea73

Browse files
committed
refactor(backport): add documentation for ZetaClient logging fields (#4174)
* refactor: use coin.CoinType for compliance logging * refactor: add documentation for zetaclient logging fields
1 parent 2037a57 commit 61fea73

File tree

13 files changed

+83
-54
lines changed

13 files changed

+83
-54
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
* [4144](https://github.com/zeta-chain/node/pull/4144) - standardize structured logging for zetaclient
1414
* [4180](https://github.com/zeta-chain/node/pull/4180) - remove unused loggers and log fields
15+
* [4174](https://github.com/zeta-chain/node/pull/4174) - add documentation for ZetaClient logging fields
1516

1617
### Fixes
1718

zetaclient/chains/base/signer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (s *Signer) PassesCompliance(cctx *types.CrossChainTx) bool {
171171
cctx.Index,
172172
cctx.InboundParams.Sender,
173173
params.Receiver,
174-
params.CoinType.String(),
174+
&params.CoinType,
175175
)
176176

177177
return false

zetaclient/chains/bitcoin/observer/event.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/pkg/errors"
1010

1111
"github.com/zeta-chain/node/pkg/chains"
12+
"github.com/zeta-chain/node/pkg/coin"
1213
"github.com/zeta-chain/node/pkg/constant"
1314
"github.com/zeta-chain/node/pkg/crypto"
1415
"github.com/zeta-chain/node/pkg/memo"
@@ -168,8 +169,9 @@ func (ob *Observer) IsEventProcessable(event BTCInboundEvent) bool {
168169
logger.Info().Msg("thank you rich folk for your donation!")
169170
return false
170171
case clienttypes.InboundCategoryRestricted:
171-
compliance.PrintComplianceLog(ob.logger.Inbound, ob.logger.Compliance,
172-
false, ob.Chain().ChainId, event.TxHash, event.FromAddress, event.ToAddress, "BTC")
172+
coinType := coin.CoinType_Gas
173+
compliance.PrintComplianceLog(ob.logger.Inbound, ob.logger.Compliance, false,
174+
ob.Chain().ChainId, event.TxHash, event.FromAddress, event.ToAddress, &coinType)
173175
return false
174176
default:
175177
logger.Error().Any("category", category).Msg("unreachable code got InboundCategory")

zetaclient/chains/evm/observer/inbound.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ func (ob *Observer) buildInboundVoteMsgForDepositedEvent(
611611
maybeReceiver = parsedAddress.Hex()
612612
}
613613
if config.ContainRestrictedAddress(sender.Hex(), clienttypes.BytesToEthHex(event.Recipient), maybeReceiver) {
614+
coinType := coin.CoinType_ERC20
614615
compliance.PrintComplianceLog(
615616
ob.Logger().Inbound,
616617
ob.Logger().Compliance,
@@ -619,7 +620,7 @@ func (ob *Observer) buildInboundVoteMsgForDepositedEvent(
619620
event.Raw.TxHash.Hex(),
620621
sender.Hex(),
621622
clienttypes.BytesToEthHex(event.Recipient),
622-
"ERC20",
623+
&coinType,
623624
)
624625
return nil
625626
}
@@ -681,8 +682,9 @@ func (ob *Observer) buildInboundVoteMsgForZetaSentEvent(
681682
// https://github.com/zeta-chain/node/issues/4057
682683
sender := event.ZetaTxSenderAddress.Hex()
683684
if config.ContainRestrictedAddress(sender, destAddr, event.SourceTxOriginAddress.Hex()) {
685+
coinType := coin.CoinType_Zeta
684686
compliance.PrintComplianceLog(ob.Logger().Inbound, ob.Logger().Compliance,
685-
false, ob.Chain().ChainId, event.Raw.TxHash.Hex(), sender, destAddr, "Zeta")
687+
false, ob.Chain().ChainId, event.Raw.TxHash.Hex(), sender, destAddr, &coinType)
686688
return nil
687689
}
688690

@@ -737,8 +739,9 @@ func (ob *Observer) buildInboundVoteMsgForTokenSentToTSS(
737739
maybeReceiver = parsedAddress.Hex()
738740
}
739741
if config.ContainRestrictedAddress(sender.Hex(), maybeReceiver) {
742+
coinType := coin.CoinType_Gas
740743
compliance.PrintComplianceLog(ob.Logger().Inbound, ob.Logger().Compliance,
741-
false, ob.Chain().ChainId, tx.Hash, sender.Hex(), sender.Hex(), "Gas")
744+
false, ob.Chain().ChainId, tx.Hash, sender.Hex(), sender.Hex(), &coinType)
742745
return nil
743746
}
744747

zetaclient/chains/evm/observer/v2_inbound.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (ob *Observer) isEventProcessable(
4040
txHash.Hex(),
4141
sender.Hex(),
4242
receiver.Hex(),
43-
"Deposit",
43+
nil,
4444
)
4545
return false
4646
}
@@ -379,22 +379,22 @@ func (ob *Observer) observeGatewayDepositAndCall(
379379

380380
// parseAndValidateDepositAndCallEvents collects and sorts events by block number, tx index, and log index
381381
func (ob *Observer) parseAndValidateDepositAndCallEvents(
382-
rawLogs []ethtypes.Log,
382+
ethlogs []ethtypes.Log,
383383
gatewayAddr ethcommon.Address,
384384
gatewayContract *gatewayevm.GatewayEVM,
385385
) []*gatewayevm.GatewayEVMDepositedAndCalled {
386386
// collect and sort validEvents by block number, then tx index, then log index (ascending)
387387
validEvents := make([]*gatewayevm.GatewayEVMDepositedAndCalled, 0)
388-
for _, log := range rawLogs {
389-
err := common.ValidateEvmTxLog(&log, gatewayAddr, "", common.TopicsGatewayDepositAndCall)
388+
for _, ethlog := range ethlogs {
389+
err := common.ValidateEvmTxLog(&ethlog, gatewayAddr, "", common.TopicsGatewayDepositAndCall)
390390
if err != nil {
391391
continue
392392
}
393-
depositAndCallEvent, err := gatewayContract.ParseDepositedAndCalled(log)
393+
depositAndCallEvent, err := gatewayContract.ParseDepositedAndCalled(ethlog)
394394
if err != nil {
395395
ob.Logger().Inbound.Warn().
396-
Stringer(logs.FieldTx, log.TxHash).
397-
Uint64(logs.FieldBlock, log.BlockNumber).
396+
Stringer(logs.FieldTx, ethlog.TxHash).
397+
Uint64(logs.FieldBlock, ethlog.BlockNumber).
398398
Msg("invalid DepositedAndCall event")
399399
continue
400400
}

zetaclient/chains/solana/observer/inbound.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (ob *Observer) IsEventProcessable(event clienttypes.InboundEvent) bool {
213213
return false
214214
case clienttypes.InboundCategoryRestricted:
215215
compliance.PrintComplianceLog(ob.Logger().Inbound, ob.Logger().Compliance,
216-
false, ob.Chain().ChainId, event.TxHash, event.Sender, event.Receiver, event.CoinType.String())
216+
false, ob.Chain().ChainId, event.TxHash, event.Sender, event.Receiver, &event.CoinType)
217217
return false
218218
default:
219219
ob.Logger().Inbound.Error().Interface("category", category).Msg("unreachable code, got InboundCategory")

zetaclient/chains/solana/signer/increment_nonce.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/near/borsh-go"
99
"github.com/rs/zerolog"
1010

11+
"github.com/zeta-chain/node/pkg/coin"
1112
contracts "github.com/zeta-chain/node/pkg/contracts/solana"
1213
"github.com/zeta-chain/node/x/crosschain/types"
1314
"github.com/zeta-chain/node/zetaclient/compliance"
@@ -24,6 +25,7 @@ func (signer *Signer) prepareIncrementNonceTx(
2425
// compliance check
2526
cancelTx := compliance.IsCCTXRestricted(cctx)
2627
if cancelTx {
28+
coinType := coin.CoinType_Gas
2729
compliance.PrintComplianceLog(
2830
logger,
2931
signer.Logger().Compliance,
@@ -32,7 +34,7 @@ func (signer *Signer) prepareIncrementNonceTx(
3234
cctx.Index,
3335
cctx.InboundParams.Sender,
3436
params.Receiver,
35-
"SOL",
37+
&coinType,
3638
)
3739
}
3840

zetaclient/chains/sui/observer/inbound.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (ob *Observer) constructInboundVote(
194194
event.TxHash,
195195
deposit.Sender,
196196
deposit.Receiver.String(),
197-
asset,
197+
&coinType,
198198
)
199199
return nil, errCompliance
200200
}

zetaclient/chains/ton/observer/inbound.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (ob *Observer) inboundComplianceCheck(inbound inboundData) (restricted bool
333333
txHash,
334334
inbound.sender.ToRaw(),
335335
inbound.receiver.Hex(),
336-
inbound.coinType.String(),
336+
&inbound.coinType,
337337
)
338338

339339
return true

zetaclient/chains/ton/observer/inbound_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func TestInbound(t *testing.T) {
277277

278278
// Check that NO cctx was sent && log contains entry for restricted address
279279
require.Len(t, ts.votesBag, 0)
280-
require.Contains(t, ts.logger.String(), "Restricted address detected in inbound")
280+
require.Contains(t, ts.logger.String(), "restricted address detected in inbound")
281281
})
282282

283283
// Yep, it's possible to have withdrawals here because we scroll through all gateway's txs

0 commit comments

Comments
 (0)