Skip to content

Commit 6be5430

Browse files
authored
Fix setStorage slot encoding to handle values > 2^64 (#171)
setStorage used writeBigUInt64BE which silently truncates slots larger than 8 bytes. Switch to the hex string approach already used by getStorage and the value encoding.
1 parent 9f17af1 commit 6be5430

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎packages/evm/src/executor.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ export class Executor {
268268
*/
269269
async setStorage(slot: bigint, value: bigint): Promise<void> {
270270
const slotBuffer = Buffer.alloc(32);
271-
slotBuffer.writeBigUInt64BE(slot, 24);
271+
const slotHex = slot.toString(16).padStart(64, "0");
272+
slotBuffer.write(slotHex, "hex");
272273

273274
const valueBuffer = Buffer.alloc(32);
274275
const hex = value.toString(16).padStart(64, "0");

0 commit comments

Comments
 (0)