Skip to content

Commit

Permalink
Merge branch 'develop' into mock-mainnet-begin-block-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD authored Sep 25, 2023
2 parents 5cfece2 + a4613fe commit a66d0b7
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 43 deletions.
50 changes: 25 additions & 25 deletions .github/actions/upgrade-testing/scripts/raise_gov_proposal.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@
write_gov_json.write(proposal_json)
write_gov_json.close()

GOV_PROPOSAL = f"""zetacored tx gov submit-proposal gov.json \
--from {os.environ['MONIKER']} \
--chain-id "{os.environ['CHAINID']}" \
--keyring-backend test \
--node "{os.environ['NODE']}" \
--gas=auto \
--gas-adjustment=2 \
--gas-prices={os.environ['GAS_PRICES']} \
-y
"""
# GOV_PROPOSAL = f"""zetacored tx gov submit-proposal gov.json \
# --from {os.environ['MONIKER']} \
# --chain-id "{os.environ['CHAINID']}" \
# --keyring-backend test \
# --node "{os.environ['NODE']}" \
# --gas=auto \
# --gas-adjustment=2 \
# --gas-prices={os.environ['GAS_PRICES']} \
# -y
# """

# GOV_PROPOSAL = f"""zetacored tx gov submit-legacy-proposal software-upgrade "{os.environ['VERSION']}" \
# --from "{os.environ['MONIKER']}" \
# --deposit {os.environ["DEPOSIT"]} \
# --upgrade-height "{str(UPGRADE_HEIGHT).split('.')[0]}" \
# --upgrade-info '{os.environ["UPGRADE_INFO"]}' \
# --title "{os.environ['VERSION']}" \
# --description "Zeta Release {os.environ['VERSION']}" \
# --chain-id "{os.environ['CHAINID']}" \
# --node "{os.environ['NODE']}" \
# --keyring-backend test \
# --gas=auto \
# --gas-adjustment=2 \
# --gas-prices={os.environ['GAS_PRICES']} \
# -y \
# --no-validate"""
GOV_PROPOSAL = f"""zetacored tx gov submit-legacy-proposal software-upgrade "{os.environ['VERSION']}" \
--from "{os.environ['MONIKER']}" \
--deposit {os.environ["DEPOSIT"]} \
--upgrade-height "{str(UPGRADE_HEIGHT).split('.')[0]}" \
--upgrade-info '{os.environ["UPGRADE_INFO"]}' \
--title "{os.environ['VERSION']}" \
--description "Zeta Release {os.environ['VERSION']}" \
--chain-id "{os.environ['CHAINID']}" \
--node "{os.environ['NODE']}" \
--keyring-backend test \
--gas=auto \
--gas-adjustment=2 \
--gas-prices={os.environ['GAS_PRICES']} \
-y \
--no-validate"""

