Skip to content

Commit

Permalink
Merge branch 'develop' into e2e-new-chain-support
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Apr 3, 2024
2 parents 1af1b4f + 64b898c commit bd909a4
Show file tree
Hide file tree
Showing 42 changed files with 1,634 additions and 1,147 deletions.
2 changes: 1 addition & 1 deletion app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool {
*cctxtypes.MsgVoteOnObservedInboundTx,
*cctxtypes.MsgVoteOnObservedOutboundTx,
*cctxtypes.MsgAddToOutTxTracker,
*cctxtypes.MsgCreateTSSVoter,
*observertypes.MsgVoteTSS,
*observertypes.MsgAddBlockHeader,
*observertypes.MsgAddBlameVote:
signers := innerMsg.GetSigners()
Expand Down
22 changes: 11 additions & 11 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestIsSystemTx(t *testing.T) {
// *cctxtypes.MsgVoteOnObservedInboundTx,
// *cctxtypes.MsgVoteOnObservedOutboundTx,
// *cctxtypes.MsgAddToOutTxTracker,
// *cctxtypes.MsgCreateTSSVoter,
// *observertypes.MsgVoteTSS,
// *observertypes.MsgAddBlockHeader,
// *observertypes.MsgAddBlameVote:
buildTxFromMsg := func(msg sdk.Msg) sdk.Tx {
Expand Down Expand Up @@ -64,26 +64,26 @@ func TestIsSystemTx(t *testing.T) {
wantIs bool
}{
{
"MsgCreateTSSVoter",
buildTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
"MsgVoteTSS",
buildTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
TssPubkey: "pubkey1234",
}),
isAuthorizedFalse,
false,
},
{
"MsgCreateTSSVoter",
buildTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
"MsgVoteTSS",
buildTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
TssPubkey: "pubkey1234",
}),
isAuthorized,
true,
},
{
"MsgExec{MsgCreateTSSVoter}",
buildAuthzTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
"MsgExec{MsgVoteTSS}",
buildAuthzTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
TssPubkey: "pubkey1234",
}),
Expand Down Expand Up @@ -169,17 +169,17 @@ func TestIsSystemTx(t *testing.T) {
true,
},
{
"MsgCreateTSSVoter",
buildTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
"MsgVoteTSS",
buildTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgCreateTSSVoter}",
buildAuthzTxFromMsg(&crosschaintypes.MsgCreateTSSVoter{
"MsgExec{MsgVoteTSS}",
buildAuthzTxFromMsg(&observertypes.MsgVoteTSS{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand Down
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* The `Policies` query of the `authority` module must be used to get the current admin policies.
* `PolicyType_group1` has been renamed into `PolicyType_groupEmergency` and `PolicyType_group2` has been renamed into `PolicyType_groupAdmin`.

* `MsgCreateTSSVoter` message in the `crosschain` module has been moved to the `observer` module and renamed to `MsgVoteTSS`.
* The structure of the message remains the same.

### Refactor

* [1511](https://github.com/zeta-chain/node/pull/1511) - move ballot voting logic from `crosschain` to `observer`
Expand All @@ -21,9 +24,9 @@
* [1914](https://github.com/zeta-chain/node/pull/1914) - move crosschain flags to core context in zetaclient
* [1948](https://github.com/zeta-chain/node/pull/1948) - remove deprecated GetTSSAddress query in crosschain module
* [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg
* [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer
* [1853](https://github.com/zeta-chain/node/pull/1853) - refactor vote inbound tx and vote outbound tx


### Features

* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses
Expand Down
17 changes: 8 additions & 9 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@ import (
"strings"
"sync"

"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/onrik/ethrpc"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/testutil/sample"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/bitcoin"
"github.com/zeta-chain/zetacore/zetaclient/config"
corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context"
"github.com/zeta-chain/zetacore/zetaclient/evm"
"github.com/zeta-chain/zetacore/zetaclient/keys"
"github.com/zeta-chain/zetacore/zetaclient/metrics"
"github.com/zeta-chain/zetacore/zetaclient/zetabridge"

"github.com/btcsuite/btcd/rpcclient"
sdk "github.com/cosmos/cosmos-sdk/types"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/testutil/sample"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/config"
)

var debugArgs = debugArguments{}
Expand Down
30 changes: 15 additions & 15 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ flags:
- "common/"

ignore:
- "x/**/client/"
- "x/**/client/**/*"
- "x/**/keeper/keeper.go"
- "x/**/keeper/msg_server.go"
- "x/**/keeper/grpc_query_params.go"
Expand All @@ -50,24 +50,24 @@ ignore:
- "x/**/types/expected_keepers.go"
- "x/**/module.go"
- "x/**/module_simulation.go"
- "x/**/simulation/"
- "x/**/simulation/**/*"
- "**/*.proto"
- "**/*.md"
- "**/*.yml"
- "**/*.yaml"
- "**/*.pb.go"
- "**/*.pb.gw.go"
- "**/*.json"
- ".github/"
- "app/"
- "cmd/"
- "contrib/"
- "docs/"
- "rpc/"
- "proto/"
- "scripts/"
- "server/"
- "testutil/"
- "testutils/"
- "errors/"
- "typescript/"
- ".github/**/*"
- "app/**/*"
- "cmd/**/*"
- "contrib/**/*"
- "docs/**/*"
- "rpc/**/*"
- "proto/**/*"
- "scripts/**/*"
- "server/**/*"
- "testutil/**/*"
- "testutils/**/*"
- "errors/**/*"
- "typescript/**/*"
1 change: 0 additions & 1 deletion docs/cli/zetacored/zetacored_tx_crosschain.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ zetacored tx crosschain [flags]
* [zetacored tx crosschain add-to-in-tx-tracker](zetacored_tx_crosschain_add-to-in-tx-tracker.md) - Add a in-tx-tracker
Use 0:Zeta,1:Gas,2:ERC20
* [zetacored tx crosschain add-to-out-tx-tracker](zetacored_tx_crosschain_add-to-out-tx-tracker.md) - Add a out-tx-tracker
* [zetacored tx crosschain create-tss-voter](zetacored_tx_crosschain_create-tss-voter.md) - Create a new TSSVoter
* [zetacored tx crosschain gas-price-voter](zetacored_tx_crosschain_gas-price-voter.md) - Broadcast message gasPriceVoter
* [zetacored tx crosschain inbound-voter](zetacored_tx_crosschain_inbound-voter.md) - Broadcast message sendVoter
* [zetacored tx crosschain migrate-tss-funds](zetacored_tx_crosschain_migrate-tss-funds.md) - Migrate TSS funds to the latest TSS address
Expand Down
1 change: 1 addition & 0 deletions docs/cli/zetacored/zetacored_tx_observer.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ zetacored tx observer [flags]
* [zetacored tx observer update-crosschain-flags](zetacored_tx_observer_update-crosschain-flags.md) - Update crosschain flags
* [zetacored tx observer update-keygen](zetacored_tx_observer_update-keygen.md) - command to update the keygen block via a group proposal
* [zetacored tx observer update-observer](zetacored_tx_observer_update-observer.md) - Broadcast message add-observer
* [zetacored tx observer vote-tss](zetacored_tx_observer_vote-tss.md) - Vote for a new TSS creation

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# tx crosschain create-tss-voter
# tx observer vote-tss

Create a new TSSVoter
Vote for a new TSS creation

```
zetacored tx crosschain create-tss-voter [pubkey] [keygenBlock] [status] [flags]
zetacored tx observer vote-tss [pubkey] [keygen-block] [status] [flags]
```

### Options
Expand All @@ -21,7 +21,7 @@ zetacored tx crosschain create-tss-voter [pubkey] [keygenBlock] [status] [flags]
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
-h, --help help for create-tss-voter
-h, --help help for vote-tss
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
--ledger Use a connected Ledger device
Expand All @@ -48,5 +48,5 @@ zetacored tx crosschain create-tss-voter [pubkey] [keygenBlock] [status] [flags]

### SEE ALSO

* [zetacored tx crosschain](zetacored_tx_crosschain.md) - crosschain transactions subcommands
* [zetacored tx observer](zetacored_tx_observer.md) - observer transactions subcommands

11 changes: 9 additions & 2 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53701,8 +53701,6 @@ definitions:
is_removed:
type: boolean
title: if the tx was removed from the tracker due to no pending cctx
crosschainMsgCreateTSSVoterResponse:
type: object
crosschainMsgGasPriceVoterResponse:
type: object
crosschainMsgMigrateTssFundsResponse:
Expand Down Expand Up @@ -54324,6 +54322,15 @@ definitions:
type: object
observerMsgUpdateObserverResponse:
type: object
observerMsgVoteTSSResponse:
type: object
properties:
ballot_created:
type: boolean
vote_finalized:
type: boolean
keygen_success:
type: boolean
observerNode:
type: object
properties:
Expand Down
22 changes: 0 additions & 22 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,6 @@ message MsgMigrateTssFunds {
}
```

## MsgCreateTSSVoter

CreateTSSVoter votes on creating a TSS key and recording the information about it (public
key, participant and operator addresses, finalized and keygen heights).

If the vote passes, the information about the TSS key is recorded on chain
and the status of the keygen is set to "success".

Fails if the keygen does not exist, the keygen has been already
completed, or the keygen has failed.

Only node accounts are authorized to broadcast this message.

```proto
message MsgCreateTSSVoter {
string creator = 1;
string tss_pubkey = 2;
int64 keyGenZetaHeight = 3;
chains.ReceiveStatus status = 4;
}
```

## MsgAbortStuckCCTX

AbortStuckCCTX aborts a stuck CCTX
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/crosschain/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ status is changed to final.
## Permissions

| Message | Admin policy account | Observer validator |
| --------------------------- | -------------------- | ------------------ |
| MsgCreateTSSVoter | ||
|-----------------------------| -------------------- | ------------------ |
| MsgVoteTSS | ||
| MsgGasPriceVoter | ||
| MsgVoteOnObservedOutboundTx | ||
| MsgVoteOnObservedInboundTx | ||
Expand Down
22 changes: 22 additions & 0 deletions docs/spec/observer/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,25 @@ message MsgResetChainNonces {
}
```

## MsgVoteTSS

VoteTSS votes on creating a TSS key and recording the information about it (public
key, participant and operator addresses, finalized and keygen heights).

If the vote passes, the information about the TSS key is recorded on chain
and the status of the keygen is set to "success".

Fails if the keygen does not exist, the keygen has been already
completed, or the keygen has failed.

Only node accounts are authorized to broadcast this message.

```proto
message MsgVoteTSS {
string creator = 1;
string tss_pubkey = 2;
int64 keygen_zeta_height = 3;
chains.ReceiveStatus status = 4;
}
```

18 changes: 18 additions & 0 deletions pkg/chains/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package chains

import "errors"

// ReceiveStatusFromString returns a ReceiveStatus from a string using in CLI
// 0 for success, 1 for failed
// TODO: remove "receive" naming ans use outbound
// https://github.com/zeta-chain/node/issues/1797
func ReceiveStatusFromString(str string) (ReceiveStatus, error) {
switch str {
case "0":
return ReceiveStatus_Success, nil
case "1":
return ReceiveStatus_Failed, nil
default:
return ReceiveStatus(0), errors.New("wrong status, must be 0 for success or 1 for failed")
}
}
47 changes: 47 additions & 0 deletions pkg/chains/status_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package chains_test

import (
"testing"

"github.com/stretchr/testify/require"
"github.com/zeta-chain/zetacore/pkg/chains"
)

func TestReceiveStatusFromString(t *testing.T) {
tests := []struct {
name string
str string
want chains.ReceiveStatus
wantErr bool
}{
{
name: "success",
str: "0",
want: chains.ReceiveStatus_Success,
wantErr: false,
},
{
name: "failed",
str: "1",
want: chains.ReceiveStatus_Failed,
wantErr: false,
},
{
name: "wrong status",
str: "2",
want: chains.ReceiveStatus(0),
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := chains.ReceiveStatusFromString(tt.str)
if tt.wantErr {
require.Error(t, err)
} else if got != tt.want {
require.NoError(t, err)
require.Equal(t, tt.want, got)
}
})
}
}
Loading

0 comments on commit bd909a4

Please sign in to comment.