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
resolve comments 1
  • Loading branch information
kingpinXD committed Jan 17, 2025
commit 3f3262cdf1ab0bb6c93f8f70680ba3e1100f11bc
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

## unreleased

### Features

* [3368](https://github.com/zeta-chain/node/pull/3368) - cli command to fetch inbound ballot from inbound hash added to zetatools.

### Refactor

* [3332](https://github.com/zeta-chain/node/pull/3332) - implement orchestrator V2. Move BTC observer-signer to V2
* [3368](https://github.com/zeta-chain/node/pull/3368) - refactor cli command to fetch inbound ballot from inbound hash and move to zetatools


## v25.0.0

Expand Down
1 change: 0 additions & 1 deletion cmd/zetaclientd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func init() {
setupGlobalOptions()
setupInitializeConfigOptions()
setupRelayerOptions()
setupInboundOptions()

// Define commands
RootCmd.AddCommand(VersionCmd)
Expand Down
21 changes: 10 additions & 11 deletions cmd/zetatool/inbound_ballot/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
zetaclientObserver "github.com/zeta-chain/node/zetaclient/chains/bitcoin/observer"
)

func BtcInboundBallotIdentified(ctx context.Context,
func btcInboundBallotIdentifier(
cfg config.Config,
zetacoreClient rpc.Clients,
inboundHash string,
Expand Down Expand Up @@ -57,7 +57,6 @@ func BtcInboundBallotIdentified(ctx context.Context,
tssBtcAddress := res.GetBtc()

return bitcoinBallotIdentifier(
ctx,
rpcClient,
params,
tssBtcAddress,
Expand All @@ -67,7 +66,7 @@ func BtcInboundBallotIdentified(ctx context.Context,
)
}

func bitcoinBallotIdentifier(ctx context.Context,
func bitcoinBallotIdentifier(
btcClient *rpcclient.Client,
params *chaincfg.Params,
tss string,
Expand Down Expand Up @@ -153,18 +152,18 @@ func identifierFromBtcEvent(event *zetaclientObserver.BTCInboundEvent,
func voteFromLegacyMemo(
event *zetaclientObserver.BTCInboundEvent,
amountSats *big.Int,
senderChainId int64,
zetacoreChainId int64,
senderChainID int64,
zetacoreChainID int64,
) *crosschaintypes.MsgVoteInbound {
message := hex.EncodeToString(event.MemoBytes)

return crosschaintypes.NewMsgVoteInbound(
"",
event.FromAddress,
senderChainId,
senderChainID,
event.FromAddress,
event.ToAddress,
zetacoreChainId,
zetacoreChainID,
cosmosmath.NewUintFromBigInt(amountSats),
message,
event.TxHash,
Expand All @@ -181,8 +180,8 @@ func voteFromLegacyMemo(
func voteFromStdMemo(
event *zetaclientObserver.BTCInboundEvent,
amountSats *big.Int,
senderChainId int64,
zetacoreChainId int64,
senderChainID int64,
zetacoreChainID int64,
) *crosschaintypes.MsgVoteInbound {
// zetacore will create a revert outbound that points to the custom revert address.
revertOptions := crosschaintypes.RevertOptions{
Expand All @@ -196,10 +195,10 @@ func voteFromStdMemo(
return crosschaintypes.NewMsgVoteInbound(
"",
event.FromAddress,
senderChainId,
senderChainID,
event.FromAddress,
event.ToAddress,
zetacoreChainId,
zetacoreChainID,
cosmosmath.NewUintFromBigInt(amountSats),
message,
event.TxHash,
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetatool/inbound_ballot/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func resolveRPC(chain chains.Chain, cfg config.Config) string {
}[chain.Network]
}

func EvmInboundBallotIdentified(ctx context.Context,
func evmInboundBallotIdentifier(ctx context.Context,
cfg config.Config,
zetacoreClient rpc.Clients,
inboundHash string,
Expand Down
10 changes: 5 additions & 5 deletions cmd/zetatool/inbound_ballot/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"strconv"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"

"github.com/zeta-chain/node/cmd/zetatool/config"
Expand Down Expand Up @@ -56,7 +57,7 @@ func GetBallotIdentifier(inboundHash string, inboundChainID int64, configFile st
ballotIdentifier := ""

if observationChain.IsEVMChain() {
ballotIdentifier, err = EvmInboundBallotIdentified(
ballotIdentifier, err = evmInboundBallotIdentifier(
ctx,
*cfg,
zetacoreClient,
Expand All @@ -74,8 +75,7 @@ func GetBallotIdentifier(inboundHash string, inboundChainID int64, configFile st
}

if observationChain.IsBitcoinChain() {
ballotIdentifier, err = BtcInboundBallotIdentified(
ctx,
ballotIdentifier, err = btcInboundBallotIdentifier(
*cfg,
zetacoreClient,
inboundHash,
Expand All @@ -92,7 +92,7 @@ func GetBallotIdentifier(inboundHash string, inboundChainID int64, configFile st
}

if observationChain.IsSolanaChain() {
ballotIdentifier, err = SolanaInboundBallotIdentified(
ballotIdentifier, err = solanaInboundBallotIdentifier(
ctx,
*cfg,
zetacoreClient,
Expand All @@ -109,6 +109,6 @@ func GetBallotIdentifier(inboundHash string, inboundChainID int64, configFile st
}
}

fmt.Println("Ballot Identifier: ", ballotIdentifier)
log.Info().Msgf("Ballot Identifier: %s", ballotIdentifier)
return nil
}
2 changes: 1 addition & 1 deletion cmd/zetatool/inbound_ballot/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
clienttypes "github.com/zeta-chain/node/zetaclient/types"
)

func SolanaInboundBallotIdentified(ctx context.Context,
func solanaInboundBallotIdentifier(ctx context.Context,
cfg config.Config,
zetacoreClient rpc.Clients,
inboundHash string,
Expand Down
Loading