Skip to content

Commit

Permalink
Merge branch 'develop' into e2e/bitcoin-live-network
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Jun 5, 2024
2 parents 47c08b6 + 26b4f69 commit faa4027
Show file tree
Hide file tree
Showing 238 changed files with 2,846 additions and 355 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
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +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 new messages `MsgAddAuthorization` and `MsgRemoveAuthorization` that can be used to update the authorization list

### Refactor

Expand All @@ -38,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 @@ -47,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 @@ -67,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
4 changes: 3 additions & 1 deletion docs/cli/zetacored/zetacored_tx_authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +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 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.

53 changes: 53 additions & 0 deletions docs/cli/zetacored/zetacored_tx_authority_add-authorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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.

```
zetacored tx authority add-authorization [msg-url] [authorized-policy] [flags]
```

### Options

```
-a, --account-number uint The account number of the signing account (offline mode only)
--aux Generate aux signer data instead of sending a tx
-b, --broadcast-mode string Transaction broadcasting mode (sync|async)
--chain-id string The network chain ID
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)
--fee-granter string Fee granter grants fees for the transaction
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000)
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
-h, --help help for add-authorization
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
--ledger Use a connected Ledger device
--node string [host]:[port] to tendermint rpc interface for this chain
--note string Note to add a description to the transaction (previously --memo)
--offline Offline mode (does not allow any online functionality)
-o, --output string Output format (text|json)
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
--tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator
-y, --yes Skip tx broadcasting prompt confirmation
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx authority](zetacored_tx_authority.md) - authority transactions subcommands

53 changes: 53 additions & 0 deletions docs/cli/zetacored/zetacored_tx_authority_remove-authorization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# tx authority remove-authorization

removes an existing authorization

```
zetacored tx authority remove-authorization [msg-url] [flags]
```

### Options

```
-a, --account-number uint The account number of the signing account (offline mode only)
--aux Generate aux signer data instead of sending a tx
-b, --broadcast-mode string Transaction broadcasting mode (sync|async)
--chain-id string The network chain ID
--dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)
--fee-granter string Fee granter grants fees for the transaction
--fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer
--fees string Fees to pay along with transaction; eg: 10uatom
--from string Name or address of private key with which to sign
--gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000)
--gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1)
--gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)
--generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)
-h, --help help for remove-authorization
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory)
--keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used
--ledger Use a connected Ledger device
--node string [host]:[port] to tendermint rpc interface for this chain
--note string Note to add a description to the transaction (previously --memo)
--offline Offline mode (does not allow any online functionality)
-o, --output string Output format (text|json)
-s, --sequence uint The sequence number of the signing account (offline mode only)
--sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature
--timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height
--tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator
-y, --yes Skip tx broadcasting prompt confirmation
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--log_no_color Disable colored logs
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored tx authority](zetacored_tx_authority.md) - authority transactions subcommands

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
12 changes: 12 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56730,6 +56730,14 @@ definitions:
ChainInfo contains static information about the chains
This structure is used to dynamically update these info on a live network
before hardcoding the values in a upgrade
authorityMsgAddAuthorizationResponse:
type: object
description: MsgAddAuthorizationResponse defines the MsgAddAuthorizationResponse service.
authorityMsgRemoveAuthorizationResponse:
type: object
description: |-
MsgRemoveAuthorizationResponse defines the MsgRemoveAuthorizationResponse
service.
authorityMsgUpdateChainInfoResponse:
type: object
description: MsgUpdateChainInfoResponse defines the MsgUpdateChainInfoResponse service.
Expand Down Expand Up @@ -56758,13 +56766,17 @@ definitions:
- groupEmergency
- groupOperational
- groupAdmin
- groupEmpty
default: groupEmergency
description: |-
- groupEmergency: Used for emergency situations that require immediate action
- groupOperational: Used for operational tasks like changing
- groupAdmin: non-sensitive protocol parameters

Used for administrative tasks like changing sensitive
- groupEmpty: protocol parameters or moving funds

Used for empty policy, no action is allowed
title: PolicyType defines the type of policy
authorityQueryGetChainInfoResponse:
type: object
Expand Down
24 changes: 24 additions & 0 deletions docs/spec/authority/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,27 @@ message MsgUpdateChainInfo {
}
```

## MsgAddAuthorization

AddAuthorization defines a method to add an authorization.If the authorization already exists, it will be overwritten with the provided policy.
This should be called by the admin policy account.

```proto
message MsgAddAuthorization {
string creator = 1;
string msg_url = 2;
PolicyType authorized_policy = 3;
}
```

## MsgRemoveAuthorization

RemoveAuthorization removes the authorization from the list. It should be called by the admin policy account.

```proto
message MsgRemoveAuthorization {
string creator = 1;
string msg_url = 2;
}
```

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
}
Loading

0 comments on commit faa4027

Please sign in to comment.