From 62c695095706df8324ee1a0a53ffa25daa41bee6 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 29 Mar 2023 11:42:50 -0400 Subject: [PATCH] *If we have missing storageProofs, log and throw an error --- src/client/rpc/provider.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/client/rpc/provider.ts b/src/client/rpc/provider.ts index a978402..783d9a7 100644 --- a/src/client/rpc/provider.ts +++ b/src/client/rpc/provider.ts @@ -596,7 +596,13 @@ export class VerifyingProvider { const isAccountValid = account .serialize() .equals(expectedAccountRLP ? expectedAccountRLP : emptyAccountSerialize); - if (!isAccountValid) return false; + if (!isAccountValid) { + return false; + } + if (storageKeys.length !== proof?.storageProof.length) { + console.error("missing storageProof"); + throw new Error("missing storageProof"); + } for (let i = 0; i < storageKeys.length; i++) { const sp = proof.storageProof[i]; @@ -612,7 +618,9 @@ export class VerifyingProvider { (!expectedStorageRLP && sp.value === "0x0") || (!!expectedStorageRLP && expectedStorageRLP.equals(Buffer.from(rlp.encode(sp.value)))); - if (!isStorageValid) return false; + if (!isStorageValid) { + return false; + } } return true;