print(GOV_PROPOSAL)
8 changes: 2 additions & 6 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,8 @@ func start(_ *cobra.Command, _ []string) error {
startLogger.Info().Msgf("stop signal received: %s", sig)

// stop zetacore observer
for _, chain := range cfg.GetEnabledChains() {
// zeta chain does not have a chain client
if chain.IsExternalChain() {
(chainClientMap)[chain].Stop()
}

for _, client := range chainClientMap {
client.Stop()
}
zetaBridge.Stop()

Expand Down
8 changes: 4 additions & 4 deletions x/crosschain/client/integrationtests/cli_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func BuildSignedTssVote(t testing.TB, val *network.Validator, denom string, acco
return WriteToNewTempFile(t, res.String())
}

func BuildSignedOutboundVote(t testing.TB, val *network.Validator, denom string, account authtypes.AccountI,
func BuildSignedOutboundVote(t testing.TB, val *network.Validator, denom string, account authtypes.AccountI, nonce uint64,
cctxIndex, outTxHash, valueReceived, status string) *os.File {
cmd := cli.CmdCCTXOutboundVoter()
outboundVoterArgs := []string{
Expand All @@ -135,7 +135,7 @@ func BuildSignedOutboundVote(t testing.TB, val *network.Validator, denom string,
valueReceived,
status,
strconv.FormatInt(common.GoerliChain().ChainId, 10),
"1",
strconv.FormatUint(nonce, 10),
"Zeta",
}
txArgs := []string{
Expand Down Expand Up @@ -205,7 +205,7 @@ func GetBallotIdentifier(message string) string {
return msg.Digest()
}

func GetBallotIdentifierOutBound(cctxindex, outtxHash, valueReceived string) string {
func GetBallotIdentifierOutBound(nonce uint64, cctxindex, outtxHash, valueReceived string) string {
msg := types.NewMsgVoteOnObservedOutboundTx(
"",
cctxindex,
Expand All @@ -217,7 +217,7 @@ func GetBallotIdentifierOutBound(cctxindex, outtxHash, valueReceived string) str
math.NewUintFromString(valueReceived),
0,
common.GoerliChain().ChainId,
1,
nonce,
common.CoinType_Zeta,
)
return msg.Digest()
Expand Down
10 changes: 5 additions & 5 deletions x/crosschain/client/integrationtests/outbound_voter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() {
cctx := crosschaintypes.QueryGetCctxResponse{}
s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &cctx))
s.Assert().Equal(crosschaintypes.CctxStatus_PendingOutbound, cctx.CrossChainTx.CctxStatus.Status)

nonce := cctx.CrossChainTx.GetCurrentOutTxParam().OutboundTxTssNonce
// Check the vote in the ballot and vote the outbound tx
fakeVotes := []string{}
for _, val := range s.network.Validators {
Expand Down Expand Up @@ -194,8 +194,8 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() {
}

// Vote the outbound tx
signedTx := BuildSignedOutboundVote(s.T(), val, s.cfg.BondDenom, account, cctxIdentifier, outTxhash, test.valueReceived, votestring)
out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetBroadcastCommand(), []string{signedTx.Name(), "--broadcast-mode", "sync"})
signedTx := BuildSignedOutboundVote(s.T(), val, s.cfg.BondDenom, account, nonce, cctxIdentifier, outTxhash, test.valueReceived, votestring)
out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, authcli.GetBroadcastCommand(), []string{signedTx.Name(), "--broadcast-mode", "sync", "--output", "json"})
s.Require().NoError(err)
}
s.Require().NoError(s.network.WaitForNBlocks(2))
Expand All @@ -206,7 +206,7 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() {
s.NoError(broadcaster.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &cctx))
s.Assert().Equal(test.cctxStatus, cctx.CrossChainTx.CctxStatus.Status)

outboundBallotIdentifier := GetBallotIdentifierOutBound(cctxIdentifier, test.name, test.valueReceived)
outboundBallotIdentifier := GetBallotIdentifierOutBound(nonce, cctxIdentifier, test.name, test.valueReceived)

out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observerCli.CmdBallotByIdentifier(), []string{outboundBallotIdentifier, "--output", "json"})
s.Require().NoError(err)
Expand All @@ -228,7 +228,7 @@ func (s *IntegrationTestSuite) TestCCTXOutBoundVoter() {
}
}
if len(fakeVotes) > 0 {
outboundFakeBallotIdentifier := GetBallotIdentifierOutBound(cctxIdentifier, test.name+"falseVote", test.valueReceived)
outboundFakeBallotIdentifier := GetBallotIdentifierOutBound(nonce, cctxIdentifier, test.name+"falseVote", test.valueReceived)
out, err = clitestutil.ExecTestCLICmd(broadcaster.ClientCtx, observerCli.CmdBallotByIdentifier(), []string{outboundFakeBallotIdentifier, "--output", "json"})
s.Require().NoError(err)
fakeBallot := observerTypes.QueryBallotByIdentifierResponse{}
Expand Down
4 changes: 4 additions & 0 deletions x/crosschain/keeper/keeper_cross_chain_tx_vote_outbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("CCTX %s does not exist", msg.CctxHash))
}

if cctx.GetCurrentOutTxParam().OutboundTxTssNonce != msg.OutTxTssNonce {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("OutTxTssNonce %d does not match CCTX OutTxTssNonce %d", msg.OutTxTssNonce, cctx.GetCurrentOutTxParam().OutboundTxTssNonce))
}

ballotIndex := msg.Digest()
// Add votes and Set Ballot
ballot, isNew, err := k.zetaObserverKeeper.FindBallot(ctx, ballotIndex, observationChain, observationType)
Expand Down
6 changes: 3 additions & 3 deletions zetaclient/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
func getSatoshis(btc float64) (int64, error) {
// The amount is only considered invalid if it cannot be represented
// as an integer type. This may happen if f is NaN or +-Infinity.
// BTC max amount is 21 mil and its at least 10^(-8) or one satoshi.
// BTC max amount is 21 mil and its at least 0 (Note: bitcoin allows creating 0-value outputs)
switch {
case math.IsNaN(btc):
fallthrough
Expand All @@ -26,8 +26,8 @@ func getSatoshis(btc float64) (int64, error) {
return 0, errors.New("invalid bitcoin amount")
case btc > 21000000.0:
return 0, errors.New("exceeded max bitcoin amount")
case btc < 0.00000001:
return 0, errors.New("cannot be less than 1 satoshi")
case btc < 0.0:
return 0, errors.New("cannot be less than zero")
}
return round(btc * satoshiPerBitcoin), nil
}
Expand Down

0 comments on commit a66d0b7

Please sign in to comment.