Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cli command to fetch inbound ballot from inbound hash and move to zetatools [WIP] #3368

Draft
wants to merge 11 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
fix spellings
  • Loading branch information
kingpinXD committed Jan 17, 2025
commit f4747987690b204c8a73d9c38c075431f8ad4319
6 changes: 3 additions & 3 deletions cmd/zetatool/inbound/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func bitcoinBallotIdentifier(
return "", err
}
if tx.Confirmations < confirmationCount {
confirmationMessage = fmt.Sprintf("tx might not confirmed on chain %d", senderChainID)
confirmationMessage = fmt.Sprintf("tx might not be confirmed on chain %d", senderChainID)
}

blockHash, err := chainhash.NewHashFromStr(tx.BlockHash)
Expand Down Expand Up @@ -162,9 +162,9 @@ func identifierFromBtcEvent(event *zetaclientObserver.BTCInboundEvent,

index := msg.Digest()
if confirmationMessage != "" {
return fmt.Sprintf("ballot idetifier %s warning :%s", index, confirmationMessage), nil
return fmt.Sprintf("ballot identifier %s warning :%s", index, confirmationMessage), nil
}
return fmt.Sprintf("ballot idetifier: %s", msg.Digest()), nil
return fmt.Sprintf("ballot identifier: %s", msg.Digest()), nil
}

// NewInboundVoteFromLegacyMemo creates a MsgVoteInbound message for inbound that uses legacy memo
Expand Down
14 changes: 6 additions & 8 deletions cmd/zetatool/inbound/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
ethrpc "github.com/ethereum/go-ethereum/rpc"
zetaclientrpc "github.com/zeta-chain/node/zetaclient/chains/evm/rpc"
"github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/evm/erc20custody.sol"
"github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/evm/zetaconnector.non-eth.sol"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol"
Expand All @@ -25,6 +24,7 @@ import (
"github.com/zeta-chain/node/pkg/rpc"
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
"github.com/zeta-chain/node/x/observer/types"
zetaclientrpc "github.com/zeta-chain/node/zetaclient/chains/evm/rpc"
clienttypes "github.com/zeta-chain/node/zetaclient/types"
"github.com/zeta-chain/node/zetaclient/zetacore"
)
Expand Down Expand Up @@ -72,13 +72,13 @@ func evmInboundBallotIdentifier(ctx context.Context,
tssEthAddress := res.GetEth()

if tx.To() == nil {
return "", fmt.Errorf("invalid trasnaction,to field is empty %s", inboundHash)
return "", fmt.Errorf("invalid transaction,to field is empty %s", inboundHash)
}

confirmationMessage := ""
confirmed, err := zetaclientrpc.IsTxConfirmed(ctx, evmClient, inboundHash, chainParams.ConfirmationCount)
if err != nil {
return "", fmt.Errorf("unbale to confirm tx %s", err.Error())
return "", fmt.Errorf("unable to confirm tx %s", err.Error())
}
if !confirmed {
confirmationMessage = fmt.Sprintf("tx might not confirmed on chain %d", inboundChain.ChainId)
Expand Down Expand Up @@ -117,7 +117,6 @@ func evmInboundBallotIdentifier(ctx context.Context,
zetaDeposited, err := custody.ParseDeposited(*log)
if err == nil && zetaDeposited != nil {
msg = erc20VoteV1(zetaDeposited, sender, inboundChain.ChainId, zetaChainID)

}
}
}
Expand All @@ -131,7 +130,6 @@ func evmInboundBallotIdentifier(ctx context.Context,
return "", fmt.Errorf("failed to get tx sender %s", err.Error())
}
msg = gasVoteV1(tx, sender, receipt.BlockNumber.Uint64(), inboundChain.ChainId, zetaChainID)

}
case chainParams.GatewayAddress:
{
Expand Down Expand Up @@ -161,13 +159,13 @@ func evmInboundBallotIdentifier(ctx context.Context,
}
}
default:
return "", fmt.Errorf("irrelevant trasnaction , not sent to any known address txHash: %s", inboundHash)
return "", fmt.Errorf("irrelevant transaction , not sent to any known address txHash: %s", inboundHash)
}

if confirmationMessage != "" {
return fmt.Sprintf("ballot idetifier %s warning :%s", msg.Digest(), confirmationMessage), nil
return fmt.Sprintf("ballot identifier %s warning :%s", msg.Digest(), confirmationMessage), nil
}
return fmt.Sprintf("ballot idetifier: %s", msg.Digest()), nil
return fmt.Sprintf("ballot identifier: %s", msg.Digest()), nil
}

func getEvmTx(
Expand Down
6 changes: 3 additions & 3 deletions cmd/zetatool/inbound/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ func GetInboundBallot(cmd *cobra.Command, args []string) error {
func GetBallotIdentifier(inboundHash string, inboundChainID int64, configFile string) error {
observationChain, found := chains.GetChainFromChainID(inboundChainID, []chains.Chain{})
if !found {
return fmt.Errorf("chain not supported,chain id : %d", inboundChainID)
return fmt.Errorf("chain not supported,chain id: %d", inboundChainID)
}

cfg, err := config.GetConfig(observationChain, configFile)
if err != nil {
return fmt.Errorf("failed to get config, %s", err.Error())
return fmt.Errorf("failed to get config: %s", err.Error())
}

zetacoreClient, err := zetacorerpc.NewCometBFTClients(cfg.ZetaChainRPC)
if err != nil {
return fmt.Errorf("failed to create zetacore client, %s", err.Error())
return fmt.Errorf("failed to create zetacore client: %s", err.Error())
}

ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetatool/inbound/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func solanaInboundBallotIdentifier(ctx context.Context,

gatewayID, _, err := solanacontracts.ParseGatewayWithPDA(chainParams.GatewayAddress)
if err != nil {
return "", fmt.Errorf("cannot parse gateway address %s , errr %s", chainParams.GatewayAddress, err.Error())
return "", fmt.Errorf("cannot parse gateway address %s , err %s", chainParams.GatewayAddress, err.Error())
}

logger := &base.ObserverLogger{}
Expand All @@ -66,7 +66,7 @@ func solanaInboundBallotIdentifier(ctx context.Context,
}
}

return fmt.Sprintf("ballot idetifier: %s", msg.Digest()), nil
return fmt.Sprintf("ballot identifier: %s", msg.Digest()), nil
}

// voteMsgFromSolEvent builds a MsgVoteInbound from an inbound event
Expand Down
Loading