From 2d24648ff37b2d00a665f4f0a44ac72983383cd4 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 8 Feb 2024 12:04:28 -0600 Subject: [PATCH 1/3] Remove CompletedOutgoingTxs from unsigned batch and contract calls lookups --- module/x/gravity/keeper/batch.go | 11 ----------- module/x/gravity/keeper/contract_call.go | 12 ------------ 2 files changed, 23 deletions(-) diff --git a/module/x/gravity/keeper/batch.go b/module/x/gravity/keeper/batch.go index 454e125ce..dbcb027ac 100644 --- a/module/x/gravity/keeper/batch.go +++ b/module/x/gravity/keeper/batch.go @@ -163,17 +163,6 @@ func (k Keeper) getLastOutgoingBatchByTokenType(ctx sdk.Context, token common.Ad // GetUnsignedBatchTxs returns all batches for which the specified validator has not submitted confirmations in ascending nonce order func (k Keeper) GetUnsignedBatchTxs(ctx sdk.Context, val sdk.ValAddress) []*types.BatchTx { var unconfirmed []*types.BatchTx - k.IterateCompletedOutgoingTxsByType(ctx, types.BatchTxPrefixByte, func(_ []byte, cotx types.OutgoingTx) bool { - sig := k.getEthereumSignature(ctx, cotx.GetStoreIndex(), val) - if len(sig) == 0 { - batch, ok := cotx.(*types.BatchTx) - if !ok { - panic(sdkerrors.Wrapf(types.ErrInvalid, "couldn't cast to batch tx for completed tx %s", cotx)) - } - unconfirmed = append(unconfirmed, batch) - } - return false - }) k.IterateOutgoingTxsByType(ctx, types.BatchTxPrefixByte, func(_ []byte, otx types.OutgoingTx) bool { sig := k.getEthereumSignature(ctx, otx.GetStoreIndex(), val) if len(sig) == 0 { diff --git a/module/x/gravity/keeper/contract_call.go b/module/x/gravity/keeper/contract_call.go index 57618d394..92fad3033 100644 --- a/module/x/gravity/keeper/contract_call.go +++ b/module/x/gravity/keeper/contract_call.go @@ -12,18 +12,6 @@ import ( func (k Keeper) GetUnsignedContractCallTxs(ctx sdk.Context, val sdk.ValAddress) []*types.ContractCallTx { var unconfirmed []*types.ContractCallTx - k.IterateCompletedOutgoingTxsByType(ctx, types.ContractCallTxPrefixByte, func(_ []byte, cotx types.OutgoingTx) bool { - sig := k.getEthereumSignature(ctx, cotx.GetStoreIndex(), val) - if len(sig) == 0 { - call, ok := cotx.(*types.ContractCallTx) - if !ok { - panic(sdkerrors.Wrapf(types.ErrInvalid, "couldn't cast to contract call for completed tx %s", cotx)) - } - unconfirmed = append(unconfirmed, call) - } - return false - }) - k.IterateOutgoingTxsByType(ctx, types.ContractCallTxPrefixByte, func(_ []byte, otx types.OutgoingTx) bool { sig := k.getEthereumSignature(ctx, otx.GetStoreIndex(), val) if len(sig) == 0 { From 98f5e4036c8f1abb769121c9d7cfc1d7512afbae Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 8 Feb 2024 12:33:58 -0600 Subject: [PATCH 2/3] Patch broken unit tests --- module/x/gravity/keeper/batch_test.go | 9 ++++++--- module/x/gravity/keeper/contract_call_test.go | 3 ++- module/x/gravity/keeper/grpc_query_test.go | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/module/x/gravity/keeper/batch_test.go b/module/x/gravity/keeper/batch_test.go index d4d04335e..e5f544e48 100644 --- a/module/x/gravity/keeper/batch_test.go +++ b/module/x/gravity/keeper/batch_test.go @@ -392,7 +392,8 @@ func TestGetUnconfirmedBatchTxs(t *testing.T) { blockheight := uint64(ctx.BlockHeight()) sig := []byte("dummysig") - gk.SetCompletedOutgoingTx(ctx, &types.BatchTx{ + //gk.SetCompletedOutgoingTx(ctx, &types.BatchTx{ + gk.SetOutgoingTx(ctx, &types.BatchTx{ BatchNonce: 1, Height: uint64(ctx.BlockHeight()), }) @@ -437,12 +438,14 @@ func TestGetUnconfirmedBatchTxs(t *testing.T) { addressA := "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" addressB := "0xBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB" - gk.SetCompletedOutgoingTx(ctx, &types.BatchTx{ + //gk.SetCompletedOutgoingTx(ctx, &types.BatchTx{ + gk.SetOutgoingTx(ctx, &types.BatchTx{ TokenContract: addressB, BatchNonce: 3, Height: blockheight, }) - gk.SetCompletedOutgoingTx(ctx, &types.BatchTx{ + //gk.SetCompletedOutgoingTx(ctx, &types.BatchTx{ + gk.SetOutgoingTx(ctx, &types.BatchTx{ TokenContract: addressA, BatchNonce: 4, Height: blockheight, diff --git a/module/x/gravity/keeper/contract_call_test.go b/module/x/gravity/keeper/contract_call_test.go index cb7650806..15f4c8348 100644 --- a/module/x/gravity/keeper/contract_call_test.go +++ b/module/x/gravity/keeper/contract_call_test.go @@ -96,7 +96,8 @@ func TestGetUnconfirmedContractCallTxs(t *testing.T) { fees := []types.ERC20Token{} sig := []byte("dummysig") gk.CreateContractCallTx(ctx, 1, scope, address, payload, tokens, fees) - gk.SetCompletedOutgoingTx(ctx, &types.ContractCallTx{ + //gk.SetCompletedOutgoingTx(ctx, &types.ContractCallTx{ + gk.SetOutgoingTx(ctx, &types.ContractCallTx{ InvalidationNonce: 2, InvalidationScope: scope, Address: address.Hex(), diff --git a/module/x/gravity/keeper/grpc_query_test.go b/module/x/gravity/keeper/grpc_query_test.go index d00dc5f46..def75a04e 100644 --- a/module/x/gravity/keeper/grpc_query_test.go +++ b/module/x/gravity/keeper/grpc_query_test.go @@ -300,7 +300,9 @@ func TestKeeper_UnsignedBatchTxs(t *testing.T) { res, err := gk.UnsignedBatchTxs(sdk.WrapSDKContext(ctx), req) require.NoError(t, err) require.NotNil(t, res) - require.Len(t, res.Batches, 3) + //require.Len(t, res.Batches, 3) + // Test broken by completed tx workaround to SubmitEthereumTxComfiration bug + require.Len(t, res.Batches, 1) } }) } @@ -344,7 +346,9 @@ func TestKeeper_UnsignedContractCallTxs(t *testing.T) { res, err := gk.UnsignedContractCallTxs(sdk.WrapSDKContext(ctx), req) require.NoError(t, err) require.NotNil(t, res) - require.Len(t, res.Calls, 3) + //require.Len(t, res.Calls, 3) + // Test broken by completed tx workaround to SubmitEthereumTxComfiration bug + require.Len(t, res.Calls, 2) } }) } From 73f849de13994eb063efc62f57f5f963d53def59 Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Thu, 8 Feb 2024 12:54:55 -0600 Subject: [PATCH 3/3] Bump rust version in dockerfile to make CI happy --- orchestrator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchestrator/Dockerfile b/orchestrator/Dockerfile index 523646bd3..4964fd074 100644 --- a/orchestrator/Dockerfile +++ b/orchestrator/Dockerfile @@ -1,6 +1,6 @@ # Reference: https://www.lpalmieri.com/posts/fast-rust-docker-builds/ -FROM rust:1.70 as cargo-chef-rust +FROM rust:1.74 as cargo-chef-rust RUN cargo install cargo-chef --version 0.1.62 FROM cargo-chef-rust as planner