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

[NTRN-94] feat: add registry migration #197

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions contracts_migrate/additional/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Additional contracts used in scope of migration:

- `lockdrop_vault_for_cl_pools.wasm` — https://github.com/neutron-org/neutron-dao/pull/71 f22fbf5d0e20a7c0cccbecb42249fd4358614e94;
- `vesting_lp_vault_for_cl_pools.wasm` — https://github.com/neutron-org/neutron-dao/pull/71 f22fbf5d0e20a7c0cccbecb42249fd4358614e94.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions contracts_migrate/current/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Contract versions currently deployed on Neutron mainnet. Retrieved for each contract to be migrated via:

1. Get contract address from [Mainnet deployments page](https://docs.neutron.org/deployment/mainnet/);
2. Run `neutrond q wasm contract <addr>` for a mainnet node, get the `contract_info.code_id` value;
3. Run `neutrond q wasm code <code_id> <binary_name.wasm>` for a mainnet node.
Binary file not shown.
Binary file added contracts_migrate/current/vesting_lp.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions contracts_migrate/new/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Contract versions to be migrated to. Origins:

- `neutron_lockdrop.wasm` — https://github.com/neutron-org/neutron-tge-contracts/pull/51 201126859f2e03b2da814efe8e9dea6c680fbfaa;
- `neutron_voting_registry.wasm` — https://github.com/neutron-org/neutron-dao/pull/75 cdbb558e09fec5548d63f033b296a1011e6259b1;
- `vesting_lp.wasm` — https://github.com/neutron-org/neutron-tge-contracts/pull/51 201126859f2e03b2da814efe8e9dea6c680fbfaa.
Binary file added contracts_migrate/new/neutron_lockdrop.wasm
Binary file not shown.
Binary file not shown.
Binary file added contracts_migrate/new/vesting_lp.wasm
Binary file not shown.
Binary file not shown.
24 changes: 18 additions & 6 deletions src/helpers/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,34 @@ export class Dao {
);
}

