Skip to content

Instantly share code, notes, and snippets.

@gjwang
Last active November 2, 2026 09:57
Show Gist options
  • Select an option

  • Save gjwang/5a8f80f5e441a5701e2e01ae73f187bf to your computer and use it in GitHub Desktop.

Select an option

Save gjwang/5a8f80f5e441a5701e2e01ae73f187bf to your computer and use it in GitHub Desktop.
BlockVectra BSC fixed-block receipt/log observation — 2026-10-25 UTC, offline verifier (EN/中文)

BSC receipt and fixed-block logs / BSC 收据与固定区块日志

A saved BlockVectra QA observation for BSC #3853, discussed in this reply. On 2026-10-25 at 13:26:17–13:26:21 UTC, three requests checked chain ID 56, a transaction receipt, and address-filtered logs from block 129476271 (0x7b7a6af). All three returned HTTP 200, with no retries.

The log response contains four entries. The selected ERC-721 Transfer for token 1811 matches its receipt event across eight fields: address, topics, data, blockHash, blockNumber, transactionHash, transactionIndex, and logIndex. The RPC filter used only the address and fixed block; event selection happens offline.

Download all files into one directory, then run with Node.js 22+:

node verify-sample.mjs observed-sample.json

Expected output:

PASS 1 receipt event matched among 4 returned logs

The checker uses no network or key. chain-id.json, receipt.json, and logs.json preserve the original response bytes; observed-sample.json pairs them with requests and hashes. SHA256SUMS records file integrity. Public blockchain addresses remain present; no API credentials or login metadata are included. This checks consistency within one saved observation, not independent canonicality, full history, performance, or the original incident's cause. MIT license included.


这是 BSC #3853 讨论中的一份 BlockVectra 历史 QA 样例。2026-10-25 13:26:17–13:26:21 UTC,链 ID 56,固定区块 129476271;3 次请求均为 HTTP 200,无重试。返回 4 条日志,其中 token 1811 的 ERC-721 Transfer 与收据事件按上述八字段一致。原请求仅按地址、区块过滤,事件在离线核验时选取。

将全部文件下载至同一目录,使用 Node.js 22+ 运行上述命令,无需 key 或联网。三个原始响应文件保留原字节,元数据记录请求及 SHA;文件包含公开链上地址,不含 API 凭据或登录资料。本样例只核对这一存档内的单区块事件一致性,不证明独立 canonical 性、完整历史、性能或原故障原因。

Compare the same event with your provider / 用自己的端点核对同一事件

bsc-compare-provider.mjs lets you run the same three saved requests against a provider you choose. It checks chain ID first, then the fixed transaction receipt and address-filtered logs. It stops on an unavailable receipt, a mismatched block/event, HTTP or JSON-RPC errors, or an empty/missing event result. There are no retries, redirects or broadcasts; each response has a 15-second deadline and a 2 MiB cap.

Download the new client and its test alongside observed-sample.json. First run the checks without a network or credential:

node --test bsc-compare-provider.test.mjs

For a real comparison, set RPC_URL privately in your server environment to your chosen BSC mainnet endpoint. For BlockVectra, use https://api.blockvectra.com/v1/bsc_mainnet and privately set your own BLOCKVECTRA_API_KEY; the client sends it as x-api-key. Other authentication arrangements must already be provided by your endpoint. Never put credentials in a command, screenshot or shared output. A comparison can consume provider quota; it is not a zero-cost guarantee.

node bsc-compare-provider.mjs observed-sample.json

A successful JSON summary reports MATCH, the fixed block, one matched event, the returned log count, attempts and UTC observation time. It does not require the log count to remain four. The summary omits endpoint, authentication values and response bodies. Any failure exits nonzero; it is not automatically evidence of a provider bug. Historical retention or availability can differ from the saved observation. Requests carry a BlockVectraQA/1 marker and must be separated from customer traffic measurements.

Preparation checks used synthetic transport, including the actual CLI entry; this new client has not been run against a live provider. The original three-response observation above remains unchanged. Matching this event does not prove independent canonicality, complete logs/history, performance or incident cause.

