-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into refactor/improve-start-cmd
- Loading branch information
Showing
70 changed files
with
2,282 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package local | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"strings" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" | ||
"github.com/spf13/cobra" | ||
"gitlab.com/thorchain/tss/go-tss/conversion" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
|
||
"github.com/zeta-chain/node/pkg/rpc" | ||
"github.com/zeta-chain/node/pkg/sdkconfig" | ||
observertypes "github.com/zeta-chain/node/x/observer/types" | ||
) | ||
|
||
const grpcURLFlag = "grpc-url" | ||
|
||
func NewGetZetaclientBootstrap() *cobra.Command { | ||
var cmd = &cobra.Command{ | ||
Use: "get-zetaclient-bootstrap", | ||
Short: "get bootstrap address book entries for zetaclient", | ||
RunE: getZetaclientBootstrap, | ||
} | ||
|
||
cmd.Flags(). | ||
String(grpcURLFlag, "zetacore0:9090", "--grpc-url zetacore0:9090") | ||
|
||
return cmd | ||
} | ||
|
||
func getZetaclientBootstrap(cmd *cobra.Command, _ []string) error { | ||
sdkconfig.SetDefault(true) | ||
grpcURL, _ := cmd.Flags().GetString(grpcURLFlag) | ||
rpcClient, err := rpc.NewGRPCClients( | ||
grpcURL, | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
grpc.WithBlock(), | ||
) | ||
if err != nil { | ||
return fmt.Errorf("get zetacore rpc client: %w", err) | ||
} | ||
var res *observertypes.QueryAllNodeAccountResponse | ||
for { | ||
res, err = rpcClient.Observer.NodeAccountAll(cmd.Context(), &observertypes.QueryAllNodeAccountRequest{}) | ||
if err != nil { | ||
return fmt.Errorf("get all node accounts: %w", err) | ||
} | ||
if len(res.NodeAccount) > 1 { | ||
break | ||
} | ||
fmt.Fprintln(cmd.OutOrStderr(), "waiting for node accounts") | ||
} | ||
|
||
// note that we deliberately do not filter ourselfs/localhost | ||
// to mirror the production configuration | ||
for _, account := range res.NodeAccount { | ||
accAddr, err := sdk.AccAddressFromBech32(account.Operator) | ||
if err != nil { | ||
return err | ||
} | ||
valAddr := sdk.ValAddress(accAddr).String() | ||
validatorRes, err := rpcClient.Staking.Validator(cmd.Context(), &stakingtypes.QueryValidatorRequest{ | ||
ValidatorAddr: valAddr, | ||
}) | ||
if err != nil { | ||
return fmt.Errorf("getting validator info for %s: %w", account.Operator, err) | ||
} | ||
// in localnet, moniker is also the hostname | ||
moniker := validatorRes.Validator.Description.Moniker | ||
|
||
peerID, err := conversion.Bech32PubkeyToPeerID(account.GranteePubkey.Secp256k1.String()) | ||
if err != nil { | ||
return fmt.Errorf("converting pubkey to peerID: %w", err) | ||
} | ||
zetaclientHostname := strings.ReplaceAll(moniker, "zetacore", "zetaclient") | ||
|
||
// resolve the hostname | ||
// something in libp2p/go-tss requires /ip4/<ip> and doesn't tolerate /dns4/<hostname> | ||
ipAddresses, err := net.LookupIP(zetaclientHostname) | ||
if err != nil { | ||
return fmt.Errorf("failed to resolve hostname %s: %w", zetaclientHostname, err) | ||
} | ||
if len(ipAddresses) == 0 { | ||
return fmt.Errorf("no IP addresses found for hostname %s", zetaclientHostname) | ||
} | ||
ipv4Address := "" | ||
for _, ip := range ipAddresses { | ||
if ip.To4() != nil { | ||
ipv4Address = ip.String() | ||
break | ||
} | ||
} | ||
if ipv4Address == "" { | ||
return fmt.Errorf("no IPv4 address found for hostname %s", zetaclientHostname) | ||
} | ||
fmt.Printf("/ip4/%s/tcp/6668/p2p/%s\n", ipv4Address, peerID.String()) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -332,4 +332,4 @@ else | |
|
||
logt "Start Network" | ||
start_network | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Regular E2E tests | ||
|
||
This page lists the regular E2E tests to run when testing the network, in case of upgrade, etc.. | ||
These snippets are aimed to be copy-pasted in the input in the E2E CI tool. | ||
|
||
## Inbounds and outbounds observation | ||
|
||
When we only want to verify the network correctly observe cross-chain transactions, simple deposits and withdraws are sufficient. | ||
|
||
The amount provided represent `0.0001` unit for coin with 18 decimals. | ||
|
||
``` | ||
eth_deposit:100000000000000 eth_withdraw:100000000000000 | ||
``` | ||
|
||
## ERC20 observation | ||
|
||
When we want to verify the network correctly observe cross-chain transactions for ERC20 tokens. | ||
|
||
The amount is set to a small value so it can be used for most ERC20s regardless of the decimals. | ||
|
||
``` | ||
erc20_deposit:1000 erc20_withdraw:1000 | ||
``` | ||
|
||
## Gateway basic workflow | ||
|
||
When we want to verify the gateway basic workflow, the happy path where cross-chain calls succeed. | ||
|
||
The amount is arbitrarily set to a small value, currently the tokens sent to the test contracts are lost. | ||
|
||
``` | ||
eth_deposit_and_call:1000 eth_withdraw_and_call:1000 erc20_deposit_and_call:1000 erc20_withdraw_and_call:1000 zevm_to_evm_call evm_to_zevm_call | ||
``` | ||
|
||
## Solana | ||
|
||
When it is necessary to test the Solana workflows, SOL and SPL tokens. | ||
|
||
``` | ||
solana_deposit:1000 solana_withdraw:1000 solana_deposit_and_call:1000 spl_deposit:1000 spl_withdraw:1000 spl_deposit_and_call:1000 solana_deposit_and_call_revert:20000 | ||
``` | ||
|
||
## Gateway revert workflow | ||
|
||
When we want to verify the gateway revert workflow, the unhappy path where cross-chain calls fail | ||
|
||
### WithdrawAndCall | ||
|
||
The `withdrawAndCall` tests doesn't depend on the provided amount, this list can be used across all networks | ||
|
||
``` | ||
eth_withdraw_and_call_revert:1000 eth_withdraw_and_call_revert_with_call:1000 erc20_withdraw_and_call_revert:1000 erc20_withdraw_and_call_revert_with_call:1000 | ||
``` | ||
|
||
### DepositAndCall | ||
|
||
The amount for reverting `depositAndCall` must depend on the chain as the value in the CCTX is used to pay for the revert fee. | ||
|
||
Note: these are estimated required values for mainnet based on the current gas price, the actual value might be different and fine-tuned. The values for ERC20 tests are set for USDC token. | ||
|
||
Ethereum: `0.0007ETH` and `3USDC` | ||
|
||
``` | ||
eth_deposit_and_call_revert:700000000000000 eth_deposit_and_call_revert_with_call:700000000000000 erc20_deposit_and_call_revert:3000000 erc20_deposit_and_call_revert_with_call:3000000 | ||
``` | ||
|
||
BSC: `0.0008BNB` and `0.5USDC` | ||
|
||
``` | ||
eth_deposit_and_call_revert:800000000000000 eth_deposit_and_call_revert_with_call:800000000000000 erc20_deposit_and_call_revert:500000 erc20_deposit_and_call_revert_with_call:500000 | ||
``` | ||
|
||
Polygon: `0.008POL` and `0.01USDC` | ||
|
||
``` | ||
eth_deposit_and_call_revert:8000000000000000 eth_deposit_and_call_revert_with_call:8000000000000000 erc20_deposit_and_call_revert:10000 erc20_deposit_and_call_revert_with_call:10000 | ||
``` | ||
|
||
Base: `0.000005ETH` and `0.02USDC` | ||
|
||
``` | ||
eth_deposit_and_call_revert:5000000000000 eth_deposit_and_call_revert_with_call:5000000000000 erc20_deposit_and_call_revert:20000 erc20_deposit_and_call_revert_with_call:20000 | ||
``` | ||
|
||
## Gateway arbitrary calls | ||
|
||
Arbitrary calls feature is an experimental and niche use case for now, these tests are not necessary for regular testing. | ||
|
||
``` | ||
eth_withdraw_and_arbitrary_call:1000 erc20_withdraw_and_arbitrary_call:1000 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.