async queryTotalVotingPower(): Promise<TotalPowerAtHeightResponse> {
async queryTotalVotingPower(
height?: number,
): Promise<TotalPowerAtHeightResponse> {
return await this.chain.queryContract<TotalPowerAtHeightResponse>(
this.contracts.core.address,
{
total_power_at_height: {},
total_power_at_height:
typeof height === 'undefined' ? {} : { height: height },
},
);
}

async queryVotingPower(addr: string): Promise<VotingPowerAtHeightResponse> {
async queryVotingPower(
addr: string,
height?: number,
): Promise<VotingPowerAtHeightResponse> {
return await this.chain.queryContract<VotingPowerAtHeightResponse>(
this.contracts.core.address,
{
voting_power_at_height: {
address: addr,
},
voting_power_at_height:
typeof height === 'undefined'
? {
address: addr,
}
: {
address: addr,
height: height,
},
},
);
}
Expand Down
16 changes: 7 additions & 9 deletions src/helpers/tge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export class Tge {
priceFeed: string;
coinRegistry: string;
astroFactory: string;
astroFactoryCL: string;
vestingAtomLp: string;
vestingUsdcLp: string;
vestingLpVault: string;
Expand Down Expand Up @@ -198,8 +197,8 @@ export class Tge {
for (const contract of [
'TGE_CREDITS',
'TGE_AUCTION',
'TGE_LOCKDROP',
'TGE_LOCKDROP_V2',
'TGE_LOCKDROP_CURRENT',
'TGE_LOCKDROP_NEW',
'TGE_AIRDROP',
'TGE_PRICE_FEED_MOCK',
'ASTRO_PAIR',
Expand All @@ -212,12 +211,11 @@ export class Tge {
'ASTRO_VESTING',
'ASTRO_COIN_REGISTRY',
'VESTING_LP',
'VESTING_LP_V2',
'VESTING_LP_CURRENT',
'VESTING_LP_NEW',
'LOCKDROP_VAULT',
'LOCKDROP_VAULT_V2',
'CREDITS_VAULT',
'VESTING_LP_VAULT',
'VESTING_LP_VAULT_V2',
'ORACLE_HISTORY',
]) {
const codeId = await this.instantiator.storeWasm(
Expand Down Expand Up @@ -379,13 +377,13 @@ export class Tge {

this.contracts.vestingAtomLp = await instantiateVestingLp(
this.instantiator,
this.codeIds.VESTING_LP,
this.codeIds.VESTING_LP_CURRENT,
this.tokenInfoManager.wallet.address.toString(),
'vesting_atom_lp',
);
this.contracts.vestingUsdcLp = await instantiateVestingLp(
this.instantiator,
this.codeIds.VESTING_LP,
this.codeIds.VESTING_LP_CURRENT,
this.tokenInfoManager.wallet.address.toString(),
'vesting_usdc_lp',
);
Expand Down Expand Up @@ -437,7 +435,7 @@ export class Tge {
async deployLockdrop() {
this.contracts.lockdrop = await instantiateLockdrop(
this.instantiator,
this.codeIds.TGE_LOCKDROP,
this.codeIds.TGE_LOCKDROP_CURRENT,
null,
this.tokenInfoManager.wallet.address.toString(),
this.contracts.credits,
Expand Down
26 changes: 18 additions & 8 deletions src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,15 @@ export const NeutronContract = {
'cwd_subdao_pre_propose_single_no_timelock.wasm',
SUBDAO_PROPOSAL: 'cwd_subdao_proposal_single.wasm',
SUBDAO_TIMELOCK: 'cwd_subdao_timelock_single.wasm',
LOCKDROP_VAULT: '../contracts_thirdparty/lockdrop_vault.wasm',
LOCKDROP_VAULT_V2: 'lockdrop_vault.wasm',
LOCKDROP_VAULT: 'lockdrop_vault.wasm',
ORACLE_HISTORY: 'astroport_oracle.wasm',
TGE_CREDITS: 'credits.wasm',
TGE_AIRDROP: 'cw20_merkle_airdrop.wasm',
CW4_VOTING: '../contracts_thirdparty/cw4_voting.wasm',
CW4_GROUP: '../contracts_thirdparty/cw4_group.wasm',
CW20_BASE: '../contracts_thirdparty/cw20_base.wasm',
TGE_AUCTION: 'neutron_auction.wasm',
TGE_LOCKDROP: '../contracts_thirdparty/neutron_lockdrop.wasm',
TGE_LOCKDROP_V2: 'neutron_lockdrop.wasm',
TGE_LOCKDROP: 'neutron_lockdrop.wasm',
TGE_PRICE_FEED_MOCK: 'neutron_price_feed_mock.wasm',
ASTRO_PAIR: '../contracts_thirdparty/astroport_pair.wasm',
ASTRO_PAIR_CL: '../contracts_thirdparty/astroport_pair_concentrated.wasm',
Expand All @@ -152,14 +150,26 @@ export const NeutronContract = {
ASTRO_GENERATOR: '../contracts_thirdparty/astroport_generator.wasm',
ASTRO_WHITELIST: '../contracts_thirdparty/astroport_whitelist.wasm',
ASTRO_VESTING: '../contracts_thirdparty/astroport_vesting.wasm',
VESTING_LP: '../contracts_thirdparty/vesting_lp.wasm',
VESTING_LP_V2: 'vesting_lp.wasm',
VESTING_LP_VAULT: '../contracts_thirdparty/vesting_lp_vault.wasm',
VESTING_LP_VAULT_V2: 'vesting_lp_vault.wasm',
VESTING_LP: 'vesting_lp.wasm',
VESTING_LP_VAULT: 'vesting_lp_vault.wasm',
CREDITS_VAULT: 'credits_vault.wasm',
VESTING_INVESTORS: 'vesting_investors.wasm',
INVESTORS_VESTING_VAULT: 'investors_vesting_vault.wasm',
TOKENFACTORY: 'tokenfactory.wasm',

// contracts involved in migration
VOTING_REGISTRY_CURRENT:
'../contracts_migrate/current/neutron_voting_registry.wasm',
VOTING_REGISTRY_NEW: '../contracts_migrate/new/neutron_voting_registry.wasm',
TGE_LOCKDROP_CURRENT: '../contracts_migrate/current/neutron_lockdrop.wasm',
TGE_LOCKDROP_NEW: '../contracts_migrate/new/neutron_lockdrop.wasm',
VESTING_LP_CURRENT: '../contracts_migrate/current/vesting_lp.wasm',
VESTING_LP_NEW: '../contracts_migrate/new/vesting_lp.wasm',

LOCKDROP_VAULT_CL:
'../contracts_migrate/additional/lockdrop_vault_for_cl_pools.wasm',
VESTING_LP_VAULT_CL:
'../contracts_migrate/additional/vesting_lp_vault_for_cl_pools.wasm',
};

export type MultiChoiceOption = {
Expand Down
8 changes: 8 additions & 0 deletions src/testcases/parallel/stargate_queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,13 @@ describe('Neutron / Simple', () => {
const res = JSON.parse(await querySmart({ feeburner_params: {} }));
expect(res.params.neutron_denom).toBe('untrn');
});

test('non whitelisted query should NOT work', async () => {
await expect(
querySmart({ feeburner_total_burned_neutrons_amount: {} }),
).rejects.toThrow(
/Unsupported query type: '\/neutron.feeburner.Query\/TotalBurnedNeutronsAmount'/,
);
});
});
});
79 changes: 77 additions & 2 deletions src/testcases/run_in_band/interchaintx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('Neutron / Interchain TXs', () => {
validator: (
testState.wallets.cosmos.val1.address as cosmosclient.ValAddress
).toString(),
amount: '2000',
amount: '1000',
denom: gaiaChain.denom,
},
}),
Expand Down Expand Up @@ -208,6 +208,79 @@ describe('Neutron / Interchain TXs', () => {
async (delegations) =>
delegations.data.delegation_responses?.length == 1,
);
expect(res1.data.delegation_responses).toEqual([
{
balance: { amount: '1000', denom: gaiaChain.denom },
delegation: {
delegator_address: icaAddress1,
shares: '1000.000000000000000000',
validator_address:
'cosmosvaloper18hl5c9xn5dze2g50uaw0l2mr02ew57zk0auktn',
},
},
]);
const res2 = await rest.staking.delegatorDelegations(
gaiaChain.sdk as CosmosSDK,
icaAddress2 as unknown as AccAddress,
);
expect(res2.data.delegation_responses).toEqual([]);
});
test('check contract balance', async () => {
const res = await neutronChain.queryBalances(contractAddress);
const balance = res.balances.find(
(b) => b.denom === neutronChain.denom,
)?.amount;
expect(balance).toEqual('98000');
});
});

describe('DOUBLE ACK - Send Interchain TX', () => {
test('delegate from first ICA', async () => {
// it will delegate two times of passed amount - first from contract call, and second from successful sudo IBC response
const res = await neutronAccount.executeContract(
contractAddress,
JSON.stringify({
delegate_double_ack: {
interchain_account_id: icaId1,
validator: (
testState.wallets.cosmos.val1.address as cosmosclient.ValAddress
).toString(),
amount: '500',
denom: gaiaChain.denom,
},
}),
);
expect(res.code).toEqual(0);
const sequenceId = getSequenceId(res.raw_log);

await waitForAck(neutronChain, contractAddress, icaId1, sequenceId);
const qres = await getAck(
neutronChain,
contractAddress,
icaId1,
sequenceId,
);
expect(qres).toMatchObject<AcknowledgementResult>({
success: ['/cosmos.staking.v1beta1.MsgDelegate'],
});

const ackSequenceId = sequenceId + 1;
await waitForAck(neutronChain, contractAddress, icaId1, ackSequenceId);
expect(qres).toMatchObject<AcknowledgementResult>({
success: ['/cosmos.staking.v1beta1.MsgDelegate'],
});
});
test('check validator state', async () => {
const res1 = await getWithAttempts(
gaiaChain.blockWaiter,
() =>
rest.staking.delegatorDelegations(
gaiaChain.sdk as CosmosSDK,
icaAddress1 as unknown as AccAddress,
),
async (delegations) =>
delegations.data.delegation_responses?.length === 1,
);
expect(res1.data.delegation_responses).toEqual([
{
balance: { amount: '2000', denom: gaiaChain.denom },
Expand All @@ -230,9 +303,11 @@ describe('Neutron / Interchain TXs', () => {
const balance = res.balances.find(
(b) => b.denom === neutronChain.denom,
)?.amount;
expect(balance).toEqual('98000');
// two interchain txs inside (2000 * 2 = 4000)
expect(balance).toEqual('94000');
});
});

describe('Error cases', () => {
test('delegate for unknown validator from second ICA', async () => {
const res = await neutronAccount.executeContract(
Expand Down
Loading