Skip to content

Commit

Permalink
rebase develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jun 4, 2024
2 parents 76cea0c + 26b4f69 commit c23b282
Show file tree
Hide file tree
Showing 225 changed files with 633 additions and 381 deletions.
3 changes: 1 addition & 2 deletions app/ante/vesting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ func TestVesting_AnteHandle(t *testing.T) {
_, err = decorator.AnteHandle(ctx, tx, false, mmd.AnteHandle)

if tt.wantHasErr {
require.Error(t, err)
require.Contains(t, err.Error(), tt.wantErr)
require.ErrorContains(t, err, tt.wantErr)
} else {
require.NoError(t, err)
}
Expand Down
9 changes: 9 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import (

"github.com/zeta-chain/zetacore/app/ante"
"github.com/zeta-chain/zetacore/docs/openapi"
"github.com/zeta-chain/zetacore/pkg/chains"
zetamempool "github.com/zeta-chain/zetacore/pkg/mempool"
srvflags "github.com/zeta-chain/zetacore/server/flags"
authoritymodule "github.com/zeta-chain/zetacore/x/authority"
Expand Down Expand Up @@ -597,6 +598,14 @@ func New(
app.LightclientKeeper,
)

// initializing map of cctx gateways so crosschain module can decide which one to use
// based on chain info of destination chain
cctxGateways := map[chains.CCTXGateway]crosschainkeeper.CCTXGateway{
chains.CCTXGateway_observers: crosschainkeeper.NewCCTXGatewayObservers(app.CrosschainKeeper),
chains.CCTXGateway_zevm: crosschainkeeper.NewCCTXGatewayZEVM(app.CrosschainKeeper),
}
app.CrosschainKeeper.SetCCTXGateways(cctxGateways)

// initialize ibccrosschain keeper and set it to the crosschain keeper
// there is a circular dependency between the two keepers, crosschain keeper must be initialized first

Expand Down
12 changes: 11 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
* [2287](https://github.com/zeta-chain/node/pull/2287) - implement `MsgUpdateChainInfo` message
* [2279](https://github.com/zeta-chain/node/pull/2279) - add a CCTXGateway field to chain static data
* [2275](https://github.com/zeta-chain/node/pull/2275) - add ChainInfo singleton state variable in authority
* [2291](https://github.com/zeta-chain/node/pull/2291) - initialize cctx gateway interface
* [2289](https://github.com/zeta-chain/node/pull/2289) - add an authorization list to keep track of all authorizations on the chain
* [2305](https://github.com/zeta-chain/node/pull/2305) - add `MsgAddAuthorization` and `MsgRemoveAuthorization` whcih can be used to update the authorization list
* [2305](https://github.com/zeta-chain/node/pull/2305) - add new messages `MsgAddAuthorization` and `MsgRemoveAuthorization` that can be used to update the authorization list

### Refactor

Expand All @@ -39,6 +40,7 @@
* [2262](https://github.com/zeta-chain/node/pull/2262) - refactor MsgUpdateZRC20 into MsgPauseZrc20 and MsgUnPauseZRC20
* [2290](https://github.com/zeta-chain/node/pull/2290) - rename `MsgAddBlameVote` message to `MsgVoteBlame`
* [2269](https://github.com/zeta-chain/node/pull/2269) - refactor MsgUpdateCrosschainFlags into MsgEnableCCTX, MsgDisableCCTX and MsgUpdateGasPriceIncreaseFlags
* [2296](https://github.com/zeta-chain/node/pull/2296) - move `testdata` package to `testutil` to organize test-related utilities

### Tests

Expand All @@ -48,6 +50,7 @@
* [2199](https://github.com/zeta-chain/node/pull/2199) - custom priority mempool unit tests
* [2240](https://github.com/zeta-chain/node/pull/2240) - removed hard-coded Bitcoin regnet chainID in E2E withdraw tests
* [2266](https://github.com/zeta-chain/node/pull/2266) - try fixing E2E test `crosschain_swap` failure `btc transaction not signed`
* [2299](https://github.com/zeta-chain/node/pull/2299) - add `zetae2e` command to deploy test contracts

### Fixes

Expand All @@ -68,6 +71,13 @@
* [2191](https://github.com/zeta-chain/node/pull/2191) - Fixed conditional logic for the docker build step for non release builds to not overwrite the github tag.
* [2192](https://github.com/zeta-chain/node/pull/2192) - Added release status checker and updater pipeline that will update release statuses when they go live on network.

## v17.0.0

### Fixes

* [2249](https://github.com/zeta-chain/node/pull/2249) - fix inbound and outbound validation for BSC chain
* [2265](https://github.com/zeta-chain/node/pull/2265) - fix rate limiter query for revert cctxs

## v16.0.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-upgrade-orchestrator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ done

# copy zetacore0 config and keys if not running on zetacore0
if [[ $(hostname) != "zetacore0" ]]; then
scp -r zetacore0:"~/.zetacored/config ~/.zetacored/os_info ~/.zetacored/config ~/.zetacored/keyring-file ~/.zetacored/keyring-test" ~/.zetacored/
scp -r 'zetacore0:~/.zetacored/config' 'zetacore0:~/.zetacored/os_info' 'zetacore0:~/.zetacored/config' 'zetacore0:~/.zetacored/keyring-file' 'zetacore0:~/.zetacored/keyring-test' ~/.zetacored/
sed -i 's|tcp://localhost:26657|tcp://zetacore0:26657|g' ~/.zetacored/config/client.toml
fi

Expand Down
2 changes: 0 additions & 2 deletions docs/cli/zetacored/zetacored_query_authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ zetacored query authority [flags]
### SEE ALSO

* [zetacored query](zetacored_query.md) - Querying subcommands
* [zetacored query authority list-authorizations](zetacored_query_authority_list-authorizations.md) - lists all authorizations
* [zetacored query authority show-authorization](zetacored_query_authority_show-authorization.md) - shows the authorization for a given message URL
* [zetacored query authority show-chain-info](zetacored_query_authority_show-chain-info.md) - show the chain info
* [zetacored query authority show-policies](zetacored_query_authority_show-policies.md) - show the policies

This file was deleted.

34 changes: 0 additions & 34 deletions docs/cli/zetacored/zetacored_query_authority_show-authorization.md

This file was deleted.

4 changes: 2 additions & 2 deletions docs/cli/zetacored/zetacored_tx_authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ zetacored tx authority [flags]
### SEE ALSO

* [zetacored tx](zetacored_tx.md) - Transactions subcommands
* [zetacored tx authority add-authorization](zetacored_tx_authority_add-authorization.md) - add a new authorization or update the policy of an existing authorization.Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin
* [zetacored tx authority add-authorization](zetacored_tx_authority_add-authorization.md) - Add a new authorization or update the policy of an existing authorization. Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin.
* [zetacored tx authority remove-authorization](zetacored_tx_authority_remove-authorization.md) - removes an existing authorization
* [zetacored tx authority update-chain-info](zetacored_tx_authority_update-chain-info.md) - Update the chain info
* [zetacored tx authority update-policies](zetacored_tx_authority_update-policies.md) - Update the policies
* [zetacored tx authority update-policies](zetacored_tx_authority_update-policies.md) - Update policies to values provided in the JSON file.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tx authority add-authorization

add a new authorization or update the policy of an existing authorization.Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin
Add a new authorization or update the policy of an existing authorization. Policy type can be 0 for groupEmergency, 1 for groupOperational, 2 for groupAdmin.

```
zetacored tx authority add-authorization [msg-url] [authorized-policy] [flags]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tx authority update-policies

Update the policies
Update policies to values provided in the JSON file.

```
zetacored tx authority update-policies [policies-json-file] [flags]
Expand Down
17 changes: 17 additions & 0 deletions e2e/e2etests/e2etests.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ const (
TestUpdateBytecodeZRC20Name = "update_bytecode_zrc20"
TestUpdateBytecodeConnectorName = "update_bytecode_connector"
TestRateLimiterName = "rate_limiter"

/*
Special tests
Not used to test functionalities but do various interactions with the netwoks
*/
TestDeploy = "deploy"
)

// AllE2ETests is an ordered list of all e2e tests
Expand Down Expand Up @@ -507,4 +513,15 @@ var AllE2ETests = []runner.E2ETest{
[]runner.ArgDefinition{},
TestRateLimiter,
),
/*
Special tests
*/
runner.NewE2ETest(
TestDeploy,
"deploy a contract",
[]runner.ArgDefinition{
{Description: "contract name", DefaultValue: ""},
},
TestDeployContract,
),
}
90 changes: 90 additions & 0 deletions e2e/e2etests/test_deploy_contract.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package e2etests

import (
"fmt"

ethcommon "github.com/ethereum/go-ethereum/common"

"github.com/zeta-chain/zetacore/e2e/contracts/testdapp"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
)

// deployFunc is a function that deploys a contract
type deployFunc func(r *runner.E2ERunner) (ethcommon.Address, error)

// deployMap maps contract names to deploy functions
var deployMap = map[string]deployFunc{
"testdapp_zevm": deployZEVMTestDApp,
"testdapp_evm": deployEVMTestDApp,
}

// TestDeployContract deploys the specified contract
func TestDeployContract(r *runner.E2ERunner, args []string) {
availableContractNames := make([]string, 0, len(deployMap))
for contractName := range deployMap {
availableContractNames = append(availableContractNames, contractName)
}
availableContractNamesMessage := fmt.Sprintf("Available contract names: %v", availableContractNames)

if len(args) != 1 {
panic(
"TestDeployContract requires exactly one argument for the contract name. " + availableContractNamesMessage,
)
}
contractName := args[0]

deployFunc, ok := deployMap[contractName]
if !ok {
panic(fmt.Sprintf("Unknown contract name: %s, %s", contractName, availableContractNamesMessage))
}

addr, err := deployFunc(r)
if err != nil {
panic(err)
}

r.Logger.Print("%s deployed at %s", contractName, addr.Hex())
}

// deployZEVMTestDApp deploys the TestDApp contract on ZetaChain
func deployZEVMTestDApp(r *runner.E2ERunner) (ethcommon.Address, error) {
addr, tx, _, err := testdapp.DeployTestDApp(
r.ZEVMAuth,
r.ZEVMClient,
r.ConnectorZEVMAddr,
r.WZetaAddr,
)
if err != nil {
return addr, err
}

// Wait for the transaction to be mined
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.ZEVMClient, tx, r.Logger, r.ReceiptTimeout)
if receipt.Status != 1 {
return addr, fmt.Errorf("contract deployment failed")
}

return addr, nil
}

// deployEVMTestDApp deploys the TestDApp contract on Ethereum
func deployEVMTestDApp(r *runner.E2ERunner) (ethcommon.Address, error) {
addr, tx, _, err := testdapp.DeployTestDApp(
r.EVMAuth,
r.EVMClient,
r.ConnectorEthAddr,
r.ZetaEthAddr,
)
if err != nil {
return addr, err
}

// Wait for the transaction to be mined
receipt := utils.MustWaitForTxReceipt(r.Ctx, r.EVMClient, tx, r.Logger, r.ReceiptTimeout)
if receipt.Status != 1 {
return addr, fmt.Errorf("contract deployment failed")
}

return addr, nil
}
14 changes: 7 additions & 7 deletions pkg/chains/address_taproot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestAddressTaproot(t *testing.T) {
// should parse mainnet taproot address
addrStr := "bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c"
addr, err := DecodeTaprootAddress(addrStr)
require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, addrStr, addr.String())
require.Equal(t, addrStr, addr.EncodeAddress())
require.True(t, addr.IsForNet(&chaincfg.MainNetParams))
Expand All @@ -22,7 +22,7 @@ func TestAddressTaproot(t *testing.T) {
// should parse testnet taproot address
addrStr := "tb1pzeclkt6upu8xwuksjcz36y4q56dd6jw5r543eu8j8238yaxpvcvq7t8f33"
addr, err := DecodeTaprootAddress(addrStr)
require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, addrStr, addr.String())
require.Equal(t, addrStr, addr.EncodeAddress())
require.True(t, addr.IsForNet(&chaincfg.TestNet3Params))
Expand All @@ -31,7 +31,7 @@ func TestAddressTaproot(t *testing.T) {
// should parse regtest taproot address
addrStr := "bcrt1pqqqsyqcyq5rqwzqfpg9scrgwpugpzysnzs23v9ccrydpk8qarc0sj9hjuh"
addr, err := DecodeTaprootAddress(addrStr)
require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, addrStr, addr.String())
require.Equal(t, addrStr, addr.EncodeAddress())
require.True(t, addr.IsForNet(&chaincfg.RegressionNetParams))
Expand All @@ -50,17 +50,17 @@ func TestAddressTaproot(t *testing.T) {
witnessProg[i] = byte(i)
}
_, err := newAddressTaproot("bcrt", witnessProg[:])
require.Nil(t, err)
require.NoError(t, err)
//t.Logf("addr: %v", addr)
}
{
// should create correct taproot address from given witness program
// these hex string comes from link
// https://mempool.space/tx/41f7cbaaf9a8d378d09ee86de32eebef455225520cb71015cc9a7318fb42e326
witnessProg, err := hex.DecodeString("af06f3d4c726a3b952f2f648d86398af5ddfc3df27aa531d97203987add8db2e")
require.Nil(t, err)
require.NoError(t, err)
addr, err := NewAddressTaproot(witnessProg[:], &chaincfg.MainNetParams)
require.Nil(t, err)
require.NoError(t, err)
require.Equal(t, addr.EncodeAddress(), "bc1p4ur084x8y63mj5hj7eydscuc4awals7ly749x8vhyquc0twcmvhquspa5c")
}
{
Expand All @@ -69,7 +69,7 @@ func TestAddressTaproot(t *testing.T) {
// https://blockstream.info/tx/09298a2f32f5267f419aeaf8a58c4807dcf6cac3edb59815a3b129cd8f1219b0?expand
addrStr := "bc1p6pls9gpm24g8ntl37pajpjtuhd3y08hs5rnf9a4n0wq595hwdh9suw7m2h"
addr, err := DecodeTaprootAddress(addrStr)
require.Nil(t, err)
require.NoError(t, err)
require.Equal(
t,
"d07f02a03b555079aff1f07b20c97cbb62479ef0a0e692f6b37b8142d2ee6dcb",
Expand Down
Loading

0 comments on commit c23b282

Please sign in to comment.