Skip to content

Commit

Permalink
feat: initia new version
Browse files Browse the repository at this point in the history
  • Loading branch information
ratik committed Nov 4, 2024
1 parent a1c1e70 commit acd3ea5
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 75 deletions.
53 changes: 22 additions & 31 deletions integration_tests/dockerfiles/initia/Dockerfile.x86
Original file line number Diff line number Diff line change
@@ -1,46 +1,37 @@
# Stage 1: Build the Go project
FROM golang:1.22-alpine3.19 AS go-builder
#ARG arch=x86_64

# See https://github.com/initia-labs/movevm/releases
ENV LIBMOVEVM_VERSION=v0.2.8
# Use build arguments for the target architecture
ARG TARGETARCH=amd64
ARG GOARCH

# this comes from standard alpine nightly file
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
# with some changes to support our toolchain, etc
RUN set -eux; apk add --no-cache ca-certificates build-base;
# See https://github.com/initia-labs/movevm/releases
ENV LIBMOVEVM_VERSION=v0.6.0

RUN apk add git cmake
# NOTE: add these to run with LEDGER_ENABLED=true
# RUN apk add libusb-dev linux-headers
# Install necessary packages
RUN set -eux; apk add --no-cache ca-certificates build-base git cmake

WORKDIR /code
COPY . /code/

RUN go mod edit -replace=github.com/cosmos/ibc-go/v8@v8.2.0=github.com/ratik/ibc-go/v8@v8.2.0-debug
RUN go mod tidy

# Install mimalloc
RUN git clone --depth 1 https://github.com/microsoft/mimalloc; cd mimalloc; mkdir build; cd build; cmake ..; make -j$(nproc); make install
ENV MIMALLOC_RESERVE_HUGE_OS_PAGES=4

# See https://github.com/initia-labs/movevm/releases
ADD https://github.com/initia-labs/movevm/releases/download/${LIBMOVEVM_VERSION}/libmovevm_muslc.aarch64.a /lib/libmovevm_muslc.aarch64.a
ADD https://github.com/initia-labs/movevm/releases/download/${LIBMOVEVM_VERSION}/libmovevm_muslc.x86_64.a /lib/libmovevm_muslc.x86_64.a
ADD https://github.com/initia-labs/movevm/releases/download/${LIBMOVEVM_VERSION}/libcompiler_muslc.aarch64.a /lib/libcompiler_muslc.aarch64.a
ADD https://github.com/initia-labs/movevm/releases/download/${LIBMOVEVM_VERSION}/libcompiler_muslc.x86_64.a /lib/libcompiler_muslc.x86_64.a

# Highly recommend to verify the version hash
# RUN sha256sum /lib/libmovevm_muslc.aarch64.a | grep a5e63292ec67f5bdefab51b42c3fbc3fa307c6aefeb6b409d971f1df909c3927
# RUN sha256sum /lib/libmovevm_muslc.x86_64.a | grep 762307147bf8f550bd5324b7f7c4f17ee20805ff93dc06cc073ffbd909438320
# RUN sha256sum /lib/libcompiler_muslc.aarch64.a | grep a5e63292ec67f5bdefab51b42c3fbc3fa307c6aefeb6b409d971f1df909c3927
# RUN sha256sum /lib/libcompiler_muslc.x86_64.a | grep 762307147bf8f550bd5324b7f7c4f17ee20805ff93dc06cc073ffbd909438320

# Copy the library you want to the final location that will be found by the linker flag `-linitia_muslc`
RUN cp /lib/libmovevm_muslc.`uname -m`.a /lib/libmovevm_muslc.a
RUN cp /lib/libcompiler_muslc.`uname -m`.a /lib/libcompiler_muslc.a

# force it to use static lib (from above) not standard libmovevm.so and libcompiler.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS="-linkmode=external -extldflags \"-L/code/mimalloc/build -lmimalloc -Wl,-z,muldefs -static\"" make build
# Determine GOARCH and download the appropriate libraries
RUN set -eux; \
case "${TARGETARCH}" in \
"amd64") export GOARCH="amd64"; ARCH="x86_64";; \
"arm64") export GOARCH="arm64"; ARCH="aarch64";; \
*) echo "Unsupported architecture: ${TARGETARCH}"; exit 1;; \
esac; \
echo "Using GOARCH=${GOARCH} and ARCH=${ARCH}"; \
wget -O /lib/libmovevm_muslc.${ARCH}.a https://github.com/initia-labs/movevm/releases/download/${LIBMOVEVM_VERSION}/libmovevm_muslc.${ARCH}.a; \
wget -O /lib/libcompiler_muslc.${ARCH}.a https://github.com/initia-labs/movevm/releases/download/${LIBMOVEVM_VERSION}/libcompiler_muslc.${ARCH}.a; \
cp /lib/libmovevm_muslc.${ARCH}.a /lib/libmovevm_muslc.a; \
cp /lib/libcompiler_muslc.${ARCH}.a /lib/libcompiler_muslc.a

