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

Rate limit inttests #347

Merged
merged 30 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dcef714
inc hermes gas multiplier in order to avoid oog
quasisamurai Sep 10, 2024
6b6b634
wip debug
quasisamurai Sep 12, 2024
e0c5a1b
inc gmp once again
quasisamurai Sep 12, 2024
ee8b133
inc gmp once again
quasisamurai Sep 12, 2024
8247b95
bring multiplier down
quasisamurai Sep 12, 2024
5e49fc6
add skeleton for rl
quasisamurai Sep 18, 2024
ad40ad9
fix & improve tests
quasisamurai Sep 19, 2024
f070a06
lint
quasisamurai Sep 19, 2024
5e516f8
improve tests
quasisamurai Sep 19, 2024
f1147a4
rm debug traces
quasisamurai Sep 19, 2024
7a53a72
rm ibc transfer debug prints as well
quasisamurai Sep 19, 2024
bee8ea8
use built-in wallet from mnemonic func
quasisamurai Sep 19, 2024
2ebf08f
rm consolelogs
quasisamurai Sep 20, 2024
adaf55a
split one test in 2 for explicity, extend comments and describes
quasisamurai Sep 24, 2024
08f6d33
add more comments
quasisamurai Sep 24, 2024
05dadb4
lint
quasisamurai Sep 24, 2024
f777034
cover more scenarios
quasisamurai Sep 26, 2024
10b1869
lint & more explicit namings & small ref
quasisamurai Sep 26, 2024
75d327f
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Sep 27, 2024
000d45a
upd njsp
quasisamurai Sep 27, 2024
e42fe5c
switch njs once again
quasisamurai Sep 30, 2024
385b3b5
switch njsp once again
quasisamurai Sep 30, 2024
ecf0f7c
update njsp))
quasisamurai Sep 30, 2024
db3f971
update njsp to linted version (just in case)
quasisamurai Sep 30, 2024
a5aaa27
store rl contract
quasisamurai Sep 30, 2024
3f43c19
use fixed njsp version & regen yarnlock
quasisamurai Sep 30, 2024
cfaa50b
use pwd fallback on njs build
quasisamurai Sep 30, 2024
e721578
try magic commit
quasisamurai Oct 1, 2024
da6674c
bring hermes gas multiplier back: we fixed the cause of high gas cons…
quasisamurai Oct 1, 2024
25c7721
add comment
quasisamurai Oct 2, 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"test:dex_bindings": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/dex_bindings --bail 1",
"test:chain_manager": "vitest --run src/testcases/run_in_band/chain_manager --bail 1",
"test:feemarket": "NO_WAIT_CHANNEL1=1 NO_WAIT_HTTP2=1 NO_WAIT_CHANNEL2=1 NO_WAIT_DELAY=1 vitest --run src/testcases/run_in_band/feemarket --bail 1",
"test:rate_limit": "vitest --run src/testcases/run_in_band/rate_limit --bail 1",
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
"lint": "eslint ./src",
"fmt": "eslint ./src --fix",
"build:neutronjsplus": "[ -d './node_modules/@neutron-org/neutronjsplus/dist' ] || tsc -p ./node_modules/@neutron-org/neutronjsplus/tsconfig.json",
Expand All @@ -45,7 +46,7 @@
"@cosmjs/stargate": "0.32.4",
"@cosmjs/tendermint-rpc": "^0.32.4",
"@neutron-org/neutronjs": "https://github.com/neutron-org/neutronjs.git#1e70c1f68e997857f42bab7647227c8ca9dc8aa1",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#1e4527ef6971f4dc2c202cb3cc2a50b0a4491f54",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#a05b8bedd5ad6e33cf55da79821a1652ea6c2b22",
"@types/lodash": "^4.14.182",
"axios": "1.6.0",
"commander": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion setup/hermes/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.0025, denom = 'untrn' }
gas_multiplier = 2.0
gas_multiplier = 2.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? because of computation increase during packet_recv and packet_send handlers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, otherwise during ibc_transfer test contract isn't refunded because of out of gas

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's got required to increase the multiplier because of a poor simulation process or because the IBC transactions reached the ceiling of max_gas = 3000000. if the latter, why don't increase the max_gas instead of the multiplier? would be cleaner

