Skip to content

Commit

Permalink
runtime 2270 and pjs 14 (#1038)
Browse files Browse the repository at this point in the history
* runtime 2270

* pjs 14

* fix call return data format

* update wasm

* fix truffle gas
  • Loading branch information
shunjizhan authored Oct 24, 2024
1 parent 6f00def commit b07e47f
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 248 deletions.
4 changes: 2 additions & 2 deletions chopsticks/configs/acala.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
endpoint: wss://acala-rpc.dwellir.com
mock-signature-host: true
runtime-log-level: 5
block: 7000000
wasm-override: ./chopsticks/wasm/acala-2260.wasm
# block: 7000000
wasm-override: ./chopsticks/wasm/acala-2270.wasm

import-storage:
Sudo:
Expand Down
Binary file added chopsticks/wasm/acala-2270.wasm
Binary file not shown.
3 changes: 2 additions & 1 deletion e2e-tests/e2e-truffle/truffle-config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const HDWalletProvider = require('@truffle/hdwallet-provider');

// pre-funded accounts for local mandala
// pre-funded accounts for local acala fork
const mnemonic = 'fox sight canyon orphan hotel grow hedgehog build bless august weather swarm';

module.exports = {
networks: {
acalaFork: {
provider: () => new HDWalletProvider(mnemonic, 'http://localhost:8545'),
network_id: 787,
gas: "202020",
},
},
mocha: {
Expand Down
4 changes: 2 additions & 2 deletions packages/eth-providers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"peerDependencies": {
"@acala-network/api": "6.1.3",
"@polkadot/api": "^12.4.2"
"@polkadot/api": "^14.0.1"
},
"dependencies": {
"@acala-network/contracts": "4.3.4",
Expand All @@ -25,7 +25,7 @@
},
"devDependencies": {
"@acala-network/api": "6.1.3",
"@polkadot/api": "^12.4.2",
"@polkadot/api": "^14.0.1",
"@types/bn.js": "^5.1.5",
"@types/lru-cache": "~7.6.1",
"dotenv": "~10.0.0",
Expand Down
14 changes: 7 additions & 7 deletions packages/eth-providers/src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,14 @@ describe('eth call error handling', () => {

describe('checkEvmExecutionError', () => {
const commonData = {
used_gas: '0x0',
used_storage: 0,
usedGas: '0x0',
usedStorage: 0,
logs: [],
};

it('when should throw - reverted', () => {
const data = {
exit_reason: { revert: 'Reverted' as const },
exitReason: { revert: 'Reverted' as const },
value: invalidCurrencyIdHex,
...commonData,
};
Expand All @@ -464,7 +464,7 @@ describe('eth call error handling', () => {

it('when should throw - outOfFund', () => {
const data = {
exit_reason: {
exitReason: {
error: { outOfFund: null },
},
value: invalidCurrencyIdHex,
Expand All @@ -476,7 +476,7 @@ describe('eth call error handling', () => {

it('when should throw - ExistentialDeposit', () => {
const data = {
exit_reason: {
exitReason: {
error: { other: 'ExistentialDeposit' },
},
value: invalidCurrencyIdHex,
Expand All @@ -489,7 +489,7 @@ describe('eth call error handling', () => {
it('when should not throw', () => {
{
const data = {
exit_reason: { succeed: 'Returned' as const },
exitReason: { succeed: 'Returned' as const },
value: '0x123456789',
...commonData,
};
Expand All @@ -498,7 +498,7 @@ describe('eth call error handling', () => {

{
const data = {
exit_reason: { succeed: 'Stopped' as const },
exitReason: { succeed: 'Stopped' as const },
value: '0x',
...commonData,
};
Expand Down
21 changes: 12 additions & 9 deletions packages/eth-providers/src/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ export interface PollFilters {
}

export interface CallReturnInfo {
exit_reason: {
exitReason: {
succeed?: 'Stopped' | 'Returned' | 'Suicided';
error?: any;
revert?: 'Reverted';
fatal?: any;
};
value: string;
used_gas: string;
used_storage: number;
usedGas: string;
usedStorage: number;
logs: Log[];
}

Expand Down Expand Up @@ -839,18 +839,21 @@ export abstract class BaseProvider extends AbstractProvider {
return res.value;
};

_ethCall = async (callRequest: SubstrateEvmCallRequest, at?: string) => {
_ethCall = async (
callRequest: SubstrateEvmCallRequest,
at?: string,
): Promise<CallReturnInfo> => {
const api = at ? await this.api.at(at) : this.api;

// call evm rpc when `state_call` is not supported yet
if (!api.call.evmRuntimeRPCApi) {
const data = await this.api.rpc.evm.call(callRequest);

return {
exit_reason: { succeed: 'Returned' },
exitReason: { succeed: 'Returned' },
value: data.toHex(),
used_gas: '0',
used_storage: 0,
usedGas: '0',
usedStorage: 0,
logs: [],
};
}
Expand Down Expand Up @@ -1120,8 +1123,8 @@ export abstract class BaseProvider extends AbstractProvider {
};

const gasInfo = await this._ethCall(txRequest, blockHash);
const usedGas = BigNumber.from(gasInfo.used_gas).toNumber();
const usedStorage = gasInfo.used_storage;
const usedGas = BigNumber.from(gasInfo.usedGas).toNumber();
const usedStorage = gasInfo.usedStorage;

/* ----------
try using a gasLimit slightly more than actual used gas
Expand Down
2 changes: 1 addition & 1 deletion packages/eth-providers/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export const decodeRevertMsg = (hexMsg: string) => {
export const checkEvmExecutionError = (data: CallReturnInfo): void => {
if (!data) return;

const { exit_reason: exitReason, value: returnData } = data;
const { exitReason, value: returnData } = data;
if (!exitReason.succeed) {
let msg: string;
let err: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/eth-rpc-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test:coverage": "COVERAGE_DIR=${COVERAGE_DIR:-eth-rpc-adapter/coverage} yarn start:coverage && COVERAGE_DIR=${COVERAGE_DIR:-eth-rpc-adapter/coverage} yarn test --run && yarn stop:coverage"
},
"peerDependencies": {
"@polkadot/api": "^12.4.2"
"@polkadot/api": "^14.0.1"
},
"dependencies": {
"@acala-network/eth-providers": "workspace:*",
Expand Down
Loading

0 comments on commit b07e47f

Please sign in to comment.