Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

* [1591](https://github.com/zeta-chain/node/pull/1591) - support lower gas limit for voting on inbound and outbound transactions

## Version: v12.0.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetaclientd-genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ else
SEED=$(curl --retry 10 --retry-delay 5 --retry-connrefused -s zetaclient0:8123/p2p)
done
rm ~/.tss/*
zetaclientd init --peer /ip4/172.20.0.21/tcp/6668/p2p/"$SEED" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 0 --keyring-backend "$BACKEND"
zetaclientd init --peer /ip4/172.20.0.21/tcp/6668/p2p/"$SEED" --zetacore-url "$node" --chain-id athens_101-1 --operator "$operatorAddress" --log-format=text --public-ip "$MYIP" --log-level 1 --keyring-backend "$BACKEND"
zetaclientd start
fi
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetaclientd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ else
zetaclientd init \
--peer /ip4/172.20.0.21/tcp/6668/p2p/$SEED \
--pre-params ~/preParams.json --zetacore-url $node \
--chain-id athens_101-1 --operator zeta1lz2fqwzjnk6qy48fgj753h48444fxtt7hekp52 --log-level 0 --hotkey=val_grantee_observer
--chain-id athens_101-1 --operator zeta1lz2fqwzjnk6qy48fgj753h48444fxtt7hekp52 --log-level 1 --hotkey=val_grantee_observer
zetaclientd start
fi
6 changes: 3 additions & 3 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,12 @@ func (ob *BitcoinChainClient) observeInTx() error {
// post inbound vote message to zetacore
for _, inTx := range inTxs {
msg := ob.GetInboundVoteMessageFromBtcEvent(inTx)
zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, msg)
if err != nil {
ob.logger.WatchInTx.Error().Err(err).Msgf("observeInTxBTC: error posting to zeta core for tx %s", inTx.TxHash)
return err // we have to re-scan this block next time
} else if zetaHash != "" {
ob.logger.WatchInTx.Info().Msgf("observeInTxBTC: BTC deposit detected and reported: PostSend zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.WatchInTx.Info().Msgf("observeInTxBTC: BTC deposit detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
}
}

Expand Down Expand Up @@ -470,7 +470,7 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64
}

logger.Debug().Msgf("Bitcoin outTx confirmed: txid %s, amount %s\n", res.TxID, amountInSat.String())
zetaHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
res.TxID,
// #nosec G701 always positive
Expand Down
8 changes: 3 additions & 5 deletions zetaclient/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
b.seqNumber[authzSigner.KeyType] = seqNumber
}
}
//b.logger.Info().Uint64("account_number", b.accountNumber).Uint64("sequence_number", b.seqNumber).Msg("account info")

flags := flag.NewFlagSet("zetacore", 0)

Expand All @@ -69,12 +68,13 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
if err != nil {
return "", err
}

builder.SetGasLimit(gaslimit)

// #nosec G701 always in range
fee := sdktypes.NewCoins(sdktypes.NewCoin(config.BaseDenom,
cosmos.NewInt(int64(gaslimit)).Mul(cosmos.NewInt(baseGasPrice))))
builder.SetFeeAmount(fee)
//fmt.Printf("signing from name: %s\n", ctx.GetFromName())
err = b.SignTx(factory, ctx.GetFromName(), builder, true, ctx.TxConfig)
if err != nil {
return "", err
Expand All @@ -90,6 +90,7 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
b.logger.Error().Err(err).Msgf("fail to broadcast tx %s", err.Error())
return "", err
}

// Code will be the tendermint ABICode , it start at 1 , so if it is an error , code will not be zero
if commit.Code > 0 {
if commit.Code == 32 {
Expand All @@ -114,11 +115,8 @@ func (b *ZetaCoreBridge) Broadcast(gaslimit uint64, authzWrappedMsg sdktypes.Msg
}
return commit.TxHash, fmt.Errorf("fail to broadcast to zetachain,code:%d, log:%s", commit.Code, commit.RawLog)
}
//b.logger.Debug().Msgf("Received a TxHash of %v from the metachain, Code %d, log %s", commit.TxHash, commit.Code, commit.Logs)

// increment seqNum
//seq := b.seqNumber[authzSigner.KeyType]
//atomic.AddUint64(&seq, 1)
b.seqNumber[authzSigner.KeyType] = b.seqNumber[authzSigner.KeyType] + 1

return commit.TxHash, nil
Expand Down
32 changes: 16 additions & 16 deletions zetaclient/evm_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
if receipt.Status == 1 {
recvStatus = common.ReceiveStatus_Success
}
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
receipt.TxHash.Hex(),
receipt.BlockNumber.Uint64(),
Expand All @@ -340,7 +340,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co

} else if cointype == common.CoinType_Gas { // the outbound is a regular Ether/BNB/Matic transfer; no need to check events
if receipt.Status == 1 {
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
receipt.TxHash.Hex(),
receipt.BlockNumber.Uint64(),
Expand All @@ -361,7 +361,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
return true, true, nil
} else if receipt.Status == 0 { // the same as below events flow
logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex())
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
receipt.TxHash.Hex(),
receipt.BlockNumber.Uint64(),
Expand All @@ -375,7 +375,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
common.CoinType_Gas,
)
if err != nil {
logger.Error().Err(err).Msgf("PostReceiveConfirmation error in WatchTxHashWithTimeout; zeta tx hash %s cctx %s nonce %d", zetaTxHash, sendHash, nonce)
logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s cctx %s nonce %d", zetaTxHash, sendHash, nonce)
} else if zetaTxHash != "" {
logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot)
}
Expand Down Expand Up @@ -405,7 +405,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
sendhash := vLog.Topics[3].Hex()
//var rxAddress string = ethcommon.HexToAddress(vLog.Topics[1].Hex()).Hex()
mMint := receivedLog.ZetaValue
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendhash,
vLog.TxHash.Hex(),
vLog.BlockNumber,
Expand Down Expand Up @@ -442,7 +442,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
}
sendhash := vLog.Topics[2].Hex()
mMint := revertedLog.RemainingZetaValue
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendhash,
vLog.TxHash.Hex(),
vLog.BlockNumber,
Expand Down Expand Up @@ -470,7 +470,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
} else if receipt.Status == 0 {
//FIXME: check nonce here by getTransaction RPC
logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex())
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
receipt.TxHash.Hex(),
receipt.BlockNumber.Uint64(),
Expand Down Expand Up @@ -510,7 +510,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
}
if confHeight <= ob.GetLastBlockHeight() {
logger.Info().Msg("Confirmed! Sending PostConfirmation to zetacore...")
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
vLog.TxHash.Hex(),
vLog.BlockNumber,
Expand All @@ -537,7 +537,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
}
} else {
logger.Info().Msgf("Found (failed tx) sendHash %s on chain %s txhash %s", sendHash, ob.chain.String(), receipt.TxHash.Hex())
zetaTxHash, ballot, err := ob.zetaClient.PostReceiveConfirmation(
zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound(
sendHash,
receipt.TxHash.Hex(),
receipt.BlockNumber.Uint64(),
Expand All @@ -551,7 +551,7 @@ func (ob *EVMChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64, co
common.CoinType_ERC20,
)
if err != nil {
logger.Error().Err(err).Msgf("PostReceiveConfirmation error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash)
logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash)
} else if zetaTxHash != "" {
logger.Info().Msgf("Zeta tx hash: %s cctx %s nonce %d ballot %s", zetaTxHash, sendHash, nonce, ballot)
}
Expand Down Expand Up @@ -971,15 +971,15 @@ func (ob *EVMChainClient) observeZetaSent(startBlock, toBlock uint64) uint64 {
"observeZetaSent: error getting inbound vote msg for tx %s chain %d", event.Raw.TxHash.Hex(), ob.chain.ChainId)
continue
}
zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendNonEVMGasLimit, &msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundMessagePassingExecutionGasLimit, &msg)
if err != nil {
ob.logger.ExternalChainWatcher.Error().Err(err).Msgf(
"observeZetaSent: error posting event to zeta core for tx %s at height %d for chain %d",
event.Raw.TxHash.Hex(), event.Raw.BlockNumber, ob.chain.ChainId)
return beingScanned - 1 // we have to re-scan from this block next time
} else if zetaHash != "" {
ob.logger.ExternalChainWatcher.Info().Msgf(
"observeZetaSent: event detected in tx %s at height %d for chain %d, PostSend zeta tx: %s ballot %s",
"observeZetaSent: event detected in tx %s at height %d for chain %d, PostVoteInbound zeta tx: %s ballot %s",
event.Raw.TxHash.Hex(), event.Raw.BlockNumber, ob.chain.ChainId, zetaHash, ballot)
}
}
Expand Down Expand Up @@ -1050,15 +1050,15 @@ func (ob *EVMChainClient) observeERC20Deposited(startBlock, toBlock uint64) uint
"observeERC20Deposited: error getting inbound vote msg for tx %s chain %d", event.Raw.TxHash.Hex(), ob.chain.ChainId)
continue
}
zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, &msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, &msg)
if err != nil {
ob.logger.ExternalChainWatcher.Error().Err(err).Msgf(
"observeERC20Deposited: error posting event to zeta core for tx %s at height %d for chain %d",
event.Raw.TxHash.Hex(), event.Raw.BlockNumber, ob.chain.ChainId)
return beingScanned - 1 // we have to re-scan from this block next time
} else if zetaHash != "" {
ob.logger.ExternalChainWatcher.Info().Msgf(
"observeERC20Deposited: event detected in tx %s at height %d for chain %d, PostSend zeta tx: %s ballot %s",
"observeERC20Deposited: event detected in tx %s at height %d for chain %d, PostVoteInbound zeta tx: %s ballot %s",
event.Raw.TxHash.Hex(), event.Raw.BlockNumber, ob.chain.ChainId, zetaHash, ballot)
}
}
Expand Down Expand Up @@ -1133,14 +1133,14 @@ func (ob *EVMChainClient) observeTssRecvd(startBlock, toBlock uint64, flags obse
if msg == nil {
continue
}
zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, msg)
if err != nil {
ob.logger.ExternalChainWatcher.Error().Err(err).Msgf(
"observeTssRecvd: error posting to zeta core for tx %s at height %d for chain %d", tx.Hash().Hex(), bn, ob.chain.ChainId)
return startBlock - 1 // we have to re-scan this block next time
} else if zetaHash != "" {
ob.logger.ExternalChainWatcher.Info().Msgf(
"observeTssRecvd: gas asset deposit detected in tx %s at height %d for chain %d, PostSend zeta tx: %s ballot %s",
"observeTssRecvd: gas asset deposit detected in tx %s at height %d for chain %d, PostVoteInbound zeta tx: %s ballot %s",
tx.Hash().Hex(), bn, ob.chain.ChainId, zetaHash, ballot)
}
}
Expand Down
16 changes: 8 additions & 8 deletions zetaclient/inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ func (ob *BitcoinChainClient) CheckReceiptForBtcTxHash(txHash string, vote bool)
if !vote {
return msg.Digest(), nil
}
zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, msg)
if err != nil {
ob.logger.WatchInTx.Error().Err(err).Msg("error posting to zeta core")
return "", err
} else if ballot == "" {
ob.logger.WatchInTx.Info().Msgf("BTC deposit detected and reported: PostSend zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.WatchInTx.Info().Msgf("BTC deposit detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
}
return msg.Digest(), nil
}
Expand Down Expand Up @@ -192,12 +192,12 @@ func (ob *EVMChainClient) CheckReceiptForCoinTypeZeta(txHash string, vote bool)
return msg.Digest(), nil
}

zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendNonEVMGasLimit, &msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundMessagePassingExecutionGasLimit, &msg)
if err != nil {
ob.logger.ExternalChainWatcher.Error().Err(err).Msg("error posting to zeta core")
return "", err
} else if zetaHash != "" {
ob.logger.ExternalChainWatcher.Info().Msgf("ZetaSent event detected and reported: PostSend zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.ExternalChainWatcher.Info().Msgf("ZetaSent event detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
}

return msg.Digest(), nil
Expand Down Expand Up @@ -240,12 +240,12 @@ func (ob *EVMChainClient) CheckReceiptForCoinTypeERC20(txHash string, vote bool)
return msg.Digest(), nil
}

zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, &msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, &msg)
if err != nil {
ob.logger.ExternalChainWatcher.Error().Err(err).Msg("error posting to zeta core")
return "", err
} else if zetaHash != "" {
ob.logger.ExternalChainWatcher.Info().Msgf("ERC20 Deposit event detected and reported: PostSend zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.ExternalChainWatcher.Info().Msgf("ERC20 Deposit event detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
}

return msg.Digest(), nil
Expand Down Expand Up @@ -297,12 +297,12 @@ func (ob *EVMChainClient) CheckReceiptForCoinTypeGas(txHash string, vote bool) (
return msg.Digest(), nil
}

zetaHash, ballot, err := ob.zetaClient.PostSend(PostSendEVMGasLimit, msg)
zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(PostVoteInboundGasLimit, PostVoteInboundExecutionGasLimit, msg)
if err != nil {
ob.logger.ExternalChainWatcher.Error().Err(err).Msg("error posting to zeta core")
return "", err
} else if zetaHash != "" {
ob.logger.ExternalChainWatcher.Info().Msgf("Gas deposit detected and reported: PostSend zeta tx: %s ballot %s", zetaHash, ballot)
ob.logger.ExternalChainWatcher.Info().Msgf("Gas deposit detected and reported: PostVoteInbound zeta tx: %s ballot %s", zetaHash, ballot)
}

return msg.Digest(), nil
Expand Down
4 changes: 2 additions & 2 deletions zetaclient/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type ChainSigner interface {

// ZetaCoreBridger is the interface to interact with ZetaCore
type ZetaCoreBridger interface {
PostSend(zetaGasLimit uint64, msg *crosschaintypes.MsgVoteOnObservedInboundTx) (string, string, error)
PostReceiveConfirmation(
PostVoteInbound(gasLimit, retryGasLimit uint64, msg *crosschaintypes.MsgVoteOnObservedInboundTx) (string, string, error)
Copy link
Contributor

@kevinssgh kevinssgh Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retryGasLimit - I see you're passing the execution gas limit here. Should the name be retry gas limit instead of execution gas limit?

PostVoteOutbound(
sendHash string,
outTxHash string,
outBlockHeight uint64,
Expand Down
Loading