Skip to content

Commit

Permalink
runtime 2230 (#896)
Browse files Browse the repository at this point in the history
* runtime 2230

* fix test

* fix

* e2e tested 2230 wasm
  • Loading branch information
shunjizhan committed Dec 5, 2023
1 parent afa754f commit 3097d7e
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 41 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ services:
# ---------- No Subql Realm ---------- #
# ------------------------------------ #
mandala-node:
image: ghcr.io/acalanetwork/mandala-node:sha-37d9e36
image: ghcr.io/acalanetwork/mandala-node:sha-7ae4bf4
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-37d9e36
image: ghcr.io/acalanetwork/mandala-node:sha-7ae4bf4
container_name: mandala-node
ports:
- 9944:9944
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('TransactionReceipt', async () => {

/** transfer aca */
console.log('transfer aca');
const extrinsic = provider.api.tx.balances.transfer(account1.defaultSubstrateAddress, 100n * oneAca);
const extrinsic = provider.api.tx.balances.transferAllowDeath(account1.defaultSubstrateAddress, 100n * oneAca);
await extrinsic.signAsync(Alice);
await sendTx(provider.api, extrinsic);

Expand Down
39 changes: 10 additions & 29 deletions packages/eth-providers/src/__tests__/e2e/tx.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { AcalaEvmTX, parseTransaction, serializeTransaction, signTransaction } from '@acala-network/eth-transactions';
import { BigNumber } from '@ethersproject/bignumber';
import { Contract } from '@ethersproject/contracts';
import { EvmRpcProvider } from '../../rpc-provider';
import { Interface, parseUnits } from 'ethers/lib/utils';
import { Wallet } from '@ethersproject/wallet';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { calcEthereumTransactionParams, sendTx, sleep } from '../../utils';
import { computeDefaultSubstrateAddress } from '../../utils/address';
import { createTestPairs } from '@polkadot/keyring/testingPairs';
import ACAABI from '@acala-network/contracts/build/contracts/Token.json';
import ADDRESS from '@acala-network/contracts/utils/MandalaAddress';
import dotenv from 'dotenv';

import { EvmRpcProvider } from '../../rpc-provider';
import { calcEthereumTransactionParams, sleep } from '../../utils';
import { computeDefaultSubstrateAddress } from '../../utils/address';
import evmAccounts from '../evmAccounts';
import type { UInt } from '@polkadot/types';

dotenv.config();

Expand All @@ -38,8 +37,8 @@ describe('transaction tests', () => {
await provider.isReady();

chainId = await provider.chainId();
storageByteDeposit = (provider.api.consts.evm.storageDepositPerByte as UInt).toBigInt();
txFeePerGas = (provider.api.consts.evm.txFeePerGas as UInt).toBigInt();
storageByteDeposit = provider.api.consts.evm.storageDepositPerByte.toBigInt();
txFeePerGas = provider.api.consts.evm.txFeePerGas.toBigInt();

({ txGasLimit, txGasPrice } = calcEthereumTransactionParams({
gasLimit: 2100001n,
Expand Down Expand Up @@ -167,7 +166,7 @@ describe('transaction tests', () => {
...partialDeployTx,
type: 0,
});
const receipt = await response.wait(0);
const receipt = await response.wait();

expect(receipt.type).equal(0);
expect(receipt.status).equal(1);
Expand Down Expand Up @@ -195,7 +194,7 @@ describe('transaction tests', () => {
expect(parsedTx.maxFeePerGas).equal(undefined);

const response = await provider.sendTransaction(rawTx);
const receipt = await response.wait(0);
const receipt = await response.wait();

expect(receipt.type).equal(0); // TODO: should be null, need to fix getPartialTransactionReceipt
expect(receipt.status).equal(1);
Expand Down Expand Up @@ -283,7 +282,7 @@ describe('transaction tests', () => {
const acaContract = new Contract(ADDRESS.ACA, ACAABI.abi, wallet1);
const iface = new Interface(ACAABI.abi);
const queryBalance = async (addr: string): Promise<BigNumber> => acaContract.balanceOf(addr);
const transferAmount = parseUnits('100', ACADigits);
const transferAmount = parseUnits('1.243', ACADigits);
let partialTransferTX: any;

beforeAll(() => {
Expand All @@ -302,24 +301,6 @@ describe('transaction tests', () => {
expect(computeDefaultSubstrateAddress(account2.evmAddress)).to.equal(account2.defaultSubstrateAddress);
});

describe('with provider', () => {
it('has correct balance after transfer', async () => {
const pairs = createTestPairs();
const alice = pairs.alice;

const oneAca = 10n ** BigInt(ACADigits);
const amount = 1000n * oneAca;
const balance = await queryBalance(account1.evmAddress);

const extrinsic = provider.api.tx.balances.transfer(account1.defaultSubstrateAddress, amount);
await extrinsic.signAsync(alice);
await sendTx(provider.api, extrinsic);

const _balance = await queryBalance(account1.evmAddress);
expect(_balance.sub(balance).toBigInt()).equal(amount);
});
});

describe('with legacy EIP-155 signature', () => {
it('has correct balance after transfer', async () => {
const _balance1 = await queryBalance(account1.evmAddress);
Expand All @@ -334,7 +315,7 @@ describe('transaction tests', () => {
const _parsedTx = parseTransaction(rawTx);

const response = await provider.sendTransaction(rawTx);
const _receipt = await response.wait(0);
const _receipt = await response.wait();

const __balance1 = await queryBalance(account1.evmAddress);
const _balance2 = await queryBalance(account2.evmAddress);
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-37d9e36 --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-7ae4bf4 --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-37d9e36
image: ghcr.io/acalanetwork/mandala-node:sha-7ae4bf4
ports:
- 9944:9944
command:
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/node@1.21.2 @subql/query@1.4.0
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-37d9e36 --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-7ae4bf4 --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-37d9e36
image: ghcr.io/acalanetwork/mandala-node:sha-7ae4bf4
ports:
- 9944:9944
healthcheck:
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 @@ -14,7 +14,7 @@ schema:
file: ./schema.graphql
network:
# local mandala
chainId: '0x2196d1ccb20962188d3dfcb3ccec4bab6647c6d3d8f6ff1c329efdaf3b213e5d'
chainId: '0x6808cd9b5035f8983328e7ddb7efa0da77ecc2e180de504d13d0e5789724e8b7'
endpoint: ws://localhost:9944
chaintypes:
# TODO: can generate this dynamically with `yarn build` using `@acala-network/types`
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-2220.wasm
wasm-override: ./wasm/acala-2230.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-2220.wasm
wasm-override: ./wasm/karura-2230.wasm

import-storage:
Sudo:
Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e-tests/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-37d9e36
image: ghcr.io/acalanetwork/mandala-node:sha-7ae4bf4
container_name: mandala-node
ports:
- 9944:9944
Expand Down
Binary file added scripts/e2e-tests/wasm/acala-2230.wasm
Binary file not shown.
Binary file added scripts/e2e-tests/wasm/karura-2230.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion scripts/new-rpc-benchmark/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# New Eth RPC Benchmark
first start a local mandala with normal sealing
```
docker run -it --rm -p 9944:9944 ghcr.io/acalanetwork/mandala-node:sha-37d9e36 --dev --rpc-external --rpc-cors=all --rpc-methods=unsafe -levm=debug --pruning=archive
docker run -it --rm -p 9944:9944 ghcr.io/acalanetwork/mandala-node:sha-7ae4bf4 --dev --rpc-external --rpc-cors=all --rpc-methods=unsafe -levm=debug --pruning=archive
```

then start an old rpc adapter
Expand Down

0 comments on commit 3097d7e

Please sign in to comment.