Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/zeta-chain/node into fea…
Browse files Browse the repository at this point in the history
…t-solana-fee-payer-key
  • Loading branch information
ws4charlie committed Aug 13, 2024
2 parents 98f041a + de6ed7b commit 755ee5c
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-nightly-performance-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: "INSTALL:NODEJS"
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: "START:LOCAL:NET:WITH:STATE"
run: |
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
artillery report report.json --output artillery_report.html
- name: "UPLOAD:REPORT"
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: artillery-report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
core.setOutput('ADMIN_TESTS', true);
core.setOutput('PERFORMANCE_TESTS', true);
core.setOutput('STATEFUL_DATA_TESTS', true);
core.setOutput('TSS_MIGRATION_TESTS', labels.includes('TSS_MIGRATION_TESTS'));
core.setOutput('TSS_MIGRATION_TESTS', true);
core.setOutput('SOLANA_TESTS', true);
} else if (context.eventName === 'workflow_dispatch') {
core.setOutput('DEFAULT_TESTS', context.payload.inputs['default-test']);
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* [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
* [2644](https://github.com/zeta-chain/node/pull/2644) - add created_timestamp to cctx status
* [2673](https://github.com/zeta-chain/node/pull/2673) - add relayer key importer, encryption and decryption

### Refactor
Expand Down
8 changes: 7 additions & 1 deletion 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"
flagSkipTrackerCheck = "skip-tracker-check"
)

var (
Expand Down Expand Up @@ -73,6 +74,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(flagSkipTrackerCheck, false, "set to true to skip tracker check at the end of the tests")

return cmd
}
Expand All @@ -94,6 +96,7 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
skipSetup = must(cmd.Flags().GetBool(flagSkipSetup))
skipBitcoinSetup = must(cmd.Flags().GetBool(flagSkipBitcoinSetup))
skipHeaderProof = must(cmd.Flags().GetBool(flagSkipHeaderProof))
skipTrackerCheck = must(cmd.Flags().GetBool(flagSkipTrackerCheck))
testTSSMigration = must(cmd.Flags().GetBool(flagTestTSSMigration))
)

Expand Down Expand Up @@ -353,7 +356,10 @@ func localE2ETest(cmd *cobra.Command, _ []string) {
if testTSSMigration {
runTSSMigrationTest(deployerRunner, logger, verbose, conf)
}

// Verify that there are no trackers left over after tests complete
if !skipTrackerCheck {
deployerRunner.EnsureNoTrackers()
}
// print and validate report
networkReport, err := deployerRunner.GenerateNetworkReport()
if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then

# set upgrade height to 225 by default
UPGRADE_HEIGHT=${UPGRADE_HEIGHT:=225}
OLD_VERSION=$(get_zetacored_version)
COMMON_ARGS="--skip-header-proof --skip-tracker-check"

if [[ ! -f deployed.yml ]]; then
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out deployed.yml --skip-header-proof
zetae2e local $E2E_ARGS --setup-only --config config.yml --config-out deployed.yml ${COMMON_ARGS}
if [ $? -ne 0 ]; then
echo "e2e setup failed"
exit 1
Expand All @@ -127,17 +129,14 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
echo "running E2E command to setup the networks and populate the state..."

# Use light flag to ensure tests can complete before the upgrade height
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light --skip-header-proof
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light ${COMMON_ARGS}
if [ $? -ne 0 ]; then
echo "first e2e failed"
exit 1
fi
fi

echo "Waiting for upgrade height..."

OLD_VERSION=$(get_zetacored_version)

CURRENT_HEIGHT=0
WAIT_HEIGHT=$(( UPGRADE_HEIGHT - 1 ))
# wait for upgrade height
Expand Down Expand Up @@ -169,9 +168,9 @@ if [ "$LOCALNET_MODE" == "upgrade" ]; then
# When the upgrade height is greater than 100 for upgrade test, the Bitcoin tests have been run once, therefore the Bitcoin wallet is already set up
# Use light flag to skip advanced tests
if [ "$UPGRADE_HEIGHT" -lt 100 ]; then
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light --skip-header-proof
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --light ${COMMON_ARGS}
else
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-bitcoin-setup --light --skip-header-proof
zetae2e local $E2E_ARGS --skip-setup --config deployed.yml --skip-bitcoin-setup --light ${COMMON_ARGS}
fi

ZETAE2E_EXIT_CODE=$?
Expand Down
4 changes: 4 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58421,6 +58421,10 @@ definitions:
format: int64
isAbortRefunded:
type: boolean
created_timestamp:
type: string
format: int64
description: when the CCTX was created. only populated on new transactions.
zetacoreemissionsParams:
type: object
properties:
Expand Down
2 changes: 2 additions & 0 deletions proto/zetachain/zetacore/crosschain/cross_chain_tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ message Status {
string status_message = 2;
int64 lastUpdate_timestamp = 3;
bool isAbortRefunded = 4;
// when the CCTX was created. only populated on new transactions.
int64 created_timestamp = 5;
}

message CrossChainTx {
Expand Down
5 changes: 4 additions & 1 deletion testutil/sample/crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ func OutboundParamsValidChainID(r *rand.Rand) *types.OutboundParams {
func Status(t *testing.T, index string) *types.Status {
r := newRandFromStringSeed(t, index)

createdAt := r.Int63()

return &types.Status{
Status: types.CctxStatus(r.Intn(100)),
StatusMessage: String(),
LastUpdateTimestamp: r.Int63(),
CreatedTimestamp: createdAt,
LastUpdateTimestamp: createdAt,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ export declare class Status extends Message<Status> {
*/
isAbortRefunded: boolean;

/**
* when the CCTX was created. only populated on new transactions.
*
* @generated from field: int64 created_timestamp = 5;
*/
createdTimestamp: bigint;

constructor(data?: PartialMessage<Status>);

static readonly runtime: typeof proto3;
Expand Down
1 change: 0 additions & 1 deletion x/crosschain/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func CheckAndUpdateCctxGasPrice(
// set new gas price and last update timestamp
cctx.GetCurrentOutboundParam().GasPrice = newGasPrice.String()
cctx.GetCurrentOutboundParam().GasPriorityFee = newPriorityFee.String()
cctx.CctxStatus.LastUpdateTimestamp = ctx.BlockHeader().Time.Unix()
k.SetCrossChainTx(ctx, cctx)

return gasPriceIncrease, additionalFees, nil
Expand Down
9 changes: 9 additions & 0 deletions x/crosschain/keeper/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "a1",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand All @@ -152,6 +153,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "a2",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand Down Expand Up @@ -180,6 +182,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "a3",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand Down Expand Up @@ -208,6 +211,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "b0",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand Down Expand Up @@ -235,6 +239,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "b1",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand All @@ -257,6 +262,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "b2",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand All @@ -279,6 +285,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "b3",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand All @@ -301,6 +308,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "c1",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand All @@ -322,6 +330,7 @@ func TestCheckAndUpdateCctxGasPrice(t *testing.T) {
cctx: types.CrossChainTx{
Index: "c2",
CctxStatus: &types.Status{
CreatedTimestamp: sampleTimestamp.Unix(),
LastUpdateTimestamp: sampleTimestamp.Unix(),
},
OutboundParams: []*types.OutboundParams{
Expand Down
5 changes: 5 additions & 0 deletions x/crosschain/keeper/cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func (k Keeper) SetCctxAndNonceToCctxAndInboundHashToCctx(ctx sdk.Context, cctx

// SetCrossChainTx set a specific send in the store from its index
func (k Keeper) SetCrossChainTx(ctx sdk.Context, cctx types.CrossChainTx) {
// only set the update timestamp if the block height is >0 to allow
// for a genesis import
if cctx.CctxStatus != nil && ctx.BlockHeight() > 0 {
cctx.CctxStatus.LastUpdateTimestamp = ctx.BlockHeader().Time.Unix()
}
p := types.KeyPrefix(fmt.Sprintf("%s", types.CCTXKey))
store := prefix.NewStore(ctx.KVStore(k.storeKey), p)
b := k.cdc.MustMarshal(&cctx)
Expand Down
3 changes: 3 additions & 0 deletions x/crosschain/keeper/grpc_query_cctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,8 @@ func TestKeeper_CctxByNonce(t *testing.T) {
})
require.NoError(t, err)
require.Equal(t, cctx, res.CrossChainTx)

// ensure that LastUpdateTimestamp is set to current block time
require.Equal(t, res.CrossChainTx.CctxStatus.LastUpdateTimestamp, ctx.BlockTime().Unix())
})
}
2 changes: 2 additions & 0 deletions x/crosschain/keeper/msg_server_abort_stuck_cctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func TestMsgServer_AbortStuckCCTX(t *testing.T) {
require.True(t, found)
require.Equal(t, crosschaintypes.CctxStatus_Aborted, cctxFound.CctxStatus.Status)
require.Equal(t, crosschainkeeper.AbortMessage, cctxFound.CctxStatus.StatusMessage)
// ensure the last update timestamp is updated
require.Equal(t, cctxFound.CctxStatus.LastUpdateTimestamp, ctx.BlockTime().Unix())
})

t.Run("can abort a cctx in pending revert", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_refund_aborted_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (k msgServer) RefundAbortedCCTX(
commit()

// set the cctx as refunded
cctx.CctxStatus.AbortRefunded(ctx.BlockTime().Unix())
cctx.CctxStatus.AbortRefunded()

k.SetCrossChainTx(ctx, cctx)

Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/types/cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func (m *CrossChainTx) AddOutbound(
m.GetCurrentOutboundParam().EffectiveGasPrice = msg.ObservedOutboundEffectiveGasPrice
m.GetCurrentOutboundParam().EffectiveGasLimit = msg.ObservedOutboundEffectiveGasLimit
m.GetCurrentOutboundParam().ObservedExternalHeight = msg.ObservedOutboundBlockHeight
m.CctxStatus.LastUpdateTimestamp = ctx.BlockHeader().Time.Unix()
return nil
}

Expand Down Expand Up @@ -211,6 +210,7 @@ func NewCCTX(ctx sdk.Context, msg MsgVoteInbound, tssPubkey string) (CrossChainT
status := &Status{
Status: CctxStatus_PendingInbound,
StatusMessage: "",
CreatedTimestamp: ctx.BlockHeader().Time.Unix(),
LastUpdateTimestamp: ctx.BlockHeader().Time.Unix(),
IsAbortRefunded: false,
}
Expand Down
2 changes: 0 additions & 2 deletions x/crosschain/types/cctx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ func TestCrossChainTx_AddOutbound(t *testing.T) {
require.Equal(t, cctx.GetCurrentOutboundParam().EffectiveGasPrice, sdkmath.NewInt(100))
require.Equal(t, cctx.GetCurrentOutboundParam().EffectiveGasLimit, uint64(20))
require.Equal(t, cctx.GetCurrentOutboundParam().ObservedExternalHeight, uint64(10))
require.Equal(t, cctx.CctxStatus.LastUpdateTimestamp, ctx.BlockHeader().Time.Unix())
})

t.Run("successfully get outbound tx for failed ballot without amount check", func(t *testing.T) {
Expand All @@ -220,7 +219,6 @@ func TestCrossChainTx_AddOutbound(t *testing.T) {
require.Equal(t, cctx.GetCurrentOutboundParam().EffectiveGasPrice, sdkmath.NewInt(100))
require.Equal(t, cctx.GetCurrentOutboundParam().EffectiveGasLimit, uint64(20))
require.Equal(t, cctx.GetCurrentOutboundParam().ObservedExternalHeight, uint64(10))
require.Equal(t, cctx.CctxStatus.LastUpdateTimestamp, ctx.BlockHeader().Time.Unix())
})

t.Run("failed to get outbound tx if amount does not match value received", func(t *testing.T) {
Expand Down
Loading

0 comments on commit 755ee5c

Please sign in to comment.