RUN LEDGER_ENABLED=false BUILD_TAGS=muslc GOARCH=${GOARCH} LDFLAGS="-linkmode=external -extldflags \"-L/code/mimalloc/build -lmimalloc -Wl,-z,muldefs -static\"" make build

FROM alpine:3.19

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dockerfiles/initia/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ echo "Building initia-test docker image"
DIR="$(dirname $0)"
cd $DIR
VERSION=$(cat ../../package.json | jq -r '.version')
git clone https://github.com/initia-labs/initia -b v0.2.15
git clone https://github.com/initia-labs/initia

# Copy Dockerfile to initia directory for arm and Dockerfile.x86 for x86
if [[ "$(arch)" == "arm64" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drop-cosmos-integration-tests",
"version": "1.0.8",
"version": "1.0.18",
"main": "vitest",
"license": "MIT",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"@cosmjs/tendermint-rpc": "^0.32.4",
"@initia/initia.js": "^0.2.16",
"@neutron-org/client-ts": "^1.4.0",
"@neutron-org/cosmopark": "^1.7.3",
"@neutron-org/cosmopark": "^1.7.9",
"bech32": "^1.1.4",
"bech32-buffer": "0.2.1",
"decimal.js": "^10.4.3",
Expand All @@ -63,4 +63,4 @@
},
"description": "Drop on Cosmos integration test",
"repository": "git@github.com:hadronlabs-org/lionco-contracts.git"
}
}
2 changes: 1 addition & 1 deletion integration_tests/src/testSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ export const setupPark = async (
context,
networks: {},
master_mnemonic: wallets.master,
loglevel: 'info',
loglevel: 'debug',
wallets: {
demowallet1: {
mnemonic: wallets.demowallet1,
Expand Down
107 changes: 72 additions & 35 deletions integration_tests/src/testcases/initia.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe('Core', () => {
(
await context.park.executeInNetwork(
'initia',
`initiad query move view 0x1 coin metadata --args "address:0x1 string:${context.initiaNTRN}" --output=json`,
`initiad query move view 0x1 coin metadata --args '["address:0x1", "string:${context.initiaNTRN}"]' --output=json`,
)
).out,
).data,
Expand All @@ -284,21 +284,19 @@ describe('Core', () => {
(
await context.park.executeInNetwork(
'initia',
`initiad query move view 0x1 coin metadata --args "address:0x1 string:uinit" --output=json`,
`initiad query move view 0x1 coin metadata --args '["address:0x1", "string:uinit"]' --output=json`,
)
).out,
).data,
);

const createPairTx = JSON.parse(
(
await context.park.executeInNetwork(
'initia',
`initiad tx move execute 0x1 dex create_pair_script --args "string:name string:INIT_NTRN decimal128:0.001 decimal128:0.5 decimal128:0.5 object:${initiaUINITmetadata} object:${initiaNTRNmetadata} u64:9000000 u64:9000000" --from=demo1 --keyring-backend=test --home=/opt --chain-id=${context.park.config.networks['initia'].chain_id} --fees 3000000uinit --gas=2000000 --output=json -y`,
`initiad tx move execute 0x1 dex create_pair_script --args '["string:name", "string:INIT_NTRN", "bigdecimal:0.001", "bigdecimal:0.5", "bigdecimal:0.5", "object:${initiaUINITmetadata}", "object:${initiaNTRNmetadata}", "u64:9000000", "u64:9000000"]' --from=demo1 --keyring-backend=test --home=/opt --chain-id=${context.park.config.networks['initia'].chain_id} --fees 3000000uinit --gas=2000000 --output=json -y`,
)
).out,
);

await sleep(3_000);

const createPairRes = JSON.parse(
Expand Down Expand Up @@ -448,7 +446,9 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(join(__dirname, '../../../artifacts/drop_core.wasm')),
Uint8Array.from(
fs.readFileSync(join(__dirname, '../../../artifacts/drop_core.wasm')),
),
1.5,
);
expect(res.codeId).toBeGreaterThan(0);
Expand All @@ -457,7 +457,11 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(join(__dirname, '../../../artifacts/drop_token.wasm')),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_token.wasm'),
),
),
1.5,
);
expect(res.codeId).toBeGreaterThan(0);
Expand All @@ -466,8 +470,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_withdrawal_voucher.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_withdrawal_voucher.wasm'),
),
),
1.5,
);
Expand All @@ -477,8 +483,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_withdrawal_manager.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_withdrawal_manager.wasm'),
),
),
1.5,
);
Expand All @@ -488,7 +496,9 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(join(__dirname, '../../../artifacts/drop_pump.wasm')),
Uint8Array.from(
fs.readFileSync(join(__dirname, '../../../artifacts/drop_pump.wasm')),
),
1.5,
);
expect(res.codeId).toBeGreaterThan(0);
Expand All @@ -497,8 +507,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_strategy.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_strategy.wasm'),
),
),
1.5,
);
Expand All @@ -508,8 +520,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_distribution.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_distribution.wasm'),
),
),
1.5,
);
Expand All @@ -519,8 +533,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_validators_set.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_validators_set.wasm'),
),
),
1.5,
);
Expand All @@ -530,8 +546,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_puppeteer_initia.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_puppeteer_initia.wasm'),
),
),
1.5,
);
Expand All @@ -541,8 +559,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_rewards_manager.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_rewards_manager.wasm'),
),
),
1.5,
);
Expand All @@ -552,8 +572,10 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_splitter.wasm'),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_splitter.wasm'),
),
),
1.5,
);
Expand All @@ -563,10 +585,12 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(
__dirname,
'../../../artifacts/drop_lsm_share_bond_provider.wasm',
Uint8Array.from(
fs.readFileSync(
join(
__dirname,
'../../../artifacts/drop_lsm_share_bond_provider.wasm',
),
),
),
1.5,
Expand All @@ -577,8 +601,13 @@ describe('Core', () => {
{
const res = await client.upload(
account.address,
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_native_bond_provider.wasm'),
Uint8Array.from(
fs.readFileSync(
join(
__dirname,
'../../../artifacts/drop_native_bond_provider.wasm',
),
),
),
1.5,
);
Expand All @@ -588,7 +617,11 @@ describe('Core', () => {

const res = await client.upload(
account.address,
fs.readFileSync(join(__dirname, '../../../artifacts/drop_factory.wasm')),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_factory.wasm'),
),
),
1.5,
);
expect(res.codeId).toBeGreaterThan(0);
Expand Down Expand Up @@ -1123,7 +1156,11 @@ describe('Core', () => {
const { client, account, neutronUserAddress } = context;
const resUpload = await client.upload(
account.address,
fs.readFileSync(join(__dirname, '../../../artifacts/drop_pump.wasm')),
Uint8Array.from(
fs.readFileSync(
join(__dirname, '../../../artifacts/drop_pump.wasm'),
),
),
1.5,
);
expect(resUpload.codeId).toBeGreaterThan(0);
Expand Down Expand Up @@ -1715,15 +1752,15 @@ describe('Core', () => {
(
await context.park.executeInNetwork(
'initia',
`initiad query move view 0x1 coin metadata --args "address:0x1 string:uinit" --output=json`,
`initiad query move view 0x1 coin metadata --args '["address:0x1", "string:uinit"]' --output=json`,
)
).out,
).data,
);

await context.park.executeInNetwork(
'initia',
`initiad tx move execute 0x1 dex single_asset_provide_liquidity_script --args "object:${context.moveToken.metadataAddr} object:${initiaUINITmetadata} u64:${newBalance - oldBalance} option<u64>:1" --from=demo3 --home=/opt --chain-id=${context.park.config.networks['initia'].chain_id} --keyring-backend=test --fees=50000uinit --gas 300000 -y`,
`initiad tx move execute 0x1 dex single_asset_provide_liquidity_script --args '["object:${context.moveToken.metadataAddr}", "object:${initiaUINITmetadata}", "u64:${newBalance - oldBalance}", "option<u64>:1"]' --from=demo3 --home=/opt --chain-id=${context.park.config.networks['initia'].chain_id} --keyring-backend=test --fees=50000uinit --gas 300000 -y`,
);

await sleep(10_000);
Expand Down Expand Up @@ -1848,7 +1885,7 @@ describe('Core', () => {
{ denom: context.moveIBCDenom },
)
).data.balance.amount;
expect(parseInt(nativeBondProviderBalance, 10)).toEqual(170000);
expect(parseInt(nativeBondProviderBalance, 10)).toEqual(150000);
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,10 @@
lodash "^4.17.21"
node-recursive-directory "^1.2.0"

"@neutron-org/cosmopark@^1.7.3":
version "1.7.3"
resolved "https://registry.yarnpkg.com/@neutron-org/cosmopark/-/cosmopark-1.7.3.tgz#0bf2da78100bb690ffc537b9048cbeab16eedd2b"
integrity sha512-V/EDCw6FB30+l0PFkO4JhD3fk6tskgxTkOy30k8X51wuYrVQx3MEGxG71Vwq424GNU6R6AGQgMIbMTAg+SOzDA==
"@neutron-org/cosmopark@^1.7.9":
version "1.7.9"
resolved "https://registry.yarnpkg.com/@neutron-org/cosmopark/-/cosmopark-1.7.9.tgz#251d9fb89da9b77fd5e5e0ce7ca3a7241e5b2cb4"
integrity sha512-kQw5oRoAFUBkryrqFjAe/taLdMKIDxxBV9nkd6PgIaIRm3aY5AX0t/yPVROdaGZBculN/UKNaLMp31w/bGiMIA==
dependencies:
"@iarna/toml" "^2.2.5"
commander "^11.0.0"
Expand Down

0 comments on commit acd3ea5

Please sign in to comment.