Skip to content

Commit 6e2e65b

Browse files
authored
Merge pull request #281 from neutron-org/feat/slinky
2 parents 1705818 + 82f6016 commit 6e2e65b

13 files changed

+644
-20
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"scripts": {
77
"test": "yarn test:parallel && yarn test:run_in_band",
88
"test:parallel": "jest -b src/testcases/parallel",
9-
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:globalfee && yarn test:dex_bindings && yarn test:pob",
9+
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:globalfee && yarn test:dex_bindings && yarn test:pob && yarn test:slinky",
1010
"test:simple": "jest -b src/testcases/parallel/simple",
11+
"test:slinky": "jest -b src/testcases/run_in_band/slinky",
1112
"test:stargate_queries": "jest -b src/testcases/parallel/stargate_queries",
1213
"test:interchaintx": "jest -b src/testcases/run_in_band/interchaintx",
1314
"test:interchain_kv_query": "jest -b src/testcases/run_in_band/interchain_kv_query",

setup/.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 16.20.0

setup/Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ build-hermes:
1313
build-relayer:
1414
cd $(APP_DIR)/neutron-query-relayer/ && make build-docker
1515

16-
build-all: build-gaia build-neutron build-hermes build-relayer
16+
build-slinky:
17+
@docker buildx build --load --build-context app=$(APP_DIR)/slinky -t skip-mev/slinky-e2e-oracle -f dockerbuilds/Dockerfile.slinky .
18+
19+
build-all: build-gaia build-neutron build-hermes build-relayer build-slinky
1720

1821
start-cosmopark:
1922
@$(COMPOSE) up -d

setup/docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
- 8090:9090
1313
environment:
1414
- RUN_BACKGROUND=0
15+
- ORACLE_ADDRESS=oracle:8080
1516
networks:
1617
- neutron-testing
1718

@@ -78,6 +79,21 @@ services:
7879
networks:
7980
- neutron-testing
8081

82+
oracle:
83+
image: skip-mev/slinky-e2e-oracle
84+
entrypoint: [
85+
"slinky",
86+
"--oracle-config-path",
87+
"/oracle/oracle.json",
88+
"--market-config-path",
89+
"/oracle/market.json",
90+
]
91+
ports:
92+
- "8080:8080" # main oracle port
93+
- "8002:8002" # oracle metrics port
94+
networks:
95+
- neutron-testing
96+
8197
volumes:
8298
data:
8399
name: neutron-testing-data

setup/dockerbuilds/Dockerfile.slinky

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.22-bullseye AS builder
2+
3+
WORKDIR /src/slinky
4+
COPY --from=app go.mod .
5+
6+
RUN go mod download
7+
8+
COPY --from=app . .
9+
10+
RUN make build
11+
12+
FROM ubuntu:rolling
13+
EXPOSE 8080
14+
EXPOSE 8002
15+
16+
COPY --from=builder /src/slinky/build/* /usr/local/bin/
17+
COPY --from=builder /src/slinky/config/local/* /oracle/
18+
RUN apt-get update && apt-get install ca-certificates -y
19+
20+
WORKDIR /usr/local/bin/
21+
ENTRYPOINT ["slinky", "--oracle-config-path", "/oracle/oracle.json", "--market-config-path", "/oracle/market.json"]

src/helpers/gaia.ts

+59
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@ import {
33
MsgDelegate,
44
MsgUndelegate,
55
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/staking/v1beta1/tx_pb';
6+
import {
7+
MsgSubmitProposal,
8+
MsgVote,
9+
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/gov/v1beta1/tx_pb';
610
import {
711
packAnyMsg,
812
WalletWrapper,
913
} from '@neutron-org/neutronjsplus/dist/cosmos';
1014
import Long from 'long';
15+
import {
16+
TextProposal,
17+
VoteOption,
18+
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/gov/v1beta1/gov_pb';
1119

1220
export const msgDelegate = async (
1321
wallet: WalletWrapper,
@@ -48,5 +56,56 @@ export const msgUndelegate = async (
4856
},
4957
[packAnyMsg('/cosmos.staking.v1beta1.MsgUndelegate', msgUndelegate)],
5058
);
59+
60+
return res?.tx_response;
61+
};
62+
63+
export const msgSubmitProposal = async (
64+
wallet: WalletWrapper,
65+
proposer: string,
66+
amount = '0',
67+
): Promise<BroadcastTx200ResponseTxResponse> => {
68+
const msgSubmitProposal = new MsgSubmitProposal({
69+
proposer,
70+
content: {
71+
typeUrl: '/cosmos.gov.v1beta1.TextProposal',
72+
value: new TextProposal({
73+
title: 'mock',
74+
description: 'mock',
75+
}).toBinary(),
76+
},
77+
initialDeposit: [{ denom: wallet.chain.denom, amount: '10000000' }],
78+
});
79+
const res = await wallet.execTx(
80+
{
81+
gas_limit: Long.fromString('500000'),
82+
amount: [{ denom: wallet.chain.denom, amount: amount }],
83+
},
84+
[packAnyMsg('/cosmos.gov.v1beta1.MsgSubmitProposal', msgSubmitProposal)],
85+
);
86+
87+
return res?.tx_response;
88+
};
89+
90+
export const msgVote = async (
91+
wallet: WalletWrapper,
92+
voter: string,
93+
proposalId: number,
94+
amount = '0',
95+
): Promise<BroadcastTx200ResponseTxResponse> => {
96+
const msgVote = new MsgVote({
97+
voter,
98+
proposalId: BigInt(proposalId),
99+
option: VoteOption.YES,
100+
});
101+
102+
const res = await wallet.execTx(
103+
{
104+
gas_limit: Long.fromString('500000'),
105+
amount: [{ denom: wallet.chain.denom, amount: amount }],
106+
},
107+
[packAnyMsg('/cosmos.gov.v1beta1.MsgVote', msgVote)],
108+
);
109+
51110
return res?.tx_response;
52111
};

src/testcases/parallel/overrule.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616

1717
const config = require('../../config.json');
1818

19-
describe('Neutron / Subdao', () => {
19+
describe('Neutron / Subdao Overrule', () => {
2020
let testState: TestStateLocalCosmosTestNet;
2121
let neutronChain: CosmosWrapper;
2222
let neutronAccount1: WalletWrapper;

src/testcases/parallel/subdao.test.ts

+88-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@ import {
1818
TimelockConfig,
1919
TimelockProposalListResponse,
2020
} from '@neutron-org/neutronjsplus/dist/dao';
21-
import { Wallet } from '@neutron-org/neutronjsplus/dist/types';
21+
import {
22+
SingleChoiceProposal,
23+
Wallet,
24+
} from '@neutron-org/neutronjsplus/dist/types';
2225
import { BroadcastTx200ResponseTxResponse } from '@cosmos-client/core/cjs/openapi/api';
2326
import cosmosclient from '@cosmos-client/core';
24-
import { waitSeconds } from '@neutron-org/neutronjsplus/dist/wait';
27+
import {
28+
getWithAttempts,
29+
waitSeconds,
30+
} from '@neutron-org/neutronjsplus/dist/wait';
2531
import {
2632
paramChangeProposal,
2733
sendProposal,
@@ -480,6 +486,86 @@ describe('Neutron / Subdao', () => {
480486
});
481487
});
482488

489+
describe('Timelock3: Closed overruled proposal should not prevent execution', () => {
490+
let proposalId: number;
491+
beforeAll(async () => {
492+
proposalId = await subdaoMember1.submitUpdateSubDaoConfigProposal(
493+
{
494+
name: 'dao name after timelock3',
495+
},
496+
'single2',
497+
);
498+
499+
// move proposal to the timelocked state where it can be overruled
500+
const timelockedProp = await subdaoMember1.supportAndExecuteProposal(
501+
proposalId,
502+
'single2',
503+
);
504+
505+
expect(timelockedProp.id).toEqual(proposalId);
506+
expect(timelockedProp.status).toEqual('timelocked');
507+
expect(timelockedProp.msgs).toHaveLength(1);
508+
});
509+
510+
test('close rejected overrule proposal', async () => {
511+
const overruleProposalId = await mainDao.getOverruleProposalId(
512+
subDao.contracts.proposals.single2.pre_propose.timelock!.address,
513+
proposalId,
514+
);
515+
516+
// wait 20 seconds
517+
await waitSeconds(20);
518+
519+
const propOverruledTest =
520+
await mainDao.chain.queryContract<SingleChoiceProposal>(
521+
mainDaoMember.dao.contracts.proposals.overrule?.address,
522+
{
523+
proposal: {
524+
proposal_id: overruleProposalId,
525+
},
526+
},
527+
);
528+
expect(propOverruledTest.proposal.status).toEqual('rejected');
529+
530+
await subdaoMember1.user.executeContract(
531+
mainDaoMember.dao.contracts.proposals.overrule.address,
532+
JSON.stringify({
533+
close: { proposal_id: overruleProposalId },
534+
}),
535+
);
536+
537+
const propOverruledTest2 = await getWithAttempts(
538+
neutronChain.blockWaiter,
539+
async () =>
540+
await mainDao.chain.queryContractWithWait<SingleChoiceProposal>(
541+
mainDaoMember.dao.contracts.proposals.overrule?.address,
542+
{
543+
proposal: {
544+
proposal_id: overruleProposalId,
545+
},
546+
},
547+
),
548+
async (p) => p.proposal.status === 'closed',
549+
5,
550+
);
551+
552+
expect(propOverruledTest2.proposal.status).toEqual('closed');
553+
});
554+
555+
test('execute timelocked: success', async () => {
556+
await waitSeconds(20);
557+
await subdaoMember1.executeTimelockedProposal(proposalId, 'single2');
558+
559+
const timelockedProp = await subDao.getTimelockedProposal(
560+
proposalId,
561+
'single2',
562+
);
563+
expect(timelockedProp.id).toEqual(proposalId);
564+
expect(timelockedProp.status).toEqual('executed');
565+
expect(timelockedProp.msgs).toHaveLength(1);
566+
});
567+
});
568+
483569
describe('Non-timelock typed duration pause proposal: Succeed creation', () => {
484570
let proposalId: number;
485571

src/testcases/run_in_band/dex_bindings.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ describe('Neutron / dex module bindings', () => {
548548
);
549549
console.log(resp);
550550
expect(Number(resp.deposits[0].total_shares)).toBeGreaterThan(0);
551-
expect(Number(resp.deposits[0].pool!.id)).toEqual(0);
551+
expect(Number(resp.deposits[0].pool.id)).toEqual(0);
552552

553553
const respNoPoolData =
554554
await neutronAccount.chain.queryContract<AllUserDepositsResponse>(

src/testcases/run_in_band/dex_stargate.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ describe('Neutron / dex module (stargate contract)', () => {
467467
);
468468
console.log(resp);
469469
expect(Number(resp.deposits[0].total_shares)).toBeGreaterThan(0);
470-
expect(Number(resp.deposits[0].pool!.id)).toEqual(0);
470+
expect(Number(resp.deposits[0].pool.id)).toEqual(0);
471471

472472
const respNoPoolData =
473473
await neutronAccount.chain.queryContract<AllUserDepositsResponse>(

0 commit comments

Comments
 (0)