Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/btc-obs-extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 authored Jan 23, 2025
2 parents ea7b697 + ac3b447 commit b1ad198
Show file tree
Hide file tree
Showing 48 changed files with 685 additions and 271 deletions.
6 changes: 5 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGELOG

## unreleased
## Unreleased

### Features

* [3353](https://github.com/zeta-chain/node/pull/3353) - add liquidity cap parameter to ZRC20 creation

### Refactor

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
noError(err)

// monitor block production to ensure we fail fast if there are consensus failures
// this is not run in an errgroup since only returning an error will not exit immedately
// this is not run in an errgroup since only returning an error will not exit immediately
// this needs to be early to quickly detect consensus failure during genesis
go monitorBlockProductionExit(ctx, conf)

Expand Down
1 change: 1 addition & 0 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ message MsgWhitelistERC20 {
string symbol = 5;
uint32 decimals = 6;
int64 gas_limit = 7;
string liquidity_cap = 8;
}
```

Expand Down
1 change: 1 addition & 0 deletions docs/spec/fungible/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ message MsgDeployFungibleCoinZRC20 {
string symbol = 6;
pkg.coin.CoinType coin_type = 7;
int64 gas_limit = 8;
string liquidity_cap = 9;
}
```

Expand Down
3 changes: 3 additions & 0 deletions e2e/e2etests/test_migrate_chain_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/exec"
"time"

sdkmath "cosmossdk.io/math"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
Expand Down Expand Up @@ -79,6 +80,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
"sETH",
coin.CoinType_Gas,
100000,
nil,
),
)
require.NoError(r, err)
Expand Down Expand Up @@ -165,6 +167,7 @@ func TestMigrateChainSupport(r *runner.E2ERunner, _ []string) {
"USDT",
18,
100000,
sdkmath.NewUintFromString("100000000000000000000000000"),
))
require.NoError(r, err)

Expand Down
15 changes: 13 additions & 2 deletions e2e/e2etests/test_solana_whitelist_spl.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package e2etests

import (
sdkmath "cosmossdk.io/math"
"github.com/gagliardetto/solana-go"
"github.com/gagliardetto/solana-go/rpc"
"github.com/stretchr/testify/require"

"github.com/zeta-chain/node/e2e/runner"
Expand All @@ -26,7 +28,11 @@ func TestSolanaWhitelistSPL(r *runner.E2ERunner, _ []string) {
whitelistEntryPDA, _, err := solana.FindProgramAddress(seed, r.GatewayProgram)
require.NoError(r, err)

whitelistEntryInfo, err := r.SolanaClient.GetAccountInfo(r.Ctx, whitelistEntryPDA)
whitelistEntryInfo, err := r.SolanaClient.GetAccountInfoWithOpts(
r.Ctx,
whitelistEntryPDA,
&rpc.GetAccountInfoOpts{Commitment: rpc.CommitmentConfirmed},
)
require.Error(r, err)
require.Nil(r, whitelistEntryInfo)

Expand All @@ -40,6 +46,7 @@ func TestSolanaWhitelistSPL(r *runner.E2ERunner, _ []string) {
"TESTSPL",
6,
100000,
sdkmath.NewUintFromString("100000000000000000000000000"),
))
require.NoError(r, err)

Expand All @@ -62,7 +69,11 @@ func TestSolanaWhitelistSPL(r *runner.E2ERunner, _ []string) {
r.WaitForMinedCCTXFromIndex(whitelistCCTXIndex)

// check that whitelist entry exists for this spl
whitelistEntryInfo, err = r.SolanaClient.GetAccountInfo(r.Ctx, whitelistEntryPDA)
whitelistEntryInfo, err = r.SolanaClient.GetAccountInfoWithOpts(
r.Ctx,
whitelistEntryPDA,
&rpc.GetAccountInfoOpts{Commitment: rpc.CommitmentConfirmed},
)
require.NoError(r, err)
require.NotNil(r, whitelistEntryInfo)
}
8 changes: 4 additions & 4 deletions e2e/e2etests/test_spl_deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ func TestSPLDeposit(r *runner.E2ERunner, args []string) {
pda := r.ComputePdaAddress()
pdaAta := r.ResolveSolanaATA(privKey, pda, r.SPLAddr)

pdaBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentFinalized)
pdaBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

senderAta := r.ResolveSolanaATA(privKey, privKey.PublicKey(), r.SPLAddr)
senderBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentFinalized)
senderBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

// get zrc20 balance for recipient
Expand All @@ -45,10 +45,10 @@ func TestSPLDeposit(r *runner.E2ERunner, args []string) {
require.Equal(r, cctx.GetCurrentOutboundParam().Receiver, r.EVMAddress().Hex())

// verify balances are updated
pdaBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentFinalized)
pdaBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

senderBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentFinalized)
senderBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

zrc20BalanceAfter, err := r.SPLZRC20.BalanceOf(&bind.CallOpts{}, r.EVMAddress())
Expand Down
8 changes: 4 additions & 4 deletions e2e/e2etests/test_spl_deposit_and_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ func TestSPLDepositAndCall(r *runner.E2ERunner, args []string) {
pda := r.ComputePdaAddress()
pdaAta := r.ResolveSolanaATA(privKey, pda, r.SPLAddr)

pdaBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentFinalized)
pdaBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

senderAta := r.ResolveSolanaATA(privKey, privKey.PublicKey(), r.SPLAddr)
senderBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentFinalized)
senderBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

// get zrc20 balance for recipient
Expand All @@ -55,10 +55,10 @@ func TestSPLDepositAndCall(r *runner.E2ERunner, args []string) {
utils.MustHaveCalledExampleContractWithMsg(r, contract, big.NewInt(int64(amount)), data)

// verify balances are updated
pdaBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentFinalized)
pdaBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, pdaAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

senderBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentFinalized)
senderBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, senderAta, rpc.CommitmentConfirmed)
require.NoError(r, err)

zrc20BalanceAfter, err := r.SPLZRC20.BalanceOf(&bind.CallOpts{}, contractAddr)
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_spl_withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestSPLWithdraw(r *runner.E2ERunner, args []string) {

// get receiver ata balance before withdraw
receiverAta := r.ResolveSolanaATA(privkey, privkey.PublicKey(), r.SPLAddr)
receiverBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentFinalized)
receiverBalanceBefore, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentConfirmed)
require.NoError(r, err)
r.Logger.Info("receiver balance of SPL before withdraw: %s", receiverBalanceBefore.Value.Amount)

Expand All @@ -57,7 +57,7 @@ func TestSPLWithdraw(r *runner.E2ERunner, args []string) {
r.Logger.Info("runner balance of SPL after withdraw: %d", zrc20BalanceAfter)

// verify balances are updated
receiverBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentFinalized)
receiverBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentConfirmed)
require.NoError(r, err)
r.Logger.Info("receiver balance of SPL after withdraw: %s", receiverBalanceAfter.Value.Amount)

Expand Down
14 changes: 11 additions & 3 deletions e2e/e2etests/test_spl_withdraw_and_create_receiver_ata.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func TestSPLWithdrawAndCreateReceiverAta(r *runner.E2ERunner, args []string) {
receiverAta, _, err := solana.FindAssociatedTokenAddress(receiverPrivKey.PublicKey(), r.SPLAddr)
require.NoError(r, err)

receiverAtaAcc, err := r.SolanaClient.GetAccountInfo(r.Ctx, receiverAta)
receiverAtaAcc, err := r.SolanaClient.GetAccountInfoWithOpts(
r.Ctx,
receiverAta,
&rpc.GetAccountInfoOpts{Commitment: rpc.CommitmentConfirmed},
)
require.Error(r, err)
require.Nil(r, receiverAtaAcc)

Expand All @@ -62,12 +66,16 @@ func TestSPLWithdrawAndCreateReceiverAta(r *runner.E2ERunner, args []string) {
r.Logger.Info("runner balance of SPL after withdraw: %d", zrc20BalanceAfter)

// verify receiver ata was created
receiverAtaAcc, err = r.SolanaClient.GetAccountInfo(r.Ctx, receiverAta)
receiverAtaAcc, err = r.SolanaClient.GetAccountInfoWithOpts(
r.Ctx,
receiverAta,
&rpc.GetAccountInfoOpts{Commitment: rpc.CommitmentConfirmed},
)
require.NoError(r, err)
require.NotNil(r, receiverAtaAcc)

// verify balances are updated
receiverBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentFinalized)
receiverBalanceAfter, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, receiverAta, rpc.CommitmentConfirmed)
require.NoError(r, err)
r.Logger.Info("receiver balance of SPL after withdraw: %s", receiverBalanceAfter.Value.Amount)

Expand Down
2 changes: 2 additions & 0 deletions e2e/e2etests/test_whitelist_erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2etests
import (
"math/big"

sdkmath "cosmossdk.io/math"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcommon "github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -40,6 +41,7 @@ func TestWhitelistERC20(r *runner.E2ERunner, _ []string) {
"NEWERC20",
6,
100000,
sdkmath.NewUintFromString("100000000000000000000000000"),
))
require.NoError(r, err)

Expand Down
4 changes: 2 additions & 2 deletions e2e/runner/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, error) {
solSOLBalance, err := r.SolanaClient.GetBalance(
r.Ctx,
solanaAddr,
rpc.CommitmentFinalized,
rpc.CommitmentConfirmed,
)
if err != nil {
return AccountBalances{}, fmt.Errorf("get sol balance: %w", err)
Expand All @@ -119,7 +119,7 @@ func (r *E2ERunner) GetAccountBalances(skipBTC bool) (AccountBalances, error) {
solanaAddr,
r.SPLAddr,
)
splBalance, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, ata, rpc.CommitmentFinalized)
splBalance, err := r.SolanaClient.GetTokenAccountBalance(r.Ctx, ata, rpc.CommitmentConfirmed)
if err != nil {
return AccountBalances{}, fmt.Errorf("get spl balance: %w", err)
}
Expand Down
6 changes: 4 additions & 2 deletions e2e/runner/setup_solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *E2ERunner) SetupSolana(gatewayID, deployerPrivateKey string) {
// get deployer account balance
privkey, err := solana.PrivateKeyFromBase58(deployerPrivateKey)
require.NoError(r, err)
bal, err := r.SolanaClient.GetBalance(r.Ctx, privkey.PublicKey(), rpc.CommitmentFinalized)
bal, err := r.SolanaClient.GetBalance(r.Ctx, privkey.PublicKey(), rpc.CommitmentConfirmed)
require.NoError(r, err)
r.Logger.Info("deployer address: %s, balance: %f SOL", privkey.PublicKey().String(), float64(bal.Value)/1e9)

Expand Down Expand Up @@ -68,7 +68,9 @@ func (r *E2ERunner) SetupSolana(gatewayID, deployerPrivateKey string) {
r.Logger.Info("initialize logs: %v", out.Meta.LogMessages)

// retrieve the PDA account info
pdaInfo, err := r.SolanaClient.GetAccountInfo(r.Ctx, pdaComputed)
pdaInfo, err := r.SolanaClient.GetAccountInfoWithOpts(r.Ctx, pdaComputed, &rpc.GetAccountInfoOpts{
Commitment: rpc.CommitmentConfirmed,
})
require.NoError(r, err)

// deserialize the PDA info
Expand Down
Loading

0 comments on commit b1ad198

Please sign in to comment.