Skip to content

Commit ff5e012

Browse files
authored
Merge pull request #140 from eosnetworkfoundation/yarkin/ws_batch_hash_check
Extra checks for block hash when batch requesting block and logs.
2 parents 8c8f62e + d8e2a14 commit ff5e012

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

peripherals/eos-evm-ws-proxy/block-monitor.js

+15
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ class BlockMonitor extends EventEmitter {
7878
const block = results.data[0].result;
7979
const logs = results.data[1].result;
8080

81+
if (!block || !block["hash"]) {
82+
throw new Error("missing hash in response for getBlock request of the [getBlock, GetPastLogs] batch request");
83+
}
84+
if (!Array.isArray(logs)) {
85+
throw new Error("invalid logs in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
86+
}
87+
for (const logEntry of logs) {
88+
if (!logEntry["blockHash"]) {
89+
throw new Error("missing blockHash in response for GetPastLogs request of the [getBlock, GetPastLogs] batch request");
90+
}
91+
else if (logEntry["blockHash"] !== block["hash"]) {
92+
throw new Error("mismatched hashes in response of [getBlock, GetPastLogs] batch request");
93+
}
94+
}
95+
8196
block.logs = logs;
8297
//console.log("RPC batch result:" + JSON.stringify(block));
8398
return block;

0 commit comments

Comments
 (0)