新客户端让你用自己的 BSC 主网端点,按原样本顺序核对链 ID、固定交易收据及单区块日志。先离线运行测试,再私密配置 RPC_URL;使用 BlockVectra 时另配自己的 BLOCKVECTRA_API_KEY,不要把凭据放进命令或截图。最多三次请求、无重试/重定向/广播;每次限时15秒、正文上限2 MiB,可能消耗供应商额度。成功只表示这一事件按八字段匹配,不要求总日志数仍为4;失败不自动等于供应商缺陷。新客户端仅做了合成传输测试,尚未用于真实端点;原历史响应字节不变,QA请求不计客户增长。

// SPDX-License-Identifier: MIT
// A bounded, opt-in comparison of one saved BSC event; not a canonicality oracle.
import { readFile } from 'node:fs/promises';
import { pathToFileURL } from 'node:url';
const fields = ['address', 'topics', 'data', 'blockHash', 'blockNumber',
'transactionHash', 'transactionIndex', 'logIndex'];
const methods = ['eth_chainId', 'eth_getTransactionReceipt', 'eth_getLogs'];
const maxBytes = 2 * 1024 * 1024;
const normalize = value => Array.isArray(value) ? value.map(normalize)
: typeof value === 'string' ? value.toLowerCase() : value;
class ComparisonError extends Error {}
const insist = (ok, message) => { if (!ok) throw new ComparisonError(message); };
function projection(log) {
insist(log && log.removed === false, 'Missing or removed event');
insist(/^0x[0-9a-f]{40}$/i.test(log.address), 'Invalid event address');
for (const key of ['blockHash', 'transactionHash']) {
insist(/^0x[0-9a-f]{64}$/i.test(log[key]), 'Invalid event hash');
}
for (const key of ['blockNumber', 'transactionIndex', 'logIndex']) {
insist(typeof log[key] === 'string' && /^0x(?:0|[1-9a-f][0-9a-f]*)$/i.test(log[key]),
'Invalid event quantity');
}
insist(Array.isArray(log.topics) && log.topics.every(t => /^0x[0-9a-f]{64}$/i.test(t)),
'Invalid event topics');
insist(typeof log.data === 'string' && /^0x(?:[0-9a-f]{2})*$/i.test(log.data),
'Invalid event data');
return JSON.stringify(fields.map(key => normalize(log[key])));
}
export async function compareProvider({ sample, endpoint, apiKey, fetchImpl = fetch }) {
// Bind all three calls to the published historical task before any network access.
insist(sample?.chain_id === 56 && sample?.chain === 'bsc_mainnet', 'Expected the saved BSC sample');
insist(sample.requests?.length === 3, 'Expected exactly three saved requests');
const requests = sample.requests.map((item, index) => {
insist(item.method === methods[index] && item.request?.method === methods[index],
'Unexpected saved method');
insist(item.request.jsonrpc === '2.0' && item.request.id === index + 1 &&
Array.isArray(item.request.params), 'Invalid saved request');
return item.request;
});
const [filter] = requests[2].params;
insist(requests[0].params.length === 0 && requests[1].params.length === 1 &&
requests[1].params[0] === '0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3',
'Unexpected saved transaction');
insist(requests[2].params.length === 1 && filter?.fromBlock === '0x7b7a6af' &&
filter.toBlock === filter.fromBlock &&
normalize(filter.address) === '0xe397a4776f9e7cdc016c332b15756325e4aac84b' &&
Object.keys(filter).sort().join(',') === 'address,fromBlock,toBlock', 'Unexpected saved filter');
const historicalReceipt = sample.requests[1].response?.result;
const target = historicalReceipt?.logs?.filter(log => normalize(log.address) === normalize(filter.address) &&
log.topics?.length === 4 &&
log.topics[0] === '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' &&
log.topics[3] === `0x${1811n.toString(16).padStart(64, '0')}`);
insist(target?.length === 1, 'Expected one saved token 1811 Transfer');
const expected = projection(target[0]);
let url;
try { url = new URL(endpoint); } catch { throw new ComparisonError('Set a valid private RPC_URL'); }
insist(url.protocol === 'https:' || (url.protocol === 'http:' &&
['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname)), 'RPC_URL needs HTTPS or loopback HTTP');
insist(!url.username && !url.password && !url.hash, 'RPC_URL must not contain userinfo or a fragment');
const headers = { 'content-type': 'application/json', 'user-agent': 'BlockVectra-BSC-Example/1 BlockVectraQA/1' };
if (apiKey) headers['x-api-key'] = apiKey;
let attempts = 0;
async function request(body) {
attempts++;
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), 15000);
try {
const response = await fetchImpl(url.href, {
method: 'POST', headers, body: JSON.stringify(body), redirect: 'error', signal: controller.signal,
});
insist(response.status === 200, `${body.method}: HTTP response was not 200; stopped without retry`);
insist(response.body, `${body.method}: missing response body`);
let length = 0;
const chunks = [];
for await (const chunk of response.body) {
length += chunk.byteLength;
insist(length <= maxBytes, `${body.method}: response exceeded 2 MiB`);
chunks.push(Buffer.from(chunk));
}
let parsed;
try { parsed = JSON.parse(Buffer.concat(chunks).toString('utf8')); }
catch { throw new ComparisonError(`${body.method}: invalid JSON response`); }
insist(parsed?.jsonrpc === '2.0' && parsed.id === body.id &&
Object.hasOwn(parsed, 'result') && !Object.hasOwn(parsed, 'error'),
`${body.method}: unsuccessful or mismatched JSON-RPC response`);
return parsed.result;
} catch (error) {
controller.abort();
// Never echo a transport exception, provider body, endpoint or authentication value.
if (error instanceof ComparisonError) throw error;
throw new ComparisonError(`${body.method}: request failed; stopped without retry`);
} finally { clearTimeout(timer); }
}
const chainId = await request(requests[0]);
insist(typeof chainId === 'string' && /^0x[0-9a-f]+$/i.test(chainId) && BigInt(chainId) === 56n,
'Chain ID differs from BSC 56; stopped before receipt/log requests');
const receipt = await request(requests[1]);
insist(receipt && receipt.status === '0x1' && Array.isArray(receipt.logs),
'Receipt missing, failed or malformed; historical data may be unavailable');
insist(normalize(receipt.transactionHash) === requests[1].params[0] &&
normalize(receipt.blockNumber) === filter.fromBlock &&
normalize(receipt.blockHash) === normalize(historicalReceipt.blockHash),
'Receipt identity differs from the saved observation');
insist(receipt.logs.filter(log => projection(log) === expected).length === 1,
'Saved event missing or duplicated in the returned receipt');
const logs = await request(requests[2]);
insist(Array.isArray(logs), 'Log result is not an array');
for (const log of logs) {
projection(log);
insist(normalize(log.address) === normalize(filter.address) && normalize(log.blockNumber) === filter.fromBlock &&
normalize(log.blockHash) === normalize(receipt.blockHash), 'Returned log lies outside the fixed block/address');
}
insist(logs.filter(log => projection(log) === expected).length === 1,
'Saved receipt event missing or duplicated in eth_getLogs');
return { result: 'MATCH', chain_id: 56, block: 129476271, matched_receipt_events: 1,
returned_logs: logs.length, attempts, retries: 0, observed_at_utc: new Date().toISOString(),
scope: 'One saved event; not full history or independent canonicality' };
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
try {
const filename = process.argv[2] ?? 'observed-sample.json';
const bytes = await readFile(filename);
insist(bytes.byteLength <= maxBytes, 'Sample exceeds 2 MiB');
const sample = JSON.parse(bytes.toString('utf8'));
const result = await compareProvider({ sample, endpoint: process.env.RPC_URL,
apiKey: process.env.BLOCKVECTRA_API_KEY });
console.log(JSON.stringify(result));
} catch (error) {
// JSON/file errors may contain local paths or source text; publish only known messages.
const message = error instanceof ComparisonError ? error.message
: 'Cannot read the saved sample or complete the comparison';
console.error(`NOT_MATCHED: ${message}`);
process.exitCode = 1;
}
}
// SPDX-License-Identifier: MIT
// Synthetic transport fixtures only: no fetch in this test reaches a network.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { spawnSync } from 'node:child_process';
import { compareProvider } from './bsc-compare-provider.mjs';
const original = JSON.parse(await readFile(new URL('./observed-sample.json', import.meta.url), 'utf8'));
function fixture(change = () => {}) {
const sample = structuredClone(original);
const responses = sample.requests.map(item => structuredClone(item.response));
change(responses, sample);
const calls = [];
const fetchImpl = async (url, options) => {
calls.push({ url, options, request: JSON.parse(options.body) });
const index = calls.length - 1;
assert.ok(index < 3, 'No extra request is allowed');
assert.equal(options.redirect, 'error');
assert.match(options.headers['user-agent'], / BlockVectraQA\/1$/);
assert.ok(options.signal instanceof AbortSignal);
return new Response(JSON.stringify(responses[index]), { status: 200 });
};
return { sample, responses, calls, fetchImpl, endpoint: 'https://rpc.invalid/private-token', apiKey: 'test-private-key' };
}
test('Exact three saved calls match one event without exposing endpoint or key', async () => {
const f = fixture();
const result = await compareProvider(f);
assert.equal(result.result, 'MATCH');
assert.equal(result.matched_receipt_events, 1);
assert.equal(result.returned_logs, 4);
assert.equal(result.attempts, 3);
assert.deepEqual(f.calls.map(c => c.request), original.requests.map(i => i.request));
assert.equal(f.calls[0].options.headers['x-api-key'], 'test-private-key');
assert.doesNotMatch(JSON.stringify(result), /private-token|test-private-key|rpc.invalid/);
});
test('A different chain stops after the identity request', async () => {
const f = fixture(r => { r[0].result = '0x1'; });
await assert.rejects(compareProvider(f), /Chain ID differs/);
assert.equal(f.calls.length, 1);
});
test('Missing historical receipt stops without a log request', async () => {
const f = fixture(r => { r[1].result = null; });
await assert.rejects(compareProvider(f), /Receipt missing/);
assert.equal(f.calls.length, 2);
});
test('A different block hash stops before logs', async () => {
const f = fixture(r => { r[1].result.blockHash = `0x${'1'.repeat(64)}`; });
await assert.rejects(compareProvider(f), /Receipt identity differs/);
assert.equal(f.calls.length, 2);
});
test('Empty logs and a duplicated matching event both fail', async () => {
for (const duplicate of [false, true]) {
const f = fixture(r => {
r[2].result = duplicate ? [...r[2].result, structuredClone(r[1].result.logs[0])] : [];
});
await assert.rejects(compareProvider(f), /event missing or duplicated in eth_getLogs/);
assert.equal(f.calls.length, 3);
}
});
test('A returned log outside the address or block cannot pass', async () => {
for (const key of ['address', 'blockNumber']) {
const f = fixture(r => { r[2].result[1][key] = key === 'address' ? `0x${'1'.repeat(40)}` : '0x1'; });
await assert.rejects(compareProvider(f), /outside the fixed block\/address/);
}
});
test('429 and redirect responses stop once without printing a provider body', async () => {
for (const status of [429, 302]) {
const f = fixture();
let calls = 0;
f.fetchImpl = async () => { calls++; return new Response('test-private-key https://rpc.invalid/private-token', { status }); };
await assert.rejects(compareProvider(f), error => /HTTP response was not 200/.test(error.message) &&
!/test-private-key|private-token/.test(error.message));
assert.equal(calls, 1);
}
});
test('Transport failures and JSON-RPC errors never echo sensitive details', async () => {
const f = fixture();
f.fetchImpl = async () => { throw new Error('test-private-key https://rpc.invalid/private-token'); };
await assert.rejects(compareProvider(f), error => error.message === 'eth_chainId: request failed; stopped without retry');
const g = fixture(r => { r[0] = { jsonrpc: '2.0', id: 1, error: { code: -32000, message: 'test-private-key' } }; });
await assert.rejects(compareProvider(g), error => /unsuccessful or mismatched/.test(error.message) &&
!error.message.includes('test-private-key'));
assert.equal(g.calls.length, 1);
});
test('Response cap aborts the request before another call', async () => {
const f = fixture();
let signal;
let calls = 0;
f.fetchImpl = async (_url, options) => {
calls++; signal = options.signal;
return new Response('x'.repeat(2 * 1024 * 1024 + 1), { status: 200 });
};
await assert.rejects(compareProvider(f), /response exceeded 2 MiB/);
assert.equal(calls, 1);
assert.equal(signal.aborted, true);
});
test('Edited sample requests are rejected before network access', async () => {
const f = fixture((_r, s) => { s.requests[2].request.params[0].toBlock = 'latest'; });
await assert.rejects(compareProvider(f), /Unexpected saved filter/);
assert.equal(f.calls.length, 0);
});
test('The actual CLI returns a safe summary or a nonzero exit using synthetic transport', () => {
for (const wrongChain of [false, true]) {
const bodies = original.requests.map(item => structuredClone(item.response));
if (wrongChain) bodies[0].result = '0x1';
const preload = `const bodies=${JSON.stringify(bodies)};let n=0;globalThis.fetch=async()=>{
if(n>=3)throw new Error('extra call');return new Response(JSON.stringify(bodies[n++]),{status:200});};`;
const result = spawnSync(process.execPath, ['--import', `data:text/javascript,${encodeURIComponent(preload)}`,
'bsc-compare-provider.mjs', 'observed-sample.json'], {
cwd: new URL('.', import.meta.url), encoding: 'utf8', timeout: 5000,
env: { ...process.env, RPC_URL: 'https://rpc.invalid/private-token', BLOCKVECTRA_API_KEY: 'test-private-key' },
});
assert.equal(result.status, wrongChain ? 1 : 0, result.stderr);
assert.doesNotMatch(result.stdout + result.stderr, /private-token|test-private-key|rpc.invalid/);
if (wrongChain) assert.match(result.stderr, /Chain ID differs/);
else assert.equal(JSON.parse(result.stdout).result, 'MATCH');
}
});
{"jsonrpc":"2.0","id":1,"result":"0x38"}
MIT License
Copyright (c) 2026 BlockVectra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{"jsonrpc":"2.0","id":3,"result":[{"address":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99","0x0000000000000000000000000000000000000000000000000000000000000713"],"data":"0x","blockNumber":"0x7b7a6af","transactionHash":"0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3","transactionIndex":"0x26","blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockTimestamp":"0x6adc624c","logIndex":"0xd5","removed":false},{"address":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","topics":["0xd81db30268fedf2c70fb24e52dd42050441c93b4dca2783935c89e66fe0c146e","0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99","0x0000000000000000000000000000000000000000000000000000000000000713"],"data":"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000","blockNumber":"0x7b7a6af","transactionHash":"0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3","transactionIndex":"0x26","blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockTimestamp":"0x6adc624c","logIndex":"0xd6","removed":false},{"address":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000003f5d18f32405d1ba62112279fbf853f7a99850ca","0x0000000000000000000000000000000000000000000000000000000000000714"],"data":"0x","blockNumber":"0x7b7a6af","transactionHash":"0x7d5cf254e78066d6e97dd3db25024419c8f90cd618aaa4e7bfe5e5d6d638ffeb","transactionIndex":"0x27","blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockTimestamp":"0x6adc624c","logIndex":"0xd7","removed":false},{"address":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","topics":["0xd81db30268fedf2c70fb24e52dd42050441c93b4dca2783935c89e66fe0c146e","0x0000000000000000000000003f5d18f32405d1ba62112279fbf853f7a99850ca","0x0000000000000000000000000000000000000000000000000000000000000714"],"data":"0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000","blockNumber":"0x7b7a6af","transactionHash":"0x7d5cf254e78066d6e97dd3db25024419c8f90cd618aaa4e7bfe5e5d6d638ffeb","transactionIndex":"0x27","blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockTimestamp":"0x6adc624c","logIndex":"0xd8","removed":false}]}
{
"sample_type": "historical_blockvectra_internal_QA_observation",
"observed_at_utc": "2026-10-25T13:26:21.586695+00:00",
"chain": "bsc_mainnet",
"chain_id": 56,
"comparison_scope": "One matching receipt event in one fixed block; not full history, independent canonicality, benchmark, external adoption or incident root cause",
"requests": [
{
"method": "eth_chainId",
"request": {
"jsonrpc": "2.0",
"id": 1,
"method": "eth_chainId",
"params": []
},
"HTTP_status": 200,
"response": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x38"
},
"original_body_sha256": "ce50ba55ecf1a9410c6f5503d09da66974203165305ff8f5a2b520f49a705c07",
"original_body_file": "chain-id.json"
},
{
"method": "eth_getTransactionReceipt",
"request": {
"jsonrpc": "2.0",
"id": 2,
"method": "eth_getTransactionReceipt",
"params": [
"0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3"
]
},
"HTTP_status": 200,
"response": {
"jsonrpc": "2.0",
"id": 2,
"result": {
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockNumber": "0x7b7a6af",
"contractAddress": null,
"cumulativeGasUsed": "0x6cf619",
"effectiveGasPrice": "0x4fa6445",
"from": "0xcd3b1fb0c7e2234c45676ae28599631dcf5bdd99",
"gasUsed": "0x1f4c1",
"logs": [
{
"address": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99",
"0x0000000000000000000000000000000000000000000000000000000000000713"
],
"data": "0x",
"blockNumber": "0x7b7a6af",
"transactionHash": "0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3",
"transactionIndex": "0x26",
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockTimestamp": "0x6adc624c",
"logIndex": "0xd5",
"removed": false
},
{
"address": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"topics": [
"0xd81db30268fedf2c70fb24e52dd42050441c93b4dca2783935c89e66fe0c146e",
"0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99",
"0x0000000000000000000000000000000000000000000000000000000000000713"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x7b7a6af",
"transactionHash": "0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3",
"transactionIndex": "0x26",
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockTimestamp": "0x6adc624c",
"logIndex": "0xd6",
"removed": false
}
],
"logsBloom": "0x00000000000000000000400000000008000000000000000000000000000020000000000000000000000000000000000000000080000000000000000000000000000000000001000000000008000000000000000000000001000000000000000000000000020000000000000000000800000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000080020000000000000000000020000000000000000000080000000000000000000000040000000000000002000000",
"status": "0x1",
"to": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"transactionHash": "0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3",
"transactionIndex": "0x26",
"type": "0x0"
}
},
"original_body_sha256": "bd6ced5a61a9066c4a888e5d2fa78f2aa9230cf06344c793a48c13d9b5a0c802",
"original_body_file": "receipt.json"
},
{
"method": "eth_getLogs",
"request": {
"jsonrpc": "2.0",
"id": 3,
"method": "eth_getLogs",
"params": [
{
"address": "0xe397A4776F9e7cDC016C332b15756325E4AAc84B",
"fromBlock": "0x7b7a6af",
"toBlock": "0x7b7a6af"
}
]
},
"HTTP_status": 200,
"response": {
"jsonrpc": "2.0",
"id": 3,
"result": [
{
"address": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99",
"0x0000000000000000000000000000000000000000000000000000000000000713"
],
"data": "0x",
"blockNumber": "0x7b7a6af",
"transactionHash": "0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3",
"transactionIndex": "0x26",
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockTimestamp": "0x6adc624c",
"logIndex": "0xd5",
"removed": false
},
{
"address": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"topics": [
"0xd81db30268fedf2c70fb24e52dd42050441c93b4dca2783935c89e66fe0c146e",
"0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99",
"0x0000000000000000000000000000000000000000000000000000000000000713"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x7b7a6af",
"transactionHash": "0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3",
"transactionIndex": "0x26",
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockTimestamp": "0x6adc624c",
"logIndex": "0xd6",
"removed": false
},
{
"address": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000003f5d18f32405d1ba62112279fbf853f7a99850ca",
"0x0000000000000000000000000000000000000000000000000000000000000714"
],
"data": "0x",
"blockNumber": "0x7b7a6af",
"transactionHash": "0x7d5cf254e78066d6e97dd3db25024419c8f90cd618aaa4e7bfe5e5d6d638ffeb",
"transactionIndex": "0x27",
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockTimestamp": "0x6adc624c",
"logIndex": "0xd7",
"removed": false
},
{
"address": "0xe397a4776f9e7cdc016c332b15756325e4aac84b",
"topics": [
"0xd81db30268fedf2c70fb24e52dd42050441c93b4dca2783935c89e66fe0c146e",
"0x0000000000000000000000003f5d18f32405d1ba62112279fbf853f7a99850ca",
"0x0000000000000000000000000000000000000000000000000000000000000714"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0x7b7a6af",
"transactionHash": "0x7d5cf254e78066d6e97dd3db25024419c8f90cd618aaa4e7bfe5e5d6d638ffeb",
"transactionIndex": "0x27",
"blockHash": "0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd",
"blockTimestamp": "0x6adc624c",
"logIndex": "0xd8",
"removed": false
}
]
},
"original_body_sha256": "22b3c82b528dcbe6f75439921867a61881e5507596cd5965c37d8d6309fbdf72",
"original_body_file": "logs.json"
}
],
"target_event": {
"type": "ERC721 Transfer",
"token_id_decimal": "1811",
"topic0": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"topic3": "0x0000000000000000000000000000000000000000000000000000000000000713",
"scope": "Offline selected event; original eth_getLogs request filters address and block only"
}
}
{"jsonrpc":"2.0","id":2,"result":{"blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockNumber":"0x7b7a6af","contractAddress":null,"cumulativeGasUsed":"0x6cf619","effectiveGasPrice":"0x4fa6445","from":"0xcd3b1fb0c7e2234c45676ae28599631dcf5bdd99","gasUsed":"0x1f4c1","logs":[{"address":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99","0x0000000000000000000000000000000000000000000000000000000000000713"],"data":"0x","blockNumber":"0x7b7a6af","transactionHash":"0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3","transactionIndex":"0x26","blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockTimestamp":"0x6adc624c","logIndex":"0xd5","removed":false},{"address":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","topics":["0xd81db30268fedf2c70fb24e52dd42050441c93b4dca2783935c89e66fe0c146e","0x000000000000000000000000cd3b1fb0c7e2234c45676ae28599631dcf5bdd99","0x0000000000000000000000000000000000000000000000000000000000000713"],"data":"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000","blockNumber":"0x7b7a6af","transactionHash":"0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3","transactionIndex":"0x26","blockHash":"0x8de7dd93ccf6a51739727357e1cc57825f7a608014ef1409cc4668e1b5c608dd","blockTimestamp":"0x6adc624c","logIndex":"0xd6","removed":false}],"logsBloom":"0x00000000000000000000400000000008000000000000000000000000000020000000000000000000000000000000000000000080000000000000000000000000000000000001000000000008000000000000000000000001000000000000000000000000020000000000000000000800000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000080020000000000000000000020000000000000000000080000000000000000000000040000000000000002000000","status":"0x1","to":"0xe397a4776f9e7cdc016c332b15756325e4aac84b","transactionHash":"0x41c3a4feb6414c0ab44c4755d4e436738a3f18a742198c060e48d451b3d9fdf3","transactionIndex":"0x26","type":"0x0"}}
c6fbea280573c11c860533b2970195a0fb42ec5be599fb2386f8c07f4dc2ea75 LICENSE
625f0cd1d35e94a5b2d3a41785a1412890dcf7664ed190318c52f095b72fa785 README.md
19f0c76e1b0e7fae991629aee90d629c7fabb02c028fac73f6588945aa1d5249 bsc-compare-provider.mjs
a152538af44f4154057f4b799fabe73a256b69bf3e45e329f9ba8dba86f35522 bsc-compare-provider.test.mjs
ce50ba55ecf1a9410c6f5503d09da66974203165305ff8f5a2b520f49a705c07 chain-id.json
22b3c82b528dcbe6f75439921867a61881e5507596cd5965c37d8d6309fbdf72 logs.json
a02e24b2c3a96984b89e9aaf5852ea52dd5e28932f34707da860be863ad9c117 observed-sample.json
bd6ced5a61a9066c4a888e5d2fa78f2aa9230cf06344c793a48c13d9b5a0c802 receipt.json
4fabe89eb6e450b53b5d876650d794d43739330744e73593343ddee38be84498 verify-sample.mjs
// SPDX-License-Identifier: MIT
// Offline consistency check of a historical observation, not a canonical-chain oracle.
import { readFileSync } from 'node:fs';
import { createHash } from 'node:crypto';
import { resolve, dirname, basename } from 'node:path';
import { strict as assert } from 'node:assert';
try {
assert.equal(process.argv.length, 3, 'Usage: node verify-sample.mjs observed-sample.json');
const filename = resolve(process.argv[2]);
const sample = JSON.parse(readFileSync(filename, 'utf8'));
assert.equal(sample.sample_type, 'historical_blockvectra_internal_QA_observation');
assert.equal(sample.chain_id, 56);
assert.equal(sample.chain, 'bsc_mainnet');
assert.equal(sample.requests.length, 3);
const methods = ['eth_chainId', 'eth_getTransactionReceipt', 'eth_getLogs'];
for (const [index, item] of sample.requests.entries()) {
assert.equal(item.method, methods[index]);
assert.equal(item.request.method, methods[index]);
assert.equal(item.request.jsonrpc, '2.0');
assert.equal(item.request.id, index + 1);
assert.equal(item.HTTP_status, 200);
const name = item.original_body_file;
assert.equal(name, basename(name), 'Original body must be a sibling file');
const bytes = readFileSync(resolve(dirname(filename), name));
assert.equal(createHash('sha256').update(bytes).digest('hex'), item.original_body_sha256);
const body = JSON.parse(bytes.toString('utf8'));
assert.deepEqual(body, item.response, 'Stored projection differs from original response');
assert.equal(body.jsonrpc, '2.0');
assert.equal(body.id, item.request.id);
assert.equal(Object.hasOwn(body, 'error'), false);
assert.ok(Object.hasOwn(body, 'result'));
}
const [identity, receiptItem, logsItem] = sample.requests;
assert.equal(identity.response.result, '0x38');
const receipt = receiptItem.response.result;
const logs = logsItem.response.result;
const [filter] = logsItem.request.params;
assert.equal(logsItem.request.params.length, 1);
assert.equal(filter.fromBlock, '0x7b7a6af');
assert.equal(filter.toBlock, filter.fromBlock);
assert.equal(receipt.blockNumber, filter.fromBlock);
assert.equal(receipt.status, '0x1');
assert.equal(receipt.transactionHash, receiptItem.request.params[0]);
assert.match(receipt.blockHash, /^0x[0-9a-fA-F]{64}$/);
assert.ok(Array.isArray(receipt.logs));
assert.ok(Array.isArray(logs));
assert.match(filter.address, /^0x[0-9a-fA-F]{40}$/);
const address = filter.address.toLowerCase();
const fields = ['address', 'topics', 'data', 'blockHash', 'blockNumber',
'transactionHash', 'transactionIndex', 'logIndex'];
const normal = value => Array.isArray(value)
? value.map(normal) : typeof value === 'string' ? value.toLowerCase() : value;
function projection(log) {
assert.equal(log.removed, false, 'Removed log is not a matching observation');
return fields.map(field => {
assert.ok(Object.hasOwn(log, field), `Missing log field ${field}`);
return normal(log[field]);
});
}
const event = sample.target_event;
assert.equal(event.type, 'ERC721 Transfer');
assert.equal(event.token_id_decimal, '1811');
assert.equal(event.topic0, '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef');
assert.equal(event.topic3, `0x${1811n.toString(16).padStart(64, '0')}`);
const expected = receipt.logs.filter(log => log.address.toLowerCase() === address &&
log.topics.length === 4 && log.topics[0].toLowerCase() === event.topic0 &&
log.topics[3].toLowerCase() === event.topic3);
assert.equal(expected.length, 1, 'This sample contains exactly one matching receipt event');
assert.equal(logs.length, 4, 'This fixed sample contains four returned logs');
for (const log of logs) {
assert.equal(log.address.toLowerCase(), address);
assert.equal(log.blockNumber, filter.fromBlock);
assert.equal(log.blockHash, receipt.blockHash);
projection(log);
}
for (const expectedLog of expected) {
const wanted = projection(expectedLog);
const matches = logs.filter(log => JSON.stringify(projection(log)) === JSON.stringify(wanted));
assert.equal(matches.length, 1, 'Receipt event missing or duplicated in eth_getLogs');
}
console.log('PASS 1 receipt event matched among 4 returned logs');
} catch (error) {
console.error(`FAIL ${error.message}`);
process.exitCode = 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment