Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 14 additions & 14 deletions internal/relayertest/mocks/chain_evm_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion relayer/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
GetTunnelPacketErrorMsg = "Failed to get tunnel packet from BandChain"
GetContractTunnelInfoErrorMsg = "Failed to get tunnel info from contract"
PacketSigningStatusErrorMsg = "Failed tunnel packet signing status"
GetBlockErrorMsg = "Failed to get block from chain"
GetHeaderBlockErrorMsg = "Failed to get header block from chain"
GetBalanceErrorMsg = "Failed to get balance from chain"
SaveDatabaseErrorMsg = "Failed to save to database"
)
Expand Down
14 changes: 7 additions & 7 deletions relayer/chains/evm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type Client interface {
StartLivelinessCheck(ctx context.Context, interval time.Duration)
NonceAt(ctx context.Context, address gethcommon.Address) (uint64, error)
GetBlockHeight(ctx context.Context) (uint64, error)
GetBlock(ctx context.Context, height *big.Int) (*gethtypes.Block, error)
GetHeaderBlock(ctx context.Context, height *big.Int) (*gethtypes.Header, error)
GetTxReceipt(ctx context.Context, txHash string) (*TxReceipt, error)
Query(ctx context.Context, gethAddr gethcommon.Address, data []byte) ([]byte, error)
EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
Expand Down Expand Up @@ -247,8 +247,8 @@ func (c *client) GetBlockHeight(ctx context.Context) (uint64, error) {
return blockHeight, nil
}

// GetBlock returns the blocks of the given block height
func (c *client) GetBlock(ctx context.Context, height *big.Int) (*gethtypes.Block, error) {
// GetHeaderBlock returns the block header at the given height.
func (c *client) GetHeaderBlock(ctx context.Context, height *big.Int) (*gethtypes.Header, error) {
newCtx, cancel := context.WithTimeout(ctx, c.QueryTimeout)
defer cancel()

Expand All @@ -258,18 +258,18 @@ func (c *client) GetBlock(ctx context.Context, height *big.Int) (*gethtypes.Bloc
return nil, fmt.Errorf("[EVMClient] failed to get client: %w", err)
}

block, err := client.BlockByNumber(newCtx, height)
header, err := client.HeaderByNumber(newCtx, height)
if err != nil {
c.Log.Error(
"Failed to get block by height",
"Failed to get headerblock by height",
"endpoint", c.clients.GetSelectedEndpoint(),
"height", height.String(),
err,
)
return nil, fmt.Errorf("[EVMClient] failed to get block by height: %w", err)
return nil, fmt.Errorf("[EVMClient] failed to get header block by height: %w", err)
}

return block, nil
return header, nil
}

// GetTxReceipt returns the transaction receipt of the given transaction hash.
Expand Down
10 changes: 5 additions & 5 deletions relayer/chains/evm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,16 @@ func (cp *EVMChainProvider) prepareTransaction(
effectiveGasPrice = txResult.EffectiveGasPrice

if txResult.Status == types.TX_STATUS_SUCCESS || txResult.Status == types.TX_STATUS_FAILED {
block, err := cp.Client.GetBlock(context.Background(), txResult.BlockNumber)
header, err := cp.Client.GetHeaderBlock(context.Background(), txResult.BlockNumber)
if err != nil {
log.Error("Failed to get block", "retry_count", retryCount, err)
alert.HandleAlert(cp.Alert, alert.NewTopic(alert.GetBlockErrorMsg).
log.Error("Failed to get header block", "retry_count", retryCount, err)
alert.HandleAlert(cp.Alert, alert.NewTopic(alert.GetHeaderBlockErrorMsg).
WithTunnelID(packet.TunnelID).
WithChainName(cp.ChainName), err.Error())
} else {
timestamp := time.Unix(int64(block.Time()), 0).UTC()
timestamp := time.Unix(int64(header.Time), 0).UTC()
blockTimestamp = &timestamp
alert.HandleReset(cp.Alert, alert.NewTopic(alert.GetBlockErrorMsg).
alert.HandleReset(cp.Alert, alert.NewTopic(alert.GetHeaderBlockErrorMsg).
WithTunnelID(packet.TunnelID).
WithChainName(cp.ChainName))
}
Expand Down
Loading