Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions query/app/api/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ async function getBlockNumber(blockHash: string, chainName: string): Promise<num
const api = await initialize(CHAIN_TO_WS_ENDPOINT.get(chainName.toLowerCase()) as string);
const rpc: any = api.rpc;
try {
const block = await rpc.chain.getBlock(blockHash);
const header = await rpc.chain.getHeader(blockHash);
await disconnect();
return block.block.header.number.toNumber();
return header.number.toNumber();
} catch (error) {
console.log(error);
}
Expand Down Expand Up @@ -370,6 +370,8 @@ export async function GET(req: NextRequest) {
error: 'Getting the block range covered by the VectorX contract failed!'
});
}

console.log('Block range: ' + blockRange.start + ' - ' + blockRange.end);

if (requestedBlock < blockRange.start || requestedBlock > blockRange.end) {
return NextResponse.json({
Expand All @@ -387,6 +389,9 @@ export async function GET(req: NextRequest) {

let [requestedBlockHash, dataCommitmentRange] = await Promise.all(promises);

console.log('Requested block hash: ' + requestedBlockHash);
console.log('Data commitment range: ' + dataCommitmentRange);

if (dataCommitmentRange === null) {
return NextResponse.json({
success: false,
Expand All @@ -404,6 +409,8 @@ export async function GET(req: NextRequest) {
chainName!
);

console.log('Got data roots: ' + dataRoots.length);

// Extend the header array to commitmentTreeSize (fill with empty bytes).
if (dataRoots.length < commitmentTreeSize) {
const additionalRoots = new Array(commitmentTreeSize - dataRoots.length).fill(new Uint8Array(32));
Expand Down
3 changes: 2 additions & 1 deletion query/app/utils/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export async function queryLogs(
toBlock: number,
event: AbiEvent,
) {
console.log('queryLogs', fromBlock, toBlock);
if (process.env[`RPC_${ethereumChainId}`] == undefined) {
throw new Error('Missing RPC URL for chain ' + ethereumChainId);
}
Expand Down Expand Up @@ -173,7 +174,7 @@ export async function getBlocksSinceLastLog(ethereumChainId: number, ethereumRpc
Number(ethCurrentBlockNumber) - (diffBlocks * 10),
Number(ethCurrentBlockNumber),
event,
diffBlocks
10000
);

// Sort headUpdateLogs by block number descending.
Expand Down
Loading