Skip to content

Commit 975c78e

Browse files
committed
Merge branch 'develop' into refactor/chain-params
# Conflicts: # zetaclient/chains/evm/observer/outbound_test.go # zetaclient/chains/evm/signer/outbound_data.go # zetaclient/chains/evm/signer/signer.go # zetaclient/config/types.go # zetaclient/orchestrator/bootstrap.go # zetaclient/orchestrator/orchestrator.go # zetaclient/orchestrator/orchestrator_test.go
2 parents c157e0d + 65ff18f commit 975c78e

File tree

79 files changed

+3748
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+3748
-538
lines changed

.github/workflows/build.yml

-8
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ on:
77
- release/*
88
merge_group:
99
pull_request:
10-
branches:
11-
- "*"
12-
types:
13-
- synchronize
14-
- opened
15-
- reopened
1610

1711
concurrency:
1812
group: pr-testing-${{ github.head_ref || github.run_id }}
@@ -28,8 +22,6 @@ jobs:
2822
build-and-test:
2923
runs-on: ubuntu-20.04
3024
timeout-minutes: 15
31-
concurrency:
32-
group: "build-and-test"
3325
steps:
3426
- uses: actions/checkout@v4
3527

.github/workflows/e2e.yml

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
- develop
77
- release/*
88
pull_request:
9-
branches:
10-
- "*"
119
merge_group:
1210
schedule:
1311
# run at 6AM UTC Daily

.github/workflows/sast-linters.yml

-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ on:
88
- "*"
99
merge_group:
1010
pull_request:
11-
types:
12-
- opened
13-
- synchronize
1411

1512
concurrency:
1613
group: linters-${{ github.head_ref || github.run_id }}

Dockerfile-localnet

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# syntax=docker/dockerfile:1.7-labs
2-
FROM golang:1.22.5-bookworm AS base-build
1+
# syntax=ghcr.io/zeta-chain/docker-dockerfile:1.7-labs
2+
FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm AS base-build
33

44
ENV GOPATH /go
55
ENV GOOS=linux
@@ -22,10 +22,10 @@ COPY --exclude=*.sh --exclude=*.md --exclude=*.yml . .
2222
RUN --mount=type=cache,target="/root/.cache/go-build" make install
2323
RUN --mount=type=cache,target="/root/.cache/go-build" make install-zetae2e
2424

25-
FROM golang:1.22.5-bookworm AS cosmovisor-build
25+
FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm AS cosmovisor-build
2626
RUN go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]
2727

28-
FROM golang:1.22.5-bookworm AS base-runtime
28+
FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm AS base-runtime
2929

3030
RUN apt update && \
3131
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 bind9-host && \

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ start-e2e-admin-test: zetanode
249249
start-e2e-performance-test: zetanode
250250
@echo "--> Starting e2e performance test"
251251
export E2E_ARGS="--test-performance" && \
252-
cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d
252+
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress -f docker-compose.yml up -d
253253

254254
start-e2e-import-mainnet-test: zetanode
255255
@echo "--> Starting e2e import-data test"

changelog.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Breaking Changes
1212

1313
* [2460](https://github.com/zeta-chain/node/pull/2460) - Upgrade to go 1.22. This required us to temporarily remove the QUIC backend from [go-libp2p](https://github.com/libp2p/go-libp2p). If you are a zetaclient operator and have configured quic peers, you need to switch to tcp peers.
14+
* [List of the other breaking changes can be found in this document](docs/releases/v19_breaking_changes.md)
1415

1516
### Features
1617

@@ -42,6 +43,9 @@
4243
* [2518](https://github.com/zeta-chain/node/pull/2518) - add support for Solana address in zetacore
4344
* [2483](https://github.com/zeta-chain/node/pull/2483) - add priorityFee (gasTipCap) gas to the state
4445
* [2567](https://github.com/zeta-chain/node/pull/2567) - add sign latency metric to zetaclient (zetaclient_sign_latency)
46+
* [2524](https://github.com/zeta-chain/node/pull/2524) - add inscription envelop parsing
47+
* [2560](https://github.com/zeta-chain/node/pull/2560) - add support for Solana SOL token withdraw
48+
* [2533](https://github.com/zeta-chain/node/pull/2533) - parse memo from both OP_RETURN and inscription
4549

4650
### Refactor
4751

@@ -589,4 +593,4 @@ Getting the correct TSS address for Bitcoin now requires proviidng the Bitcoin c
589593
### CI
590594

591595
* [1218](https://github.com/zeta-chain/node/pull/1218) - cross-compile release binaries and simplify PR testings
592-
* [1302](https://github.com/zeta-chain/node/pull/1302) - add mainnet builds to goreleaser
596+
* [1302](https://github.com/zeta-chain/node/pull/1302) - add mainnet builds to goreleaser

cmd/zetaclientd/init.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"path"
5+
46
"github.com/rs/zerolog"
57
"github.com/spf13/cobra"
68

@@ -36,6 +38,7 @@ type initArguments struct {
3638
KeyringBackend string
3739
HsmMode bool
3840
HsmHotKey string
41+
SolanaKey string
3942
}
4043

4144
func init() {
@@ -69,6 +72,7 @@ func init() {
6972
InitCmd.Flags().BoolVar(&initArgs.HsmMode, "hsm-mode", false, "enable hsm signer, default disabled")
7073
InitCmd.Flags().
7174
StringVar(&initArgs.HsmHotKey, "hsm-hotkey", "hsm-hotkey", "name of hotkey associated with hardware security module")
75+
InitCmd.Flags().StringVar(&initArgs.SolanaKey, "solana-key", "solana-key.json", "solana key file name")
7276
}
7377

7478
func Initialize(_ *cobra.Command, _ []string) error {
@@ -106,8 +110,16 @@ func Initialize(_ *cobra.Command, _ []string) error {
106110
configData.KeyringBackend = config.KeyringBackend(initArgs.KeyringBackend)
107111
configData.HsmMode = initArgs.HsmMode
108112
configData.HsmHotKey = initArgs.HsmHotKey
113+
configData.SolanaKeyFile = initArgs.SolanaKey
109114
configData.ComplianceConfig = testutils.ComplianceConfigTest()
110115

111-
//Save config file
116+
// Save solana test fee payer key file
117+
keyFile := path.Join(rootArgs.zetaCoreHome, initArgs.SolanaKey)
118+
err = createSolanaTestKeyFile(keyFile)
119+
if err != nil {
120+
return err
121+
}
122+
123+
// Save config file
112124
return config.Save(&configData, rootArgs.zetaCoreHome)
113125
}

cmd/zetaclientd/solana_test_key.go

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"os"
6+
)
7+
8+
// solanaTestKey is a local test private key for Solana
9+
// TODO: use separate keys for each zetaclient in Solana E2E tests
10+
// https://github.com/zeta-chain/node/issues/2614
11+
var solanaTestKey = []uint8{
12+
199, 16, 63, 28, 125, 103, 131, 13, 6, 94, 68, 109, 13, 68, 132, 17,
13+
71, 33, 216, 51, 49, 103, 146, 241, 245, 162, 90, 228, 71, 177, 32, 199,
14+
31, 128, 124, 2, 23, 207, 48, 93, 141, 113, 91, 29, 196, 95, 24, 137,
15+
170, 194, 90, 4, 124, 113, 12, 222, 166, 209, 119, 19, 78, 20, 99, 5,
16+
}
17+
18+
// createSolanaTestKeyFile creates a solana test key json file
19+
func createSolanaTestKeyFile(keyFile string) error {
20+
// marshal the byte array to JSON
21+
keyBytes, err := json.Marshal(solanaTestKey)
22+
if err != nil {
23+
return err
24+
}
25+
26+
// create file (or overwrite if it already exists)
27+
// #nosec G304 -- for E2E testing purposes only
28+
file, err := os.Create(keyFile)
29+
if err != nil {
30+
return err
31+
}
32+
defer file.Close()
33+
34+
// write the key bytes to the file
35+
_, err = file.Write(keyBytes)
36+
return err
37+
}

cmd/zetaclientd/utils.go

-2
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,3 @@ func CreateZetacoreClient(cfg config.Config, hotkeyPassword string, logger zerol
4141

4242
return client, nil
4343
}
44-
45-
// TODO

cmd/zetae2e/local/local.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,11 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
318318
logger.Print("❌ solana client is nil, maybe solana rpc is not set")
319319
os.Exit(1)
320320
}
321-
eg.Go(solanaTestRoutine(conf, deployerRunner, verbose, e2etests.TestSolanaDepositName))
321+
solanaTests := []string{
322+
e2etests.TestSolanaDepositName,
323+
e2etests.TestSolanaWithdrawName,
324+
}
325+
eg.Go(solanaTestRoutine(conf, deployerRunner, verbose, solanaTests...))
322326
}
323327

324328
// while tests are executed, monitor blocks in parallel to check if system txs are on top and they have biggest priority

cmd/zetae2e/local/performance.go

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ func ethereumWithdrawPerformanceRoutine(
7575
return err
7676
}
7777

78+
if r.ReceiptTimeout == 0 {
79+
r.ReceiptTimeout = 15 * time.Minute
80+
}
81+
if r.CctxTimeout == 0 {
82+
r.CctxTimeout = 15 * time.Minute
83+
}
84+
7885
r.Logger.Print("🏃 starting Ethereum withdraw performance tests")
7986
startTime := time.Now()
8087

cmd/zetae2e/local/test_runner.go

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func initTestRunner(
3030
return nil, err
3131
}
3232

33+
// copy timeouts from deployer runner
34+
testRunner.CctxTimeout = deployerRunner.ReceiptTimeout
35+
testRunner.ReceiptTimeout = deployerRunner.ReceiptTimeout
36+
3337
// copy contracts from deployer runner
3438
if err := testRunner.CopyAddressesFrom(deployerRunner); err != nil {
3539
return nil, err

contrib/localnet/docker-compose.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
# - An orchestrator to manage interaction with the localnet (orchestrator)
1010
# - An upgrade host to serve binaries for the upgrade tests (upgrade-host). Only enabled when profile is set to upgrade.
1111
# - An upgrade orchestrator to send the upgrade governance proposal (upgrade-orchestrator). Only enabled when profile is set to upgrade.
12+
#
13+
# If you are using third party images in CI, you should copy them into ghcr via https://github.com/zeta-chain/copy-docker-images
1214

1315
networks:
1416
mynetwork:
@@ -181,7 +183,7 @@ services:
181183
- preparams:/root/preparams
182184

183185
eth:
184-
image: ethereum/client-go:v1.10.26
186+
image: ghcr.io/zeta-chain/ethereum-client-go:v1.10.26
185187
container_name: eth
186188
hostname: eth
187189
ports:
@@ -207,7 +209,7 @@ services:
207209
ipv4_address: 172.20.0.102
208210

209211
bitcoin:
210-
image: ruimarinho/bitcoin-core:22 # version 23 is not working with btcd 0.22.0 due to change in createwallet rpc
212+
image: ghcr.io/zeta-chain/ruimarinho-bitcoin-core:22 # version 23 is not working with btcd 0.22.0 due to change in createwallet rpc
211213
container_name: bitcoin
212214
hostname: bitcoin
213215
networks:

contrib/localnet/orchestrator/Dockerfile.fastbuild

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM zetanode:latest as zeta
2-
FROM ethereum/client-go:v1.10.26 as geth
3-
FROM golang:1.20.14-bookworm as orchestrator
2+
FROM ghcr.io/zeta-chain/ethereum-client-go:v1.10.26 as geth
3+
FROM ghcr.io/zeta-chain/golang:1.22.5-bookworm as orchestrator
44

55
RUN apt update && \
66
apt install -yq jq yq curl tmux python3 openssh-server iputils-ping iproute2 && \

contrib/localnet/orchestrator/start-zetae2e.sh

+5
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ address=$(yq -r '.additional_accounts.user_bitcoin.evm_address' config.yml)
6666
echo "funding bitcoin tester address ${address} with 10000 Ether"
6767
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545
6868

69+
# unlock solana tester accounts
70+
address=$(yq -r '.additional_accounts.user_solana.evm_address' config.yml)
71+
echo "funding solana tester address ${address} with 10000 Ether"
72+
geth --exec "eth.sendTransaction({from: eth.coinbase, to: '${address}', value: web3.toWei(10000,'ether')})" attach http://eth:8545
73+
6974
# unlock ethers tester accounts
7075
address=$(yq -r '.additional_accounts.user_ether.evm_address' config.yml)
7176
echo "funding ether tester address ${address} with 10000 Ether"

contrib/localnet/scripts/start-zetacored.sh

+3
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ then
247247
# bitcoin tester
248248
address=$(yq -r '.additional_accounts.user_bitcoin.bech32_address' /root/config.yml)
249249
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
250+
# solana tester
251+
address=$(yq -r '.additional_accounts.user_solana.bech32_address' /root/config.yml)
252+
zetacored add-genesis-account "$address" 100000000000000000000000000azeta
250253
# ethers tester
251254
address=$(yq -r '.additional_accounts.user_ether.bech32_address' /root/config.yml)
252255
zetacored add-genesis-account "$address" 100000000000000000000000000azeta

docs/cli/zetacored/zetacored_tx_fungible_update-gateway-contract.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Broadcast message UpdateGatewayContract to update the gateway contract address
44

55
```
6-
zetacored tx fungible update-gateway-contract [contract-address] [flags]
6+
zetacored tx fungible update-gateway-contract [contract-address] [flags]
77
```
88

99
### Options

e2e/e2etests/e2etests.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ const (
5454
/*
5555
Solana tests
5656
*/
57-
TestSolanaDepositName = "solana_deposit"
57+
TestSolanaDepositName = "solana_deposit"
58+
TestSolanaWithdrawName = "solana_withdraw"
5859

5960
/*
6061
Bitcoin tests
@@ -338,10 +339,18 @@ var AllE2ETests = []runner.E2ETest{
338339
TestSolanaDepositName,
339340
"deposit SOL into ZEVM",
340341
[]runner.ArgDefinition{
341-
{Description: "amount in SOL", DefaultValue: "0.1"},
342+
{Description: "amount in lamport", DefaultValue: "13370000"},
342343
},
343344
TestSolanaDeposit,
344345
),
346+
runner.NewE2ETest(
347+
TestSolanaWithdrawName,
348+
"withdraw SOL from ZEVM",
349+
[]runner.ArgDefinition{
350+
{Description: "amount in lamport", DefaultValue: "1336000"},
351+
},
352+
TestSolanaWithdraw,
353+
),
345354
/*
346355
Bitcoin tests
347356
*/

e2e/e2etests/test_solana_deposit.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
package e2etests
22

33
import (
4+
"math/big"
5+
46
"github.com/gagliardetto/solana-go"
7+
"github.com/stretchr/testify/require"
58

69
"github.com/zeta-chain/zetacore/e2e/runner"
710
"github.com/zeta-chain/zetacore/e2e/utils"
811
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
912
)
1013

11-
func TestSolanaDeposit(r *runner.E2ERunner, _ []string) {
14+
func TestSolanaDeposit(r *runner.E2ERunner, args []string) {
15+
require.Len(r, args, 1)
16+
17+
// parse deposit amount (in lamports)
18+
// #nosec G115 e2e - always in range
19+
depositAmount := big.NewInt(int64(parseInt(r, args[0])))
20+
1221
// load deployer private key
13-
privkey := solana.MustPrivateKeyFromBase58(r.Account.SolanaPrivateKey.String())
22+
privkey, err := solana.PrivateKeyFromBase58(r.Account.SolanaPrivateKey.String())
23+
require.NoError(r, err)
1424

1525
// create 'deposit' instruction
16-
amount := uint64(13370000)
17-
instruction := r.CreateDepositInstruction(privkey.PublicKey(), r.EVMAddress(), amount)
26+
instruction := r.CreateDepositInstruction(privkey.PublicKey(), r.EVMAddress(), depositAmount.Uint64())
1827

1928
// create and sign the transaction
2029
signedTx := r.CreateSignedTransaction([]solana.Instruction{instruction}, privkey)

e2e/e2etests/test_solana_withdraw.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package e2etests
2+
3+
import (
4+
"math/big"
5+
6+
"github.com/ethereum/go-ethereum/accounts/abi/bind"
7+
"github.com/gagliardetto/solana-go"
8+
"github.com/stretchr/testify/require"
9+
10+
"github.com/zeta-chain/zetacore/e2e/runner"
11+
)
12+
13+
func TestSolanaWithdraw(r *runner.E2ERunner, args []string) {
14+
require.Len(r, args, 1)
15+
16+
// print balanceAfter of from address
17+
balanceBefore, err := r.SOLZRC20.BalanceOf(&bind.CallOpts{}, r.ZEVMAuth.From)
18+
require.NoError(r, err)
19+
r.Logger.Info("from address %s balance of SOL before: %d", r.ZEVMAuth.From, balanceBefore)
20+
21+
// parse withdraw amount (in lamports), approve amount is 1 SOL
22+
approvedAmount := new(big.Int).SetUint64(solana.LAMPORTS_PER_SOL)
23+
// #nosec G115 e2e - always in range
24+
withdrawAmount := big.NewInt(int64(parseInt(r, args[0])))
25+
require.Equal(
26+
r,
27+
-1,
28+
withdrawAmount.Cmp(approvedAmount),
29+
"Withdrawal amount must be less than the approved amount (1e9).",
30+
)
31+
32+
// load deployer private key
33+
privkey, err := solana.PrivateKeyFromBase58(r.Account.SolanaPrivateKey.String())
34+
require.NoError(r, err)
35+
36+
// withdraw
37+
r.WithdrawSOLZRC20(privkey.PublicKey(), withdrawAmount, approvedAmount)
38+
39+
// print balance of from address after withdraw
40+
balanceAfter, err := r.SOLZRC20.BalanceOf(&bind.CallOpts{}, r.ZEVMAuth.From)
41+
require.NoError(r, err)
42+
r.Logger.Info("from address %s balance of SOL after: %d", r.ZEVMAuth.From, balanceAfter)
43+
44+
// check if the balance is reduced correctly
45+
amountReduced := new(big.Int).Sub(balanceBefore, balanceAfter)
46+
require.True(r, amountReduced.Cmp(withdrawAmount) >= 0, "balance is not reduced correctly")
47+
}

0 commit comments

Comments
 (0)