max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
Expand Down
1 change: 1 addition & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const CONTRACTS = {
LOCKDROP_VAULT_CL: 'lockdrop_vault_for_cl_pools.wasm',
MARKETMAP: 'marketmap.wasm',
ORACLE: 'oracle.wasm',
RATE_LIMITER: 'rate_limiter.wasm',
};

export const NEUTRON_PREFIX = process.env.NEUTRON_ADDRESS_PREFIX || 'neutron';
Expand Down
49 changes: 35 additions & 14 deletions src/helpers/signing_neutron_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,27 @@ export class SigningNeutronClient extends CosmWasmClient {
fee: StdFee | 'auto' | number = 'auto',
admin: string = this.sender,
): Promise<string> {
// upload
const wasmCode = await this.getNeutronContract(fileName);
const uploadResult = await this.client.upload(this.sender, wasmCode, fee);

// instantiate
const res = await this.client.instantiate(
this.sender,
uploadResult.codeId,
msg,
label,
fee,
{ admin },
);
return res.contractAddress;
try {
// Upload
const wasmCode = await this.getNeutronContract(fileName);
const uploadResult = await this.client.upload(this.sender, wasmCode, fee);
console.log('Upload logs:', uploadResult.logs);

// Instantiate
const res = await this.client.instantiate(
this.sender,
uploadResult.codeId,
msg,
label,
fee,
{ admin },
);
console.log('Instantiation events:', res.events);
return res.contractAddress;
} catch (error) {
console.error('Error during contract upload/instantiation:', error);
throw new Error(`Contract instantiation failed: ${error}`);
}
}

async migrate(
Expand Down Expand Up @@ -228,3 +235,17 @@ export class SigningNeutronClient extends CosmWasmClient {
);
}
}

export async function CreateWalletFromMnemonic(
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
mnemonic: string,
prefix: string,
): Promise<DirectSecp256k1HdWallet> {
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, {
prefix: prefix,
});

const accounts = await wallet.getAccounts();

console.log('Wallet address:', accounts[0].address);
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
return wallet;
}
22 changes: 19 additions & 3 deletions src/testcases/parallel/ibc_transfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ describe('Neutron / IBC transfer', () => {
hermes checks height on remote chain and Timeout error occurs.
*/
const currentHeight = await gaiaClient.getHeight();
await waitBlocks(15, gaiaClient);
await waitBlocks(25, gaiaClient);
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved

await neutronClient.execute(ibcContract, {
send: {
Expand Down Expand Up @@ -562,6 +562,12 @@ describe('Neutron / IBC transfer', () => {
state: 'enabled_infinite_loop',
},
});
// check that failures count is the same
let failuresResAfter = await contractManagerQuerier.failures({
address: ibcContract,
});

console.log(failuresResAfter);

await neutronClient.execute(ibcContract, {
send: {
Expand All @@ -572,7 +578,14 @@ describe('Neutron / IBC transfer', () => {
},
});

await neutronClient.waitBlocks(5);
await neutronClient.waitBlocks(35);

// check that failures count is the same
failuresResAfter = await contractManagerQuerier.failures({
address: ibcContract,
});

console.log(failuresResAfter);

const res = await neutronClient.getWithAttempts<QueryFailuresResponse>(
async () =>
Expand Down Expand Up @@ -614,6 +627,7 @@ describe('Neutron / IBC transfer', () => {
const failuresResAfter = await contractManagerQuerier.failures({
address: ibcContract,
});
console.log(failuresResAfter.failures);
expect(failuresResAfter.failures.length).toEqual(6);

// Restore sudo handler's normal state
Expand All @@ -629,19 +643,21 @@ describe('Neutron / IBC transfer', () => {
address: ibcContract,
});
const failure = failuresResBefore.failures[0];
console.log(failure);
const res = await neutronClient.execute(ibcContract, {
resubmit_failure: {
failure_id: +failure.id.toString(),
},
});
expect(res.code).toBe(0);

await neutronClient.waitBlocks(5);
await neutronClient.waitBlocks(10);

// check that failures count is changed
const failuresResAfter = await contractManagerQuerier.failures({
address: ibcContract,
});
console.log(failuresResAfter.failures);
expect(failuresResAfter.failures.length).toEqual(5);
});
});
Expand Down
Loading
Loading