Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix and unit tests for query pending cctx within rate limit #2060

Merged
merged 41 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8db24cc
initial commit of grpc pending cctx query with rate limiter
ws4charlie Apr 18, 2024
a873173
replace big.Float with sdk.Dec and update mock rate limiter flags
ws4charlie Apr 18, 2024
60cdbd0
split big loop into backwards loop and forwards loop to be more accurate
ws4charlie Apr 18, 2024
b888133
Merge branch 'develop' of https://github.com/zeta-chain/node into fea…
ws4charlie Apr 18, 2024
3f63f22
adjust zetaclient code to query pending cctx with rate limit
ws4charlie Apr 18, 2024
f0b0677
update change log and add one more rate limiter flag test
ws4charlie Apr 19, 2024
aab441e
use outboun amount for calculation
ws4charlie Apr 19, 2024
00ab5ac
some minimum code refactor
ws4charlie Apr 19, 2024
f31c988
created separate file for cctx query with rate limit
ws4charlie Apr 19, 2024
3cdf614
Merge branch 'develop' into feat-withdraw-rate-limit
ws4charlie Apr 19, 2024
6ad94af
improved a few error handlling
ws4charlie Apr 19, 2024
27e94a7
use old cctx query as fallback when rate limiter is disabled; some re…
ws4charlie Apr 19, 2024
0eb3b8a
fixed unit test compile
ws4charlie Apr 19, 2024
1568e44
Merge branch 'develop' into feat-withdraw-rate-limit
lumtis Apr 19, 2024
60e5dcc
added unit test for fallback query
ws4charlie Apr 20, 2024
101457c
added unit tests for cctx value conversion
ws4charlie Apr 20, 2024
7065d2e
added unit tests for cctx value conversion
ws4charlie Apr 20, 2024
874d5f3
add changelog entry
ws4charlie Apr 20, 2024
16955b8
added unit tests for query pending cctxs within rate limit
ws4charlie Apr 20, 2024
249bcaa
added total value in rate limiter window for monitoring purpose
ws4charlie Apr 20, 2024
dd950a8
Merge branch 'develop' into unit-test-rate-limit
lumtis Apr 22, 2024
7fe367f
Update x/crosschain/keeper/grpc_query_cctx_rate_limit.go
ws4charlie Apr 22, 2024
e5e4e28
change variable name fCoin to foreignCoin
ws4charlie Apr 22, 2024
5e28daf
Update x/fungible/keeper/foreign_coins.go
ws4charlie Apr 22, 2024
da27a84
Update x/crosschain/keeper/grpc_query_cctx_rate_limit_test.go
ws4charlie Apr 22, 2024
f9eed15
converted rate limiter query unit tests to table test
ws4charlie Apr 22, 2024
f40cf45
handle edge case when pending cctxs span wider block range than slidi…
ws4charlie Apr 24, 2024
578afcc
added zero rate check; added comment to make unit test clearer
ws4charlie Apr 24, 2024
fa24f32
added unit test and note for method GetAllForeignCoinMap
ws4charlie Apr 24, 2024
61627b1
treat Rate as average block rate; stop outbound when current rate lim…
ws4charlie Apr 25, 2024
daba269
add commented unit tests back
ws4charlie Apr 25, 2024
ec6aca8
Merge branch 'v16.0.0-rc' into unit-test-rate-limit
lumtis Apr 29, 2024
c011900
replace sdk.Dec with sdkmath.Int to represent cctx value in azeta
ws4charlie Apr 29, 2024
289ec62
test: disable header proof test in local upgrade test E2E test (#2051)
lumtis Apr 29, 2024
bd13759
test(e2e): add rate limiter admin E2E test (#2063)
lumtis Apr 29, 2024
4be83fb
removed incorrect Note
ws4charlie Apr 29, 2024
2a1433d
Merge branch 'v16.0.0-rc' into unit-test-rate-limit
ws4charlie Apr 29, 2024
23b7930
improved variable name
ws4charlie Apr 29, 2024
17b955e
Merge branch 'release/v16' into unit-test-rate-limit
lumtis Apr 30, 2024
7136f31
add E2E test for rate limiter gas and erc20
lumtis Apr 30, 2024
fd861d5
remove outdated comment
lumtis Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
* [1985](https://github.com/zeta-chain/node/pull/1985) - improve fungible module coverage
* [1992](https://github.com/zeta-chain/node/pull/1992) - remove setupKeeper from crosschain module
* [2008](https://github.com/zeta-chain/node/pull/2008) - add test for connector bytecode update
* [2060](https://github.com/zeta-chain/node/pull/2060) - add unit test for rate limiter query

### Fixes

Expand Down
5 changes: 5 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54013,6 +54013,11 @@ definitions:
total_pending:
type: string
format: uint64
current_withdraw_window:
type: string
format: int64
current_withdraw_rate:
type: string
rate_limit_exceeded:
type: boolean
crosschainQueryMessagePassingProtocolFeeResponse:
Expand Down
4 changes: 3 additions & 1 deletion proto/crosschain/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ message QueryListPendingCctxWithinRateLimitRequest {
message QueryListPendingCctxWithinRateLimitResponse {
repeated CrossChainTx cross_chain_tx = 1;
uint64 total_pending = 2;
bool rate_limit_exceeded = 3;
int64 current_withdraw_window = 3;
string current_withdraw_rate = 4;
bool rate_limit_exceeded = 5;
}

message QueryLastZetaHeightRequest {}
Expand Down
6 changes: 3 additions & 3 deletions testutil/keeper/mocks/crosschain/fungible.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion typescript/crosschain/query_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,17 @@ export declare class QueryListPendingCctxWithinRateLimitResponse extends Message
totalPending: bigint;

/**
* @generated from field: bool rate_limit_exceeded = 3;
* @generated from field: int64 current_withdraw_window = 3;
*/
currentWithdrawWindow: bigint;

/**
* @generated from field: string current_withdraw_rate = 4;
*/
currentWithdrawRate: string;

/**
* @generated from field: bool rate_limit_exceeded = 5;
*/
rateLimitExceeded: boolean;

Expand Down
5 changes: 4 additions & 1 deletion x/crosschain/keeper/grpc_query_cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
const (
// MaxPendingCctxs is the maximum number of pending cctxs that can be queried
MaxPendingCctxs = 500

// MaxLookbackNonce is the maximum number of nonces to look back to find missed pending cctxs
MaxLookbackNonce = 1000
)

func (k Keeper) ZetaAccounting(c context.Context, _ *types.QueryZetaAccountingRequest) (*types.QueryZetaAccountingResponse, error) {
Expand Down Expand Up @@ -122,7 +125,7 @@ func (k Keeper) ListPendingCctx(c context.Context, req *types.QueryListPendingCc
// now query the previous nonces up to 1000 prior to find any pending cctx that we might have missed
// need this logic because a confirmation of higher nonce will automatically update the p.NonceLow
// therefore might mask some lower nonce cctx that is still pending.
startNonce := pendingNonces.NonceLow - 1000
startNonce := pendingNonces.NonceLow - MaxLookbackNonce
if startNonce < 0 {
startNonce = 0
}
Expand Down
Loading
Loading