Skip to content

Commit

Permalink
runtime 2250 (#997)
Browse files Browse the repository at this point in the history
* mandala 2250

* update hash

* update e2e tests

* test

* fix

* update snapshot

* use larger share

* fix
  • Loading branch information
shunjizhan authored May 8, 2024
1 parent 86e0924 commit 2616302
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 74 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ services:
# ---------- No Subql Realm ---------- #
# ------------------------------------ #
mandala-node:
image: ghcr.io/acalanetwork/mandala-node:sha-89ef1e5
image: ghcr.io/acalanetwork/mandala-node:sha-16f147e
ports:
- 9944:9944
healthcheck:
Expand Down
2 changes: 1 addition & 1 deletion examples/docker-compose-bodhi-stack.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
mandala-node:
image: ghcr.io/acalanetwork/mandala-node:sha-89ef1e5
image: ghcr.io/acalanetwork/mandala-node:sha-16f147e
container_name: mandala-node
ports:
- 9944:9944
Expand Down
2 changes: 1 addition & 1 deletion examples/viem/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
mandala-node:
image: ghcr.io/acalanetwork/mandala-node:sha-89ef1e5
image: ghcr.io/acalanetwork/mandala-node:sha-16f147e
container_name: mandala-node
ports:
- 9944:9944
Expand Down
2 changes: 0 additions & 2 deletions examples/waffle/evm/test/EVM.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ describe('EVM', () => {
expect((await evm.developerDeposit()).toString()).to.equal(formatAmount('1_000_000_000_000_000_000'));

expect((await evm.publicationFee()).toString()).to.equal(formatAmount('1_000_000_000_000_000_000'));

await evmPredeployed.publishContract(evm.address);
} else {
expect(await evm.newContractExtraBytes()).to.equal(0);

Expand Down
29 changes: 15 additions & 14 deletions examples/waffle/incentives/test/incentives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('incentives', () => {
});

it('incentives getClaimRewardDeductionRate works', async () => {
const Rate = FixedU128.div(BigNumber.from('10')); // 1/10
const newRate = FixedU128.div(BigNumber.from('10')).toBigInt(); // 1/10
const updateClaimRewardDeductionRates = provider.api.tx.sudo.sudo(
provider.api.tx.incentives.updateClaimRewardDeductionRates([
[
Expand All @@ -84,13 +84,14 @@ describe('incentives', () => {
DexShare: [{ Token: 'ACA' }, { Token: 'AUSD' }]
}
},
Rate.toBigInt()
newRate
]
])
);
await send(updateClaimRewardDeductionRates, wallet.substrateAddress);

expect(await incentives.getClaimRewardDeductionRate(1, ADDRESS.LP_ACA_AUSD)).to.equal(Rate);
const curRate = await incentives.getClaimRewardDeductionRate(1, ADDRESS.LP_ACA_AUSD);
expect(curRate.toBigInt()).to.equal(newRate);
});

it('incentives getPendingRewards works', async () => {
Expand Down Expand Up @@ -123,14 +124,14 @@ describe('incentives', () => {
{
DexShare: [{ Token: 'ACA' }, { Token: 'AUSD' }]
},
1_000_000_000
1_000_000_000_000
)
);
await send(updateBalance, wallet.substrateAddress);

await expect(incentivesPredeployed.depositDexShare(ADDRESS.LP_ACA_AUSD, 1000))
await expect(incentivesPredeployed.depositDexShare(ADDRESS.LP_ACA_AUSD, 1_000_000_000_000))
.to.emit(incentivesPredeployed, 'DepositedShare')
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1000);
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1_000_000_000_000);
});

it('incentives withdrawDexShare works', async () => {
Expand All @@ -140,18 +141,18 @@ describe('incentives', () => {
{
DexShare: [{ Token: 'ACA' }, { Token: 'AUSD' }]
},
1_000_000_000
1_000_000_000_000
)
);
await send(updateBalance, wallet.substrateAddress);

await expect(incentivesPredeployed.depositDexShare(ADDRESS.LP_ACA_AUSD, 1000))
await expect(incentivesPredeployed.depositDexShare(ADDRESS.LP_ACA_AUSD, 1_000_000_000_000))
.to.emit(incentivesPredeployed, 'DepositedShare')
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1000);
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1_000_000_000_000);

await expect(incentivesPredeployed.withdrawDexShare(ADDRESS.LP_ACA_AUSD, 1000))
await expect(incentivesPredeployed.withdrawDexShare(ADDRESS.LP_ACA_AUSD, 1_000_000_000_000))
.to.emit(incentivesPredeployed, 'WithdrewShare')
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1000);
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1_000_000_000_000);
});

it('incentives claimRewards works', async () => {
Expand All @@ -161,14 +162,14 @@ describe('incentives', () => {
{
DexShare: [{ Token: 'ACA' }, { Token: 'AUSD' }]
},
1_000_000_000
1_000_000_000_000
)
);
await send(updateBalance, wallet.substrateAddress);

await expect(incentivesPredeployed.depositDexShare(ADDRESS.LP_ACA_AUSD, 1000))
await expect(incentivesPredeployed.depositDexShare(ADDRESS.LP_ACA_AUSD, 1_000_000_000_000))
.to.emit(incentivesPredeployed, 'DepositedShare')
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1000);
.withArgs(await wallet.getAddress(), ADDRESS.LP_ACA_AUSD, 1_000_000_000_000);

await expect(incentivesPredeployed.claimRewards(1, ADDRESS.LP_ACA_AUSD))
.to.emit(incentivesPredeployed, 'ClaimedRewards')
Expand Down
2 changes: 1 addition & 1 deletion packages/eth-rpc-adapter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A node service that provides [JSON-RPC](https://eth.wiki/json-rpc/API) for [Acal
## Run
First run a Mandala node locally
```
docker run -it --rm -p 9944:9944 ghcr.io/acalanetwork/mandala-node:sha-89ef1e5 --dev --rpc-external --rpc-cors=all --rpc-methods=unsafe -levm=debug --pruning=archive --instant-sealing
docker run -it --rm -p 9944:9944 ghcr.io/acalanetwork/mandala-node:sha-16f147e --dev --rpc-external --rpc-cors=all --rpc-methods=unsafe -levm=debug --pruning=archive --instant-sealing
```

Then there are 3 ways to run an RPC adapter:
Expand Down
2 changes: 1 addition & 1 deletion packages/eth-rpc-adapter/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
mandala-node:
image: ghcr.io/acalanetwork/mandala-node:sha-89ef1e5
image: ghcr.io/acalanetwork/mandala-node:sha-16f147e
ports:
- 9944:9944
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ exports[`endpoint > eth_getTransactionByHash > finds correct tx when hash exist
{
"blockNumber": "0xa",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gas": "0x1fd91",
"gasPrice": "0x25315050b1",
"gas": "0x1fcfa",
"gasPrice": "0x25592c5c5f",
"input": "0x3d8d96200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000e8d4a51000000000000000000000000000000000000000000000000000000000e8d4a51000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000001",
"nonce": "0x6",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
Expand All @@ -276,8 +276,8 @@ exports[`endpoint > eth_getTransactionByHash > finds correct tx when hash exist
{
"blockNumber": "0x9",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gas": "0x25a7f",
"gasPrice": "0x22a22ed358",
"gas": "0x25a18",
"gasPrice": "0x22c1d12a54",
"input": "0x3d8d962000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000e8d4a510000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000010000000000000000000000000000000000000000000100000000000000000002",
"nonce": "0x5",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
Expand All @@ -293,8 +293,8 @@ exports[`endpoint > eth_getTransactionByHash > finds correct tx when hash exist
{
"blockNumber": "0x6",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gas": "0x1fdca",
"gasPrice": "0x252f21c079",
"gas": "0x1fd26",
"gasPrice": "0x2557747a01",
"input": "0x6fc4b4e50000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000e8d4a510000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000001",
"nonce": "0x2",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
Expand All @@ -311,7 +311,7 @@ exports[`endpoint > eth_getTransactionByHash > finds correct tx when hash exist
"blockNumber": "0x14",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gas": "0x200b20",
"gasPrice": "0x41d4ad9224",
"gasPrice": "0x419514ca84",
"input": "0x",
"nonce": "0x10",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
Expand Down Expand Up @@ -467,9 +467,9 @@ exports[`endpoint > eth_getTransactionReceipt > returns correct result when hash
"blockNumber": "0xa",
"contractAddress": null,
"cumulativeGasUsed": "0x0",
"effectiveGasPrice": "0x25315050b1",
"effectiveGasPrice": "0x25592c5c5f",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gasUsed": "0x1a8a4",
"gasUsed": "0x1a826",
"logs": [
{
"address": "0x0000000000000000000000000000000000000803",
Expand All @@ -496,9 +496,9 @@ exports[`endpoint > eth_getTransactionReceipt > returns correct result when hash
"blockNumber": "0x9",
"contractAddress": null,
"cumulativeGasUsed": "0x0",
"effectiveGasPrice": "0x22a22ed358",
"effectiveGasPrice": "0x22c1d12a54",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gasUsed": "0x1f615",
"gasUsed": "0x1f5bf",
"logs": [
{
"address": "0x0000000000000000000000000000000000000803",
Expand All @@ -525,9 +525,9 @@ exports[`endpoint > eth_getTransactionReceipt > returns correct result when hash
"blockNumber": "0x6",
"contractAddress": null,
"cumulativeGasUsed": "0x0",
"effectiveGasPrice": "0x252f21c079",
"effectiveGasPrice": "0x2557747a01",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gasUsed": "0x1a8d3",
"gasUsed": "0x1a84b",
"logs": [
{
"address": "0x0000000000000000000000000000000000000803",
Expand All @@ -554,7 +554,7 @@ exports[`endpoint > eth_getTransactionReceipt > returns correct result when hash
"blockNumber": "0x14",
"contractAddress": null,
"cumulativeGasUsed": "0x0",
"effectiveGasPrice": "0x41d4ad9224",
"effectiveGasPrice": "0x419514ca84",
"from": "0x82a258cb20e2adb4788153cd5eb5839615ece9a0",
"gasUsed": "0xcbbd",
"logs": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ describe('endpoint', () => {

describe('eth_getBalance', () => {
it('get correct balance', async () => {
const block8Balance = 8999995192313663934000000n; // edit me for different mandala version
const block8Balance = 8999995192165097994000000n; // edit me for different mandala version
expect(BigInt((await eth_getBalance([ADDRESS_ALICE, 8])).data.result)).to.equal(block8Balance);
expect(BigInt((await eth_getBalance([ADDRESS_ALICE, '0x8'])).data.result)).to.equal(block8Balance);
expect(BigInt((await eth_getBalance([ADDRESS_ALICE, { blockNumber: 8 }])).data.result)).to.equal(block8Balance);
Expand Down
2 changes: 1 addition & 1 deletion packages/evm-subql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ npm i -g @subql/[email protected] @subql/[email protected]
If you already have a node running elsewhere, you can skip this step.

```shell
docker run -it --rm -p 9944:9944 ghcr.io/acalanetwork/mandala-node:sha-89ef1e5 --dev --rpc-external --rpc-cors=all --rpc-methods=unsafe -levm=debug --pruning=archive --instant-sealing
docker run -it --rm -p 9944:9944 ghcr.io/acalanetwork/mandala-node:sha-16f147e --dev --rpc-external --rpc-cors=all --rpc-methods=unsafe -levm=debug --pruning=archive --instant-sealing
```

3. Run a Postgres service and listen to port number 5432 (in the second terminal)
Expand Down
2 changes: 1 addition & 1 deletion packages/evm-subql/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.9'

services:
mandala-node:
image: ghcr.io/acalanetwork/mandala-node:sha-89ef1e5
image: ghcr.io/acalanetwork/mandala-node:sha-16f147e
ports:
- 9944:9944
healthcheck:
Expand Down
2 changes: 1 addition & 1 deletion packages/evm-subql/project-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const PROJECT_PARAMS = {
startBlock: 1,
},
localMandala: {
chainId: '0x8837eb25f126806eca5012c67621cca1c04fadb6c93b3488e63fe94f872e2387',
chainId: '0xfed39d074b506cd8979ba50d64489dd11226eef1275917de229642edd4cec132',
endpoint: ['ws://localhost:9944'],
startBlock: 1,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/evm-subql/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ runner:
schema:
file: ./schema.graphql
network:
chainId: '0x8837eb25f126806eca5012c67621cca1c04fadb6c93b3488e63fe94f872e2387'
chainId: '0xfed39d074b506cd8979ba50d64489dd11226eef1275917de229642edd4cec132'
endpoint:
- ws://localhost:9944
chaintypes:
Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e-tests/configs/acala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ endpoint: wss://acala-rpc.aca-api.network
mock-signature-host: true
# block: 2694000
db: ./db.sqlite
wasm-override: ./wasm/acala-2240.wasm
wasm-override: ./wasm/acala-2250.wasm

import-storage:
Sudo:
Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e-tests/configs/karura.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ endpoint: wss://karura-rpc.aca-api.network
mock-signature-host: true
# block: 3000000
db: ./db.sqlite
wasm-override: ./wasm/karura-2240.wasm
wasm-override: ./wasm/karura-2250.wasm

import-storage:
Sudo:
Expand Down
20 changes: 10 additions & 10 deletions scripts/e2e-tests/configs/subql/acala.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# // Auto-generated , DO NOT EDIT
specVersion: 1.0.0
version: 0.0.1
name: '@acala-network/evm-subql'
version: 1.0.0
description: subquery for Acala EVM+
runner:
node:
name: '@subql/node'
version: 1.21.2
version: '>=3.0.1'
query:
name: '@subql/query'
version: 1.4.0
description: 'subquery for Acala EVM+'
repository: 'https://github.com/AcalaNetwork/bodhi.js/tree/master/evm-subql'
version: '*'
schema:
file: ./schema.graphql
network:
# Acala
chainId: '0xfc41b9bd8ef8fe53d58c7ea67c794c7ec9a73daf05e6d54b14ff6342c99ba64c'
endpoint: ws://chopsticks:8000
endpoint:
- ws://chopsticks:8000
chaintypes:
file: ./dist/chain-types/index.js
dataSources:
- kind: substrate/Runtime
startBlock: 5108461
startBlock: 6134893
mapping:
file: ./dist/index.js
handlers:
- handler: handleBlock
kind: substrate/BlockHandler
- kind: substrate/BlockHandler
handler: handleBlock
20 changes: 10 additions & 10 deletions scripts/e2e-tests/configs/subql/karura.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
# // Auto-generated , DO NOT EDIT
specVersion: 1.0.0
version: 0.0.1
name: '@acala-network/evm-subql'
version: 1.0.0
description: subquery for Acala EVM+
runner:
node:
name: '@subql/node'
version: 1.21.2
version: '>=3.0.1'
query:
name: '@subql/query'
version: 1.4.0
description: 'subquery for Karura EVM+'
repository: 'https://github.com/AcalaNetwork/bodhi.js/tree/master/evm-subql'
version: '*'
schema:
file: ./schema.graphql
network:
# Karura
chainId: '0xbaf5aabe40646d11f0ee8abbdc64f4a4b7674925cba08e4a05ff9ebed6e2126b'
endpoint: ws://chopsticks:8000
endpoint:
- ws://chopsticks:8000
chaintypes:
file: ./dist/chain-types/index.js
dataSources:
- kind: substrate/Runtime
startBlock: 5853808
startBlock: 6834574
mapping:
file: ./dist/index.js
handlers:
- handler: handleBlock
kind: substrate/BlockHandler
- kind: substrate/BlockHandler
handler: handleBlock
Loading

0 comments on commit 2616302

Please sign in to comment.