Skip to content

Commit 9506313

Browse files
committed
fix: address PR reviewer comments
- Set MetricCurrentDepositNonce in GetAndStoreBatchFromEthereum for consistency across both bridge directions - Use dynamic chain names for MetricBridgeDirection instead of hardcoded strings
1 parent 26fcc18 commit 9506313

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

bridges/ethKC/bridgeExecutor.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ func (executor *bridgeExecutor) GetAndStoreBatchFromEthereum(ctx context.Context
473473

474474
executor.batch = batch
475475
executor.statusHandler.SetIntMetric(bridgeCore.MetricCurrentBatchID, safeUint64ToInt(batch.ID))
476+
if len(batch.Deposits) > 0 {
477+
lastDeposit := batch.Deposits[len(batch.Deposits)-1]
478+
executor.statusHandler.SetIntMetric(bridgeCore.MetricCurrentDepositNonce, safeUint64ToInt(lastDeposit.Nonce))
479+
}
476480

477481
return nil
478482
}

bridges/ethKC/bridgeExecutor_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ func TestEthToKCBridgeExecutor_GetAndStoreBatchFromEthereum(t *testing.T) {
401401
expectedBatch := &bridgeCore.TransferBatch{
402402
ID: providedNonce,
403403
Deposits: []*bridgeCore.DepositTransfer{
404-
{},
404+
{Nonce: 100},
405+
{Nonce: 101},
405406
},
406407
}
407408
args.EthereumClient = &bridgeTests.EthereumClientStub{
@@ -420,6 +421,7 @@ func TestEthToKCBridgeExecutor_GetAndStoreBatchFromEthereum(t *testing.T) {
420421
assert.True(t, expectedBatch == executor.GetStoredBatch()) // pointer testing
421422
assert.True(t, expectedBatch == executor.batch)
422423
assert.Equal(t, int(providedNonce), statusHandler.GetIntMetric(bridgeCore.MetricCurrentBatchID))
424+
assert.Equal(t, 101, statusHandler.GetIntMetric(bridgeCore.MetricCurrentDepositNonce))
423425
})
424426
t.Run("should add deposits metadata for sc calls", func(t *testing.T) {
425427
t.Parallel()

factory/ethKcBridgeComponents.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ func (components *ethKleverBridgeComponents) createEthereumToKleverBlockchainBri
519519
return err
520520
}
521521

522-
components.ethtoKleverStatusHandler.SetStringMetric(core.MetricBridgeDirection, "ETH->KC")
522+
components.ethtoKleverStatusHandler.SetStringMetric(core.MetricBridgeDirection, ethtokleverName)
523523

524524
timeForTransferExecution := time.Second * time.Duration(args.Configs.GeneralConfig.Eth.IntervalToWaitForTransferInSeconds)
525525

@@ -589,7 +589,7 @@ func (components *ethKleverBridgeComponents) createKCToEthereumBridge(args ArgsE
589589
return err
590590
}
591591

592-
components.kcToEthStatusHandler.SetStringMetric(core.MetricBridgeDirection, "KC->ETH")
592+
components.kcToEthStatusHandler.SetStringMetric(core.MetricBridgeDirection, kcToEthName)
593593

594594
timeForWaitOnEthereum := time.Second * time.Duration(args.Configs.GeneralConfig.Eth.IntervalToWaitForTransferInSeconds)
595595

0 commit comments

Comments
 (0)