Skip to content

Commit

Permalink
Fix estimateResources (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
zjb0807 committed May 15, 2023
1 parent abd8b64 commit e6b450c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions packages/eth-providers/src/base-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import LRUCache from 'lru-cache';
import {
BIGNUMBER_ZERO,
BLOCK_GAS_LIMIT,
BLOCK_STORAGE_LIMIT,
CACHE_SIZE_WARNING,
DUMMY_ADDRESS,
DUMMY_BLOCK_HASH,
Expand Down Expand Up @@ -1080,16 +1081,16 @@ export abstract class BaseProvider extends AbstractProvider {
gasLimit: BigNumber;
usedStorage: BigNumber;
}> => {
const MAX_GAS_LIMIT = BLOCK_GAS_LIMIT;
const MAX_GAS_LIMIT = BLOCK_GAS_LIMIT * 10; // capped at 10x (1000%) the current block gas limit
const MIN_GAS_LIMIT = 21000;
const MAX_STORAGE_LIMIT = 640000;
const STORAGE_LIMIT = BLOCK_STORAGE_LIMIT;

const _txRequest = await getTransactionRequest(transaction);
const txRequest = {
..._txRequest,
value: BigNumber.isBigNumber(_txRequest.value) ? _txRequest.value.toBigInt() : _txRequest.value,
gasLimit: MAX_GAS_LIMIT,
storageLimit: MAX_STORAGE_LIMIT,
gasLimit: _txRequest.gasLimit?.toBigInt() || MAX_GAS_LIMIT,
storageLimit: STORAGE_LIMIT,
};

const { used_gas: usedGas, used_storage: usedStorage } = await this._ethCall(txRequest);
Expand Down
3 changes: 2 additions & 1 deletion packages/eth-providers/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export const ORPHAN_TX_DEFAULT_INFO = {
...DUMMY_V_R_S,
};

export const BLOCK_GAS_LIMIT = 29_990_102;
export const BLOCK_GAS_LIMIT = 29_990_016;
export const BLOCK_STORAGE_LIMIT = 3_670_016;

export const ONE_GWEI = 1_000_000_000n;
export const TEN_GWEI = ONE_GWEI * 10n;
Expand Down
6 changes: 3 additions & 3 deletions packages/eth-rpc-adapter/src/__tests__/e2e/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export const karuraBlock2449983 = {
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
difficulty: '0x0',
totalDifficulty: '0x0',
gasLimit: '0x1c99cd6',
gasLimit: '0x1c99c80',
gasUsed: '0x36c64',
miner: '0xaa8b848056f89fc7f3bcc7c0a790ab8280423100',
extraData: '0x',
Expand Down Expand Up @@ -283,7 +283,7 @@ export const karuraBlock1818188 = {
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
difficulty: '0x0',
totalDifficulty: '0x0',
gasLimit: '0x1c99cd6',
gasLimit: '0x1c99c80',
gasUsed: '0x0',
miner: '0x520425df7e86cb8dffd8fd140b075140b28f9629',
extraData: '0x',
Expand All @@ -306,7 +306,7 @@ export const karuraBlock1818518 = {
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
difficulty: '0x0',
totalDifficulty: '0x0',
gasLimit: '0x1c99cd6',
gasLimit: '0x1c99c80',
gasUsed: '0x3181f',
miner: '0x576482c15d3e4ec12c0577c611d3ed05eadfed46',
extraData: '0x',
Expand Down

0 comments on commit e6b450c

Please sign in to comment.