Commit ce242d9f authored by George Hotz's avatar George Hotz

fix bug found with memory fuzzer

parent f0d244bc
......@@ -6,7 +6,7 @@ import { Lib_BytesUtils } from "./Lib_BytesUtils.sol";
import { Lib_RLPReader } from "./Lib_RLPReader.sol";
import { Lib_RLPWriter } from "./Lib_RLPWriter.sol";
//import "hardhat/console.sol";
import "hardhat/console.sol";
/**
* @title Lib_MerkleTrie
......@@ -541,9 +541,15 @@ library Lib_MerkleTrie {
previousNodeHash = _getNodeHash(currentNode.encoded);
}
// If the root node is < 32 bytes, it won't have a stored hash
bytes32 encodedHash = keccak256(currentNode.encoded);
if (currentNode.encoded.length < 32) {
GetTrie()[encodedHash] = currentNode.encoded;
}
// Current node should be the root at this point.
// Simply return the hash of its encoding.
return keccak256(currentNode.encoded);
return encodedHash;
}
/**
......
......@@ -60,7 +60,7 @@ describe("MIPSMemory contract", function () {
root = await write(mm, root, 0, 1)
root = await write(mm, root, 0, 2)
})
/*it("fuzzing should be okay", async function() {
it("fuzzing should be okay", async function() {
let root = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
let kv = {}
......@@ -90,5 +90,5 @@ describe("MIPSMemory contract", function () {
kv[key] = value
}
}
})*/
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment