Skip to content

Commit

Permalink
rebase develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Aug 19, 2024
2 parents a35599c + 53883f5 commit 0ec7f71
Show file tree
Hide file tree
Showing 214 changed files with 9,344 additions and 2,824 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ on:
type: boolean
required: false
default: false
v2-test:
type: boolean
required: false
default: false

concurrency:
group: e2e-${{ github.head_ref || github.sha }}
Expand All @@ -69,6 +73,7 @@ jobs:
STATEFUL_DATA_TESTS: ${{ steps.matrix-conditionals.outputs.STATEFUL_DATA_TESTS }}
TSS_MIGRATION_TESTS: ${{ steps.matrix-conditionals.outputs.TSS_MIGRATION_TESTS }}
SOLANA_TESTS: ${{ steps.matrix-conditionals.outputs.SOLANA_TESTS }}
V2_TESTS: ${{ steps.matrix-conditionals.outputs.V2_TESTS }}
steps:
# use api rather than event context to avoid race conditions (label added after push)
- id: matrix-conditionals
Expand All @@ -92,6 +97,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', labels.includes('STATEFUL_DATA_TESTS'));
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('SOLANA_TESTS', labels.includes('SOLANA_TESTS'));
core.setOutput('V2_TESTS', labels.includes('V2_TESTS')); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'merge_group') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_LIGHT_TESTS', true);
Expand All @@ -105,6 +111,7 @@ jobs:
core.setOutput('ADMIN_TESTS', true);
core.setOutput('PERFORMANCE_TESTS', true);
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'schedule') {
core.setOutput('DEFAULT_TESTS', true);
core.setOutput('UPGRADE_TESTS', true);
Expand All @@ -115,6 +122,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('TSS_MIGRATION_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
core.setOutput('V2_TESTS', true); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
} else if (context.eventName === 'workflow_dispatch') {
core.setOutput('DEFAULT_TESTS', context.payload.inputs['default-test']);
core.setOutput('UPGRADE_TESTS', context.payload.inputs['upgrade-test']);
Expand All @@ -125,6 +133,7 @@ jobs:
core.setOutput('STATEFUL_DATA_TESTS', context.payload.inputs['stateful-data-test']);
core.setOutput('TSS_MIGRATION_TESTS', context.payload.inputs['tss-migration-test']);
core.setOutput('SOLANA_TESTS', context.payload.inputs['solana-test']);
core.setOutput('V2_TESTS', context.payload.inputs['v2-test']); // for v2 tests, TODO: remove this once we fully migrate to v2 (https://github.com/zeta-chain/node/issues/2627)
}
e2e:
Expand Down Expand Up @@ -162,6 +171,9 @@ jobs:
- make-target: "start-solana-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.SOLANA_TESTS == 'true' }}
- make-target: "start-v2-test"
runs-on: ubuntu-20.04
run: ${{ needs.matrix-conditionals.outputs.V2_TESTS == 'true' }}
name: ${{ matrix.make-target }}
uses: ./.github/workflows/reusable-e2e.yml
with:
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
echo "${{ github.ref }}"
check-goreleaser:
needs:
- check-branch
runs-on: ubuntu-22.04
if: ${{ github.event.inputs.skip_checks != 'true' }}
runs-on: ${{ vars.RELEASE_RUNNER }}
steps:
- name: Branch
- uses: actions/checkout@v4
- name: Release build dry-run
run: |
make release-dry-run
Expand Down Expand Up @@ -124,7 +124,8 @@ jobs:
- check-changelog
- check-upgrade-handler-updated
- check-branch
runs-on: ubuntu-22.04
- check-goreleaser
runs-on: ${{ vars.RELEASE_RUNNER }}
timeout-minutes: 60
environment: release
steps:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ start-solana-test: zetanode solana
export E2E_ARGS="--skip-regular --test-solana" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana -f docker-compose.yml up -d

start-v2-test: zetanode
@echo "--> Starting e2e smart contracts v2 test"
export E2E_ARGS="--skip-regular --test-v2" && \
cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d

###############################################################################
### Upgrade Tests ###
###############################################################################
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [2578](https://github.com/zeta-chain/node/pull/2578) - add Gateway address in protocol contract list
* [2630](https://github.com/zeta-chain/node/pull/2630) - implement `MsgMigrateERC20CustodyFunds` to migrate the funds from the ERC20Custody to a new contracts (to be used for the new ERC20Custody contract for smart contract V2)
* [2578](https://github.com/zeta-chain/node/pull/2578) - Add Gateway address in protocol contract list
* [2594](https://github.com/zeta-chain/node/pull/2594) - Integrate Protocol Contracts V2 in the protocol
* [2634](https://github.com/zeta-chain/node/pull/2634) - add support for EIP-1559 gas fees
* [2597](https://github.com/zeta-chain/node/pull/2597) - Add generic rpc metrics to zetaclient
* [2538](https://github.com/zeta-chain/node/pull/2538) - add background worker routines to shutdown zetaclientd when needed for tss migration
Expand All @@ -19,9 +20,14 @@
* [2615](https://github.com/zeta-chain/node/pull/2615) - Refactor cleanup of outbound trackers
* [2725](https://github.com/zeta-chain/node/pull/2725) - refactor SetCctxAndNonceToCctxAndInboundHashToCctx receive tsspubkey as an argument

### Tests

* [2726](https://github.com/zeta-chain/node/pull/2726) - add e2e tests for deposit and call, deposit and revert

### Fixes

* [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module
* [2672](https://github.com/zeta-chain/node/pull/2672) - check observer set for duplicates when adding a new observer or updating an existing one

## v19.0.0

Expand Down
8 changes: 8 additions & 0 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,13 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.ZEVM.ContextAppAddr = config.DoubleQuotedString(r.ContextAppAddr.Hex())
conf.Contracts.ZEVM.TestDappAddr = config.DoubleQuotedString(r.ZevmTestDAppAddr.Hex())

// v2
conf.Contracts.EVM.Gateway = config.DoubleQuotedString(r.GatewayEVMAddr.Hex())
conf.Contracts.EVM.ERC20CustodyNew = config.DoubleQuotedString(r.ERC20CustodyV2Addr.Hex())
conf.Contracts.EVM.TestDAppV2Addr = config.DoubleQuotedString(r.TestDAppV2EVMAddr.Hex())

conf.Contracts.ZEVM.Gateway = config.DoubleQuotedString(r.GatewayZEVMAddr.Hex())
conf.Contracts.ZEVM.TestDAppV2Addr = config.DoubleQuotedString(r.TestDAppV2ZEVMAddr.Hex())

return conf
}
79 changes: 70 additions & 9 deletions cmd/zetae2e/config/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@ import (
"fmt"

"github.com/gagliardetto/solana-go"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol"
zetaeth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zeta.eth.sol"
zetaconnectoreth "github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.eth.sol"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/wzeta.sol"
connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zetaconnectorzevm.sol"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol"
"github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol"
uniswapv2router "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol"
"github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/evm/erc20custody.sol"
zetaeth "github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/evm/zeta.eth.sol"
zetaconnectoreth "github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/evm/zetaconnector.eth.sol"
"github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/zevm/systemcontract.sol"
"github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/zevm/wzeta.sol"
connectorzevm "github.com/zeta-chain/protocol-contracts/v1/pkg/contracts/zevm/zetaconnectorzevm.sol"
"github.com/zeta-chain/protocol-contracts/v1/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol"
uniswapv2router "github.com/zeta-chain/protocol-contracts/v1/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.sol"
erc20custodyv2 "github.com/zeta-chain/protocol-contracts/v2/pkg/erc20custody.sol"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayevm.sol"
"github.com/zeta-chain/protocol-contracts/v2/pkg/gatewayzevm.sol"
"github.com/zeta-chain/protocol-contracts/v2/pkg/zrc20.sol"

"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/contracts/contextapp"
"github.com/zeta-chain/zetacore/e2e/contracts/erc20"
"github.com/zeta-chain/zetacore/e2e/contracts/zevmswap"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/pkg/contracts/testdappv2"
)

// setContractsFromConfig get EVM contracts from config
Expand Down Expand Up @@ -211,5 +215,62 @@ func setContractsFromConfig(r *runner.E2ERunner, conf config.Config) error {
}
}

// v2 contracts

if c := conf.Contracts.EVM.Gateway; c != "" {
r.GatewayEVMAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid GatewayAddr: %w", err)
}
r.GatewayEVM, err = gatewayevm.NewGatewayEVM(r.GatewayEVMAddr, r.EVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.EVM.ERC20CustodyNew; c != "" {
r.ERC20CustodyV2Addr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid ERC20CustodyV2Addr: %w", err)
}
r.ERC20CustodyV2, err = erc20custodyv2.NewERC20Custody(r.ERC20CustodyV2Addr, r.EVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.EVM.TestDAppV2Addr; c != "" {
r.TestDAppV2EVMAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid TestDAppV2Addr: %w", err)
}
r.TestDAppV2EVM, err = testdappv2.NewTestDAppV2(r.TestDAppV2EVMAddr, r.EVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.Gateway; c != "" {
r.GatewayZEVMAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid GatewayAddr: %w", err)
}
r.GatewayZEVM, err = gatewayzevm.NewGatewayZEVM(r.GatewayZEVMAddr, r.ZEVMClient)
if err != nil {
return err
}
}

if c := conf.Contracts.ZEVM.TestDAppV2Addr; c != "" {
r.TestDAppV2ZEVMAddr, err = c.AsEVMAddress()
if err != nil {
return fmt.Errorf("invalid TestDAppV2Addr: %w", err)
}
r.TestDAppV2ZEVM, err = testdappv2.NewTestDAppV2(r.TestDAppV2ZEVMAddr, r.EVMClient)
if err != nil {
return err
}
}

return nil
}
4 changes: 3 additions & 1 deletion cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ contracts:
connector_zevm: "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67"
wzeta: "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf"
test_dapp: "0xA8D5060feb6B456e886F023709A2795373691E63"
gateway: "0xa825eAa55b497AF892faca73a3797046C10B7c23"
evm:
zeta_eth: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9"
connector_eth: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"
custody: "0xff3135df4F2775f4091b81f4c7B6359CfA07862a"
erc20: "0xbD1e64A22B9F92D9Ce81aA9B4b0fFacd80215564"
test_dapp: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed"
test_dapp: "0xBFF76e77D56B3C1202107f059425D56f0AEF87Ed"
gateway: "0xF0deebCB0E9C829519C4baa794c5445171973826"
82 changes: 80 additions & 2 deletions cmd/zetae2e/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
flagTestTSSMigration = "test-tss-migration"
flagSkipBitcoinSetup = "skip-bitcoin-setup"
flagSkipHeaderProof = "skip-header-proof"
flagTestV2 = "test-v2"
flagSkipTrackerCheck = "skip-tracker-check"
)

Expand Down Expand Up @@ -74,6 +75,7 @@ func NewLocalCmd() *cobra.Command {
cmd.Flags().Bool(flagSkipBitcoinSetup, false, "set to true to skip bitcoin wallet setup")
cmd.Flags().Bool(flagSkipHeaderProof, false, "set to true to skip header proof tests")
cmd.Flags().Bool(flagTestTSSMigration, false, "set to true to include a migration test at the end")
cmd.Flags().Bool(flagTestV2, false, "set to true to run tests for v2 contracts")
cmd.Flags().Bool(flagSkipTrackerCheck, false, "set to true to skip tracker check at the end of the tests")

return cmd
Expand All @@ -98,6 +100,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof))
skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck))
testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration))
testV2 = must(cmd.Flags().GetBool(flagTestV2))
)

logger := runner.NewLogger(verbose, color.FgWhite, "setup")
Expand Down Expand Up @@ -185,13 +188,26 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
startTime := time.Now()

deployerRunner.SetupEVM(contractsDeployed, true)
deployerRunner.SetZEVMContracts()

if testV2 {
deployerRunner.SetupEVMV2()
}

deployerRunner.SetZEVMSystemContracts()

if testV2 {
// NOTE: v2 (gateway) setup called here because system contract needs to be set first, then gateway, then zrc20
deployerRunner.SetZEVMContractsV2()
}

deployerRunner.SetZEVMZRC20s()

if testSolana {
deployerRunner.SetSolanaContracts(conf.AdditionalAccounts.UserSolana.SolanaPrivateKey.String())
}
noError(deployerRunner.FundEmissionsPool())

deployerRunner.MintERC20OnEvm(10000)
deployerRunner.MintERC20OnEvm(1000000)

logger.Print("✅ setup completed in %s", time.Since(startTime))
}
Expand Down Expand Up @@ -332,9 +348,71 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
solanaTests := []string{
e2etests.TestSolanaDepositName,
e2etests.TestSolanaWithdrawName,
e2etests.TestSolanaDepositAndCallName,
e2etests.TestSolanaDepositAndCallRefundName,
}
eg.Go(solanaTestRoutine(conf, deployerRunner, verbose, solanaTests...))
}
if testV2 {
// update the ERC20 custody contract for v2 tests
deployerRunner.UpdateChainParamsERC20CustodyContract()

//// Test happy paths for gas token workflow
eg.Go(v2TestRoutine(conf, "eth", conf.AdditionalAccounts.UserEther, color.FgHiGreen, deployerRunner, verbose,
e2etests.TestV2ETHDepositName,
e2etests.TestV2ETHDepositAndCallName,
e2etests.TestV2ETHWithdrawName,
e2etests.TestV2ETHWithdrawAndCallName,
e2etests.TestV2ZEVMToEVMCallName,
e2etests.TestV2EVMToZEVMCallName,
))

//// Test happy paths for erc20 token workflow
eg.Go(v2TestRoutine(conf, "erc20", conf.AdditionalAccounts.UserERC20, color.FgHiBlue, deployerRunner, verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestV2ERC20DepositName,
e2etests.TestV2ERC20DepositAndCallName,
e2etests.TestV2ERC20WithdrawName,
e2etests.TestV2ERC20WithdrawAndCallName,
))

// Test revert cases for gas token workflow
eg.Go(
v2TestRoutine(
conf,
"eth-revert",
conf.AdditionalAccounts.UserZetaTest,
color.FgHiYellow,
deployerRunner,
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM and withdraw
e2etests.TestV2ETHDepositAndCallRevertName,
e2etests.TestV2ETHDepositAndCallRevertWithCallName,
e2etests.TestV2ETHWithdrawAndCallRevertName,
e2etests.TestV2ETHWithdrawAndCallRevertWithCallName,
),
)

// Test revert cases for erc20 token workflow
eg.Go(
v2TestRoutine(
conf,
"erc20-revert",
conf.AdditionalAccounts.UserBitcoin,
color.FgHiRed,
deployerRunner,
verbose,
e2etests.TestV2ETHDepositName, // necessary to pay fees on ZEVM
e2etests.TestV2ERC20DepositName, // necessary to have assets to withdraw
e2etests.TestOperationAddLiquidityETHName, // liquidity with gas and ERC20 are necessary for reverts
e2etests.TestOperationAddLiquidityERC20Name,
e2etests.TestV2ERC20DepositAndCallRevertName,
e2etests.TestV2ERC20DepositAndCallRevertWithCallName,
e2etests.TestV2ERC20WithdrawAndCallRevertName,
e2etests.TestV2ERC20WithdrawAndCallRevertWithCallName,
),
)
}

// while tests are executed, monitor blocks in parallel to check if system txs are on top and they have biggest priority
txPriorityErrCh := make(chan error, 1)
Expand Down
Loading

0 comments on commit 0ec7f71

Please sign in to comment.