Commit c8192069 authored by clabby's avatar clabby

Add contract changes

parent f573f06a
...@@ -93,6 +93,8 @@ library MerkleTrie { ...@@ -93,6 +93,8 @@ library MerkleTrie {
bytes[] memory _proof, bytes[] memory _proof,
bytes32 _root bytes32 _root
) internal pure returns (bytes memory) { ) internal pure returns (bytes memory) {
require(_key.length > 0, "MerkleTrie: empty key");
TrieNode[] memory proof = _parseProof(_proof); TrieNode[] memory proof = _parseProof(_proof);
bytes memory key = Bytes.toNibbles(_key); bytes memory key = Bytes.toNibbles(_key);
bytes memory currentNodeID = abi.encodePacked(_root); bytes memory currentNodeID = abi.encodePacked(_root);
......
...@@ -628,6 +628,25 @@ contract FFIInterface is Test { ...@@ -628,6 +628,25 @@ contract FFIInterface is Test {
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (uint256, uint256)); return abi.decode(result, (uint256, uint256));
} }
function getMerkleTrieFuzzCase(string memory variant)
external
returns (
bytes32,
bytes memory,
bytes memory,
bytes[] memory
)
{
string[] memory cmds = new string[](5);
cmds[0] = "./go-fuzz/fuzz";
cmds[1] = "-m";
cmds[2] = "trie";
cmds[3] = "-v";
cmds[4] = variant;
return abi.decode(vm.ffi(cmds), (bytes32, bytes, bytes, bytes[]));
}
} }
// Used for testing a future upgrade beyond the current implementations. // Used for testing a future upgrade beyond the current implementations.
......
...@@ -17,19 +17,20 @@ ...@@ -17,19 +17,20 @@
"build:forge": "forge build", "build:forge": "forge build",
"build:with-metadata": "FOUNDRY_PROFILE=echidna yarn build:forge", "build:with-metadata": "FOUNDRY_PROFILE=echidna yarn build:forge",
"build:differential": "tsc scripts/differential-testing.ts --outDir dist --moduleResolution node --esModuleInterop", "build:differential": "tsc scripts/differential-testing.ts --outDir dist --moduleResolution node --esModuleInterop",
"build:fuzz": "go build -o go-fuzz go-fuzz/cmd/fuzz.go",
"prebuild": "yarn ts-node scripts/verify-foundry-install.ts", "prebuild": "yarn ts-node scripts/verify-foundry-install.ts",
"build": "hardhat compile && yarn autogen:artifacts && yarn build:ts && yarn typechain", "build": "hardhat compile && yarn autogen:artifacts && yarn build:ts && yarn typechain",
"build:ts": "tsc -p tsconfig.build.json", "build:ts": "tsc -p tsconfig.build.json",
"autogen:artifacts": "ts-node scripts/generate-artifacts.ts", "autogen:artifacts": "ts-node scripts/generate-artifacts.ts",
"deploy": "hardhat deploy", "deploy": "hardhat deploy",
"test": "yarn build:differential && forge test", "test": "yarn build:differential && yarn build:fuzz && forge test",
"coverage": "yarn build:differential && forge coverage", "coverage": "yarn build:differential && yarn build:fuzz && forge coverage",
"coverage:lcov": "yarn build:differential && forge coverage --report lcov", "coverage:lcov": "yarn build:differential && yarn build:fuzz && forge coverage --report lcov",
"gas-snapshot": "yarn build:differential && forge snapshot --no-match-test 'testDiff|testFuzz'", "gas-snapshot": "yarn build:differential && yarn build:fuzz && forge snapshot --no-match-test 'testDiff|testFuzz'",
"storage-snapshot": "./scripts/storage-snapshot.sh", "storage-snapshot": "./scripts/storage-snapshot.sh",
"validate-spacers": "hardhat validate-spacers", "validate-spacers": "hardhat validate-spacers",
"slither": "./scripts/slither.sh", "slither": "./scripts/slither.sh",
"clean": "rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./src/contract-artifacts.ts", "clean": "rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./src/contract-artifacts.ts ./go-fuzz/fuzz",
"lint:ts:check": "eslint . --max-warnings=0", "lint:ts:check": "eslint . --max-warnings=0",
"lint:forge-tests:check": "ts-node scripts/forge-test-names.ts", "lint:forge-tests:check": "ts-node scripts/forge-test-names.ts",
"lint:contracts:check": "yarn solhint -f table 'contracts/**/*.sol' && yarn lint:forge-tests:check", "lint:contracts:check": "yarn solhint -f table 'contracts/**/*.sol' && yarn lint:forge-tests:check",
......
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