mirror of
https://github.com/cerc-io/watcher-ts
synced 2026-09-08 16:54:08 +00:00
Use block number for eth_call in rpc-eth-client (#435)
* Update subgraph readme to run fill before job-runner * Fix getContractEntitiesMap incase of template data sources * Use rpcSupportsBlockHashParam flag to use blockNumber for rpc client eth_call * Fix optional baseFeePerGas in rpc-eth-client * Fix graph-node tests after changes * Remove completed TODO
This commit is contained in:
@@ -71,6 +71,7 @@ xdescribe('call handler in mapping code', () => {
|
||||
indexer,
|
||||
provider,
|
||||
{
|
||||
rpcSupportsBlockHashParam: true,
|
||||
block: dummyEventData.block,
|
||||
contractAddress: dummyGraphData.dataSource.address
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('crypto host api', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -90,6 +90,7 @@ xdescribe('eden wasm loader tests', async () => {
|
||||
indexer,
|
||||
provider,
|
||||
{
|
||||
rpcSupportsBlockHashParam: true,
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
@@ -210,6 +211,7 @@ xdescribe('eden wasm loader tests', async () => {
|
||||
indexer,
|
||||
provider,
|
||||
{
|
||||
rpcSupportsBlockHashParam: true,
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
@@ -328,6 +330,7 @@ xdescribe('eden wasm loader tests', async () => {
|
||||
indexer,
|
||||
provider,
|
||||
{
|
||||
rpcSupportsBlockHashParam: true,
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('ethereum ABI encode decode', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -51,6 +51,7 @@ xdescribe('eth-call wasm tests', () => {
|
||||
indexer,
|
||||
provider,
|
||||
{
|
||||
rpcSupportsBlockHashParam: true,
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
|
||||
@@ -31,7 +31,7 @@ describe('json host api', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('wasm loader tests', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
@@ -113,7 +113,7 @@ describe('wasm loader tests', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
module,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -47,8 +47,9 @@ export interface GraphData {
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
block?: Block
|
||||
contractAddress?: string
|
||||
rpcSupportsBlockHashParam: boolean;
|
||||
block?: Block;
|
||||
contractAddress?: string;
|
||||
}
|
||||
|
||||
const log = debug('vulcanize:graph-node');
|
||||
@@ -173,10 +174,21 @@ export const instantiate = async (
|
||||
functionParams = await Promise.all(functionParamsPromise);
|
||||
|
||||
assert(context.block);
|
||||
let result: any;
|
||||
|
||||
// TODO: Check for function overloading.
|
||||
console.time(`time:loader#ethereum.call-${functionName}`);
|
||||
let result = await contract[functionName](...functionParams, { blockTag: context.block.blockHash });
|
||||
if (context.rpcSupportsBlockHashParam) {
|
||||
result = await contract[functionName](
|
||||
...functionParams,
|
||||
{ blockTag: context.block.blockHash }
|
||||
);
|
||||
} else {
|
||||
result = await contract[functionName](
|
||||
...functionParams,
|
||||
{ blockTag: BigNumber.from(context.block.blockNumber).toHexString() }
|
||||
);
|
||||
}
|
||||
console.timeEnd(`time:loader#ethereum.call-${functionName}`);
|
||||
|
||||
// Using function signature does not work.
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('numbers wasm tests', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -52,6 +52,7 @@ xdescribe('storage-call wasm tests', () => {
|
||||
indexer,
|
||||
provider,
|
||||
{
|
||||
rpcSupportsBlockHashParam: true,
|
||||
block: dummyEventData.block,
|
||||
contractAddress
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('typeConversion wasm tests', () => {
|
||||
db,
|
||||
indexer,
|
||||
provider,
|
||||
{},
|
||||
{ rpcSupportsBlockHashParam: true },
|
||||
filePath,
|
||||
dummyGraphData
|
||||
);
|
||||
|
||||
@@ -52,7 +52,7 @@ export class GraphWatcher {
|
||||
_dataSourceMap: { [key: string]: DataSource } = {};
|
||||
_transactionsMap: Map<string, Transaction> = new Map();
|
||||
|
||||
_context: Context = {};
|
||||
_context: Context;
|
||||
|
||||
constructor (database: GraphDatabase, ethClient: EthClient, ethProvider: providers.BaseProvider, serverConfig: ServerConfig) {
|
||||
this._database = database;
|
||||
@@ -60,6 +60,10 @@ export class GraphWatcher {
|
||||
this._ethProvider = ethProvider;
|
||||
this._subgraphPath = serverConfig.subgraphPath;
|
||||
this._wasmRestartBlocksInterval = serverConfig.wasmRestartBlocksInterval;
|
||||
|
||||
this._context = {
|
||||
rpcSupportsBlockHashParam: Boolean(serverConfig.rpcSupportsBlockHashParam)
|
||||
};
|
||||
}
|
||||
|
||||
async init () {
|
||||
|
||||
Reference in New Issue
Block a user