Skip to content

Commit

Permalink
refactor(votes)!: drop support for header proofs (#3125)
Browse files Browse the repository at this point in the history
* Revome block header proofs from zetaclient

* Remove proofs from NewMsgAddOutboundTracker

* Removed block header proofs from cctx cosmos module

* Removed block header proof for vote inbound tracker

* Update changelog

* Update codegen

* Address PR comments
  • Loading branch information
swift1337 authored Nov 8, 2024
1 parent 6d7b91d commit 1f2c1e1
Show file tree
Hide file tree
Showing 29 changed files with 269 additions and 1,453 deletions.
5 changes: 2 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
* [2984](https://github.com/zeta-chain/node/pull/2984) - add Whitelist message ability to whitelist SPL tokens on Solana
* [3091](https://github.com/zeta-chain/node/pull/3091) - improve build reproducability. `make release{,-build-only}` checksums should now be stable.

### Refactor
* [3122](https://github.com/zeta-chain/node/pull/3122) - improve & refactor zetaclientd cli

### Tests
* [3075](https://github.com/zeta-chain/node/pull/3075) - ton: withdraw concurrent, deposit & revert.

### Refactor
* [3118](https://github.com/zeta-chain/node/pull/3118) - zetaclient: remove hsm signer
* [3122](https://github.com/zeta-chain/node/pull/3122) - improve & refactor zetaclientd cli
* [3125](https://github.com/zeta-chain/node/pull/3125) - drop support for header proofs

### Fixes
* [3041](https://github.com/zeta-chain/node/pull/3041) - replace libp2p public DHT with private gossip peer discovery and connection gater for inbound connections
Expand Down
2 changes: 0 additions & 2 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57603,8 +57603,6 @@ definitions:
type: string
tx_signer:
type: string
proved:
type: boolean
cryptoPubKeySet:
type: object
properties:
Expand Down
6 changes: 0 additions & 6 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ message MsgAddOutboundTracker {
int64 chain_id = 2;
uint64 nonce = 3;
string tx_hash = 4;
pkg.proofs.Proof proof = 5;
string block_hash = 6;
int64 tx_index = 7;
}
```

Expand All @@ -28,9 +25,6 @@ message MsgAddInboundTracker {
int64 chain_id = 2;
string tx_hash = 3;
pkg.coin.CoinType coin_type = 4;
pkg.proofs.Proof proof = 5;
string block_hash = 6;
int64 tx_index = 7;
}
```

Expand Down
4 changes: 3 additions & 1 deletion proto/zetachain/zetacore/crosschain/outbound_tracker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ option go_package = "github.com/zeta-chain/node/x/crosschain/types";
message TxHash {
string tx_hash = 1;
string tx_signer = 2;
bool proved = 3;

// used to be `bool proven` (for block header verification)
reserved 3;
}
message OutboundTracker {
string index = 1; // format: "chain-nonce"
Expand Down
12 changes: 6 additions & 6 deletions proto/zetachain/zetacore/crosschain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ message MsgAddInboundTracker {
int64 chain_id = 2;
string tx_hash = 3;
pkg.coin.CoinType coin_type = 4;
pkg.proofs.Proof proof = 5;
string block_hash = 6;
int64 tx_index = 7;

// used to be block header profs properties
reserved 5, 6, 7;
}
message MsgAddInboundTrackerResponse {}

Expand All @@ -92,9 +92,9 @@ message MsgAddOutboundTracker {
int64 chain_id = 2;
uint64 nonce = 3;
string tx_hash = 4;
pkg.proofs.Proof proof = 5;
string block_hash = 6;
int64 tx_index = 7;

// used to be block header profs properties
reserved 5, 6, 7;
}

message MsgAddOutboundTrackerResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ export declare class TxHash extends Message<TxHash> {
*/
txSigner: string;

/**
* @generated from field: bool proved = 3;
*/
proved: boolean;

constructor(data?: PartialMessage<TxHash>);

static readonly runtime: typeof proto3;
Expand Down
31 changes: 0 additions & 31 deletions typescript/zetachain/zetacore/crosschain/tx_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf";
import { Message, proto3 } from "@bufbuild/protobuf";
import type { CoinType } from "../pkg/coin/coin_pb.js";
import type { Proof } from "../pkg/proofs/proofs_pb.js";
import type { ReceiveStatus } from "../pkg/chains/chains_pb.js";
import type { CallOptions, ProtocolContractVersion, RevertOptions } from "./cross_chain_tx_pb.js";
import type { RateLimiterFlags } from "./rate_limiter_flags_pb.js";
Expand Down Expand Up @@ -136,21 +135,6 @@ export declare class MsgAddInboundTracker extends Message<MsgAddInboundTracker>
*/
coinType: CoinType;

/**
* @generated from field: zetachain.zetacore.pkg.proofs.Proof proof = 5;
*/
proof?: Proof;

/**
* @generated from field: string block_hash = 6;
*/
blockHash: string;

/**
* @generated from field: int64 tx_index = 7;
*/
txIndex: bigint;

constructor(data?: PartialMessage<MsgAddInboundTracker>);

static readonly runtime: typeof proto3;
Expand Down Expand Up @@ -294,21 +278,6 @@ export declare class MsgAddOutboundTracker extends Message<MsgAddOutboundTracker
*/
txHash: string;

/**
* @generated from field: zetachain.zetacore.pkg.proofs.Proof proof = 5;
*/
proof?: Proof;

/**
* @generated from field: string block_hash = 6;
*/
blockHash: string;

/**
* @generated from field: int64 tx_index = 7;
*/
txIndex: bigint;

constructor(data?: PartialMessage<MsgAddOutboundTracker>);

static readonly runtime: typeof proto3;
Expand Down
11 changes: 2 additions & 9 deletions x/crosschain/client/cli/tx_add_outbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,8 @@ func CmdAddOutboundTracker() *cobra.Command {
return err
}

msg := types.NewMsgAddOutboundTracker(
clientCtx.GetFromAddress().String(),
argChain,
argNonce,
argTxHash,
nil, // TODO: add option to provide a proof from CLI arguments https://github.com/zeta-chain/node/issues/1134
"",
-1,
)
creator := clientCtx.GetFromAddress().String()
msg := types.NewMsgAddOutboundTracker(creator, argChain, argNonce, argTxHash)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
Expand Down
55 changes: 6 additions & 49 deletions x/crosschain/keeper/msg_server_add_inbound_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"fmt"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -23,27 +22,14 @@ func (k msgServer) AddInboundTracker(
return nil, observertypes.ErrSupportedChains
}

// check if the msg signer is from the emergency group policy address.It is okay to ignore the error as the sender can also be an observer
isAuthorizedPolicy := false
err := k.GetAuthorityKeeper().CheckAuthorization(ctx, msg)
if err == nil {
isAuthorizedPolicy = true
}

// check if the msg signer is an observer
isObserver := k.GetObserverKeeper().IsNonTombstonedObserver(ctx, msg.Creator)
// only emergency group and observer can submit a tracker
var (
isAuthorizedPolicy = k.GetAuthorityKeeper().CheckAuthorization(ctx, msg) == nil
isObserver = k.GetObserverKeeper().IsNonTombstonedObserver(ctx, msg.Creator)
)

// only emergency group and observer can submit tracker without proof
// if the sender is not from the emergency group or observer, the inbound proof must be provided
if !(isAuthorizedPolicy || isObserver) {
if msg.Proof == nil {
return nil, errorsmod.Wrap(authoritytypes.ErrUnauthorized, fmt.Sprintf("Creator %s", msg.Creator))
}

// verify the proof and tx body
if err := verifyProofAndInboundBody(ctx, k, msg); err != nil {
return nil, err
}
return nil, errorsmod.Wrapf(authoritytypes.ErrUnauthorized, "Creator %s", msg.Creator)
}

// add the inTx tracker
Expand All @@ -55,32 +41,3 @@ func (k msgServer) AddInboundTracker(

return &types.MsgAddInboundTrackerResponse{}, nil
}

// verifyProofAndInboundBody verifies the proof and inbound tx body
func verifyProofAndInboundBody(ctx sdk.Context, k msgServer, msg *types.MsgAddInboundTracker) error {
txBytes, err := k.GetLightclientKeeper().VerifyProof(ctx, msg.Proof, msg.ChainId, msg.BlockHash, msg.TxIndex)
if err != nil {
return types.ErrProofVerificationFail.Wrap(err.Error())
}

// get chain params and tss addresses to verify the inTx body
chainParams, found := k.GetObserverKeeper().GetChainParamsByChainID(ctx, msg.ChainId)
if !found || chainParams == nil {
return types.ErrUnsupportedChain.Wrapf("chain params not found for chain %d", msg.ChainId)
}
tss, err := k.GetObserverKeeper().GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{
BitcoinChainId: msg.ChainId,
})
if err != nil {
return observertypes.ErrTssNotFound.Wrap(err.Error())
}
if tss == nil {
return observertypes.ErrTssNotFound.Wrapf("tss address nil")
}

if err := types.VerifyInboundBody(*msg, txBytes, *chainParams, *tss); err != nil {
return types.ErrTxBodyVerificationFail.Wrap(err.Error())
}

return nil
}
Loading

0 comments on commit 1f2c1e1

Please sign in to comment.