Commit 01ec03a8 authored by clabby's avatar clabby

Cleanup ctb's ffi utils

parent 6911bdc7
...@@ -307,81 +307,81 @@ LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12957) ...@@ -307,81 +307,81 @@ LegacyERC20ETH_Test:test_transferFrom_doesNotExist_reverts() (gas: 12957)
LegacyERC20ETH_Test:test_transfer_doesNotExist_reverts() (gas: 10755) LegacyERC20ETH_Test:test_transfer_doesNotExist_reverts() (gas: 10755)
LegacyMessagePasser_Test:test_passMessageToL1_succeeds() (gas: 34524) LegacyMessagePasser_Test:test_passMessageToL1_succeeds() (gas: 34524)
LibPosition_Test:test_pos_correctness_succeeds() (gas: 38689) LibPosition_Test:test_pos_correctness_succeeds() (gas: 38689)
MIPS_Test:test_add_succeeds() (gas: 122466) MIPS_Test:test_add_succeeds() (gas: 122932)
MIPS_Test:test_addiSign_succeeds() (gas: 122457) MIPS_Test:test_addiSign_succeeds() (gas: 122923)
MIPS_Test:test_addi_succeeds() (gas: 122654) MIPS_Test:test_addi_succeeds() (gas: 123120)
MIPS_Test:test_addu_succeeds() (gas: 122508) MIPS_Test:test_addu_succeeds() (gas: 122974)
MIPS_Test:test_addui_succeeds() (gas: 122716) MIPS_Test:test_addui_succeeds() (gas: 123182)
MIPS_Test:test_and_succeeds() (gas: 122527) MIPS_Test:test_and_succeeds() (gas: 122993)
MIPS_Test:test_andi_succeeds() (gas: 122460) MIPS_Test:test_andi_succeeds() (gas: 122926)
MIPS_Test:test_beq_succeeds() (gas: 202893) MIPS_Test:test_beq_succeeds() (gas: 203359)
MIPS_Test:test_bgez_succeeds() (gas: 121753) MIPS_Test:test_bgez_succeeds() (gas: 122219)
MIPS_Test:test_bgtz_succeeds() (gas: 121674) MIPS_Test:test_bgtz_succeeds() (gas: 122140)
MIPS_Test:test_blez_succeeds() (gas: 121630) MIPS_Test:test_blez_succeeds() (gas: 122096)
MIPS_Test:test_bltz_succeeds() (gas: 121773) MIPS_Test:test_bltz_succeeds() (gas: 122239)
MIPS_Test:test_bne_succeeds() (gas: 121839) MIPS_Test:test_bne_succeeds() (gas: 122305)
MIPS_Test:test_branch_inDelaySlot_fails() (gas: 86048) MIPS_Test:test_branch_inDelaySlot_fails() (gas: 86514)
MIPS_Test:test_brk_succeeds() (gas: 122143) MIPS_Test:test_brk_succeeds() (gas: 122609)
MIPS_Test:test_clo_succeeds() (gas: 122195) MIPS_Test:test_clo_succeeds() (gas: 122661)
MIPS_Test:test_clone_succeeds() (gas: 122096) MIPS_Test:test_clone_succeeds() (gas: 122562)
MIPS_Test:test_clz_succeeds() (gas: 122666) MIPS_Test:test_clz_succeeds() (gas: 123132)
MIPS_Test:test_div_succeeds() (gas: 122645) MIPS_Test:test_div_succeeds() (gas: 123111)
MIPS_Test:test_divu_succeeds() (gas: 122630) MIPS_Test:test_divu_succeeds() (gas: 123096)
MIPS_Test:test_exit_succeeds() (gas: 122145) MIPS_Test:test_exit_succeeds() (gas: 122611)
MIPS_Test:test_fcntl_succeeds() (gas: 204375) MIPS_Test:test_fcntl_succeeds() (gas: 204841)
MIPS_Test:test_illegal_instruction_fails() (gas: 91511) MIPS_Test:test_illegal_instruction_fails() (gas: 91977)
MIPS_Test:test_invalid_root_fails() (gas: 435685) MIPS_Test:test_invalid_root_fails() (gas: 436151)
MIPS_Test:test_jal_nonzeroRegion_succeeds() (gas: 120783) MIPS_Test:test_jal_nonzeroRegion_succeeds() (gas: 121249)
MIPS_Test:test_jal_succeeds() (gas: 120772) MIPS_Test:test_jal_succeeds() (gas: 121238)
MIPS_Test:test_jalr_succeeds() (gas: 121891) MIPS_Test:test_jalr_succeeds() (gas: 122357)
MIPS_Test:test_jr_succeeds() (gas: 121585) MIPS_Test:test_jr_succeeds() (gas: 122051)
MIPS_Test:test_jump_inDelaySlot_fails() (gas: 85416) MIPS_Test:test_jump_inDelaySlot_fails() (gas: 85882)
MIPS_Test:test_jump_nonzeroRegion_succeeds() (gas: 120527) MIPS_Test:test_jump_nonzeroRegion_succeeds() (gas: 120993)
MIPS_Test:test_jump_succeeds() (gas: 120457) MIPS_Test:test_jump_succeeds() (gas: 120923)
MIPS_Test:test_lb_succeeds() (gas: 127698) MIPS_Test:test_lb_succeeds() (gas: 128164)
MIPS_Test:test_lbu_succeeds() (gas: 127596) MIPS_Test:test_lbu_succeeds() (gas: 128062)
MIPS_Test:test_lh_succeeds() (gas: 127719) MIPS_Test:test_lh_succeeds() (gas: 128185)
MIPS_Test:test_lhu_succeeds() (gas: 127636) MIPS_Test:test_lhu_succeeds() (gas: 128102)
MIPS_Test:test_ll_succeeds() (gas: 127858) MIPS_Test:test_ll_succeeds() (gas: 128324)
MIPS_Test:test_lui_succeeds() (gas: 121739) MIPS_Test:test_lui_succeeds() (gas: 122205)
MIPS_Test:test_lw_succeeds() (gas: 127487) MIPS_Test:test_lw_succeeds() (gas: 127953)
MIPS_Test:test_lwl_succeeds() (gas: 242138) MIPS_Test:test_lwl_succeeds() (gas: 243070)
MIPS_Test:test_lwr_succeeds() (gas: 242426) MIPS_Test:test_lwr_succeeds() (gas: 243358)
MIPS_Test:test_mfhi_succeeds() (gas: 122100) MIPS_Test:test_mfhi_succeeds() (gas: 122566)
MIPS_Test:test_mflo_succeeds() (gas: 122229) MIPS_Test:test_mflo_succeeds() (gas: 122695)
MIPS_Test:test_mmap_succeeds() (gas: 119063) MIPS_Test:test_mmap_succeeds() (gas: 119529)
MIPS_Test:test_movn_succeeds() (gas: 203565) MIPS_Test:test_movn_succeeds() (gas: 204031)
MIPS_Test:test_movz_succeeds() (gas: 203433) MIPS_Test:test_movz_succeeds() (gas: 203899)
MIPS_Test:test_mthi_succeeds() (gas: 122144) MIPS_Test:test_mthi_succeeds() (gas: 122610)
MIPS_Test:test_mtlo_succeeds() (gas: 122252) MIPS_Test:test_mtlo_succeeds() (gas: 122718)
MIPS_Test:test_mul_succeeds() (gas: 121744) MIPS_Test:test_mul_succeeds() (gas: 122210)
MIPS_Test:test_mult_succeeds() (gas: 122448) MIPS_Test:test_mult_succeeds() (gas: 122914)
MIPS_Test:test_multu_succeeds() (gas: 122485) MIPS_Test:test_multu_succeeds() (gas: 122951)
MIPS_Test:test_nor_succeeds() (gas: 122577) MIPS_Test:test_nor_succeeds() (gas: 123043)
MIPS_Test:test_or_succeeds() (gas: 122534) MIPS_Test:test_or_succeeds() (gas: 123000)
MIPS_Test:test_ori_succeeds() (gas: 122537) MIPS_Test:test_ori_succeeds() (gas: 123003)
MIPS_Test:test_preimage_read_succeeds() (gas: 234549) MIPS_Test:test_preimage_read_succeeds() (gas: 235481)
MIPS_Test:test_preimage_write_succeeds() (gas: 127085) MIPS_Test:test_preimage_write_succeeds() (gas: 127551)
MIPS_Test:test_prestate_exited_succeeds() (gas: 113326) MIPS_Test:test_prestate_exited_succeeds() (gas: 113792)
MIPS_Test:test_sb_succeeds() (gas: 160569) MIPS_Test:test_sb_succeeds() (gas: 161501)
MIPS_Test:test_sc_succeeds() (gas: 160752) MIPS_Test:test_sc_succeeds() (gas: 161684)
MIPS_Test:test_sh_succeeds() (gas: 160606) MIPS_Test:test_sh_succeeds() (gas: 161538)
MIPS_Test:test_sll_succeeds() (gas: 121705) MIPS_Test:test_sll_succeeds() (gas: 122171)
MIPS_Test:test_sllv_succeeds() (gas: 121934) MIPS_Test:test_sllv_succeeds() (gas: 122400)
MIPS_Test:test_slt_succeeds() (gas: 204760) MIPS_Test:test_slt_succeeds() (gas: 205226)
MIPS_Test:test_sltu_succeeds() (gas: 122751) MIPS_Test:test_sltu_succeeds() (gas: 123217)
MIPS_Test:test_sra_succeeds() (gas: 121956) MIPS_Test:test_sra_succeeds() (gas: 122422)
MIPS_Test:test_srav_succeeds() (gas: 122224) MIPS_Test:test_srav_succeeds() (gas: 122690)
MIPS_Test:test_srl_succeeds() (gas: 121787) MIPS_Test:test_srl_succeeds() (gas: 122253)
MIPS_Test:test_srlv_succeeds() (gas: 121952) MIPS_Test:test_srlv_succeeds() (gas: 122418)
MIPS_Test:test_step_abi_succeeds() (gas: 58467) MIPS_Test:test_step_abi_succeeds() (gas: 58467)
MIPS_Test:test_sub_succeeds() (gas: 122561) MIPS_Test:test_sub_succeeds() (gas: 123027)
MIPS_Test:test_subu_succeeds() (gas: 122558) MIPS_Test:test_subu_succeeds() (gas: 123024)
MIPS_Test:test_sw_succeeds() (gas: 160581) MIPS_Test:test_sw_succeeds() (gas: 161513)
MIPS_Test:test_swl_succeeds() (gas: 160642) MIPS_Test:test_swl_succeeds() (gas: 161574)
MIPS_Test:test_swr_succeeds() (gas: 160717) MIPS_Test:test_swr_succeeds() (gas: 161649)
MIPS_Test:test_xor_succeeds() (gas: 122562) MIPS_Test:test_xor_succeeds() (gas: 123028)
MIPS_Test:test_xori_succeeds() (gas: 122614) MIPS_Test:test_xori_succeeds() (gas: 123080)
MerkleTrie_get_Test:test_get_corruptedProof_reverts() (gas: 5733) MerkleTrie_get_Test:test_get_corruptedProof_reverts() (gas: 5733)
MerkleTrie_get_Test:test_get_extraProofElements_reverts() (gas: 58889) MerkleTrie_get_Test:test_get_extraProofElements_reverts() (gas: 58889)
MerkleTrie_get_Test:test_get_invalidDataRemainder_reverts() (gas: 35845) MerkleTrie_get_Test:test_get_invalidDataRemainder_reverts() (gas: 35845)
...@@ -447,9 +447,9 @@ OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutp ...@@ -447,9 +447,9 @@ OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutp
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 182306) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifOutputTimestampIsNotFinalized_reverts() (gas: 182306)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41780) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalNotProven_reverts() (gas: 41780)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 173953) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_ifWithdrawalProofNotOldEnough_reverts() (gas: 173953)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 180724) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onInsufficientGas_reverts() (gas: 181188)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 154740) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onRecentWithdrawal_reverts() (gas: 154740)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 218770) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReentrancy_reverts() (gas: 219235)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 220983) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_onReplay_reverts() (gas: 220983)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_paused_reverts() (gas: 38706) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_paused_reverts() (gas: 38706)
OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 209679) OptimismPortal_FinalizeWithdrawal_Test:test_finalizeWithdrawalTransaction_provenWithdrawalHash_succeeds() (gas: 209679)
...@@ -660,9 +660,9 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 171675) ...@@ -660,9 +660,9 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 171675)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11549) SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11549)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936) StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072) StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
Storage_Roundtrip_Test:test_setGetAddress_succeeds(bytes32,address) (runs: 64, μ: 31821, ~: 31821) Storage_Roundtrip_Test:test_setGetAddress_succeeds(bytes32,address) (runs: 64, μ: 31510, ~: 31821)
Storage_Roundtrip_Test:test_setGetBytes32_succeeds(bytes32,bytes32) (runs: 64, μ: 31598, ~: 31598) Storage_Roundtrip_Test:test_setGetBytes32_succeeds(bytes32,bytes32) (runs: 64, μ: 31598, ~: 31598)
Storage_Roundtrip_Test:test_setGetUint_succeeds(bytes32,uint256) (runs: 64, μ: 30731, ~: 31664) Storage_Roundtrip_Test:test_setGetUint_succeeds(bytes32,uint256) (runs: 64, μ: 30420, ~: 31664)
SystemConfig_Initialize_Test:test_initialize_events_succeeds() (gas: 71972) SystemConfig_Initialize_Test:test_initialize_events_succeeds() (gas: 71972)
SystemConfig_Initialize_Test:test_initialize_startBlockNoop_reverts() (gas: 81247) SystemConfig_Initialize_Test:test_initialize_startBlockNoop_reverts() (gas: 81247)
SystemConfig_Initialize_Test:test_initialize_startBlockOverride_succeeds() (gas: 65143) SystemConfig_Initialize_Test:test_initialize_startBlockOverride_succeeds() (gas: 65143)
......
...@@ -9,11 +9,8 @@ typechain ...@@ -9,11 +9,8 @@ typechain
coverage.out coverage.out
.resource-metering.csv .resource-metering.csv
# Tests
test-case-generator/fuzz
# Scripts # Scripts
scripts/differential-testing/differential-testing scripts/go-ffi/go-ffi
# Environment Variables # Environment Variables
.envrc .envrc
......
...@@ -15,14 +15,13 @@ ...@@ -15,14 +15,13 @@
"bindings:go": "pnpm clean && pnpm build && pnpm bindings:go:no-build", "bindings:go": "pnpm clean && pnpm build && pnpm bindings:go:no-build",
"prebuild": "./scripts/verify-foundry-install.sh", "prebuild": "./scripts/verify-foundry-install.sh",
"build": "forge build", "build": "forge build",
"build:differential": "go build -o ./scripts/differential-testing/differential-testing ./scripts/differential-testing", "build:go-ffi": "(cd scripts/go-ffi && go build)",
"build:fuzz": "(cd test-case-generator && go build ./cmd/fuzz.go)",
"autogen:invariant-docs": "npx tsx scripts/invariant-doc-gen.ts", "autogen:invariant-docs": "npx tsx scripts/invariant-doc-gen.ts",
"test": "pnpm build:differential && pnpm build:fuzz && forge test", "test": "pnpm build:go-ffi && forge test",
"coverage": "pnpm build:differential && pnpm build:fuzz && forge coverage", "coverage": "pnpm build:go-ffi && forge coverage",
"coverage:lcov": "pnpm build:differential && pnpm build:fuzz && forge coverage --report lcov", "coverage:lcov": "pnpm build:go-ffi && forge coverage --report lcov",
"gas-snapshot:no-build": "forge snapshot --no-match-test 'testDiff|testFuzz|invariant|generateArtifact'", "gas-snapshot:no-build": "forge snapshot --no-match-test 'testDiff|testFuzz|invariant|generateArtifact'",
"gas-snapshot": "pnpm build:differential && pnpm build:fuzz && pnpm gas-snapshot:no-build", "gas-snapshot": "pnpm build:go-ffi && pnpm gas-snapshot:no-build",
"storage-snapshot": "./scripts/storage-snapshot.sh", "storage-snapshot": "./scripts/storage-snapshot.sh",
"semver-lock": "forge script scripts/SemverLock.s.sol", "semver-lock": "forge script scripts/SemverLock.s.sol",
"validate-deploy-configs": "./scripts/check-deploy-configs.sh", "validate-deploy-configs": "./scripts/check-deploy-configs.sh",
...@@ -30,10 +29,10 @@ ...@@ -30,10 +29,10 @@
"validate-spacers": "pnpm build && pnpm validate-spacers:no-build", "validate-spacers": "pnpm build && pnpm validate-spacers:no-build",
"slither": "./scripts/slither.sh", "slither": "./scripts/slither.sh",
"slither:triage": "TRIAGE_MODE=1 ./scripts/slither.sh", "slither:triage": "TRIAGE_MODE=1 ./scripts/slither.sh",
"clean": "rm -rf ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./test-case-generator/fuzz ./scripts/differential-testing/differential-testing", "clean": "rm -rf ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./scripts/go-ffi/go-ffi",
"preinstall": "npx only-allow pnpm", "preinstall": "npx only-allow pnpm",
"pre-pr:no-build": "pnpm gas-snapshot:no-build && pnpm storage-snapshot && pnpm semver-lock && pnpm autogen:invariant-docs && pnpm lint && pnpm bindings:go", "pre-pr:no-build": "pnpm gas-snapshot:no-build && pnpm storage-snapshot && pnpm semver-lock && pnpm autogen:invariant-docs && pnpm lint && pnpm bindings:go",
"pre-pr": "pnpm clean && pnpm build:differential && pnpm build:fuzz && pnpm build && pnpm pre-pr:no-build", "pre-pr": "pnpm clean && pnpm build:go-ffi && pnpm build && pnpm pre-pr:no-build",
"pre-pr:full": "pnpm test && pnpm slither && pnpm validate-deploy-configs && pnpm validate-spacers && pnpm pre-pr", "pre-pr:full": "pnpm test && pnpm slither && pnpm validate-deploy-configs && pnpm validate-spacers && pnpm pre-pr",
"lint:ts:check": "eslint . --max-warnings=0", "lint:ts:check": "eslint . --max-warnings=0",
"lint:forge-tests:check": "npx tsx scripts/forge-test-names.ts", "lint:forge-tests:check": "npx tsx scripts/forge-test-names.ts",
......
# `ctb-test-case-generator` # `ctb-go-ffi`
A lightweight input fuzzing utility used for testing various Bedrock contracts. A lightweight binary for utilities accessed via `forge`'s `ffi` cheatcode in the `contracts-bedrock` test suite.
<pre> <pre>
├── test-case-generator ├── go-ffi
│ ├── <a href="./cmd">cmd</a>: `ctb-test-case-genertor`'s binary │ ├── <a href="./bin.go">bin</a>: `go-ffi`'s binary
│ └── <a href="./trie">trie</a>: Utility for generating random merkle trie roots / inclusion proofs │ ├── <a href="./trie.go">trie</a>: Utility for generating random merkle trie roots / inclusion proofs
│ └── <a href="./differential-testing.go">diff-testing</a>: Utility for differential testing Solidity implementations against their respective Go implementations.
</pre> </pre>
## Usage ## Usage
To build, run `pnpm build:fuzz` from this directory or the `contract-bedrock` package. To build, run `pnpm build:go-ffi` from this directory or the `contract-bedrock` package.
To generate an abi-encoded fuzz case, pass in a mode via the `-m` flag as well as an optional variant via the `-v` flag.
### Available Modes ### Available Modes
#### `diff`
> **Note**
> Variant required for diff mode.
| Variant | Description |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------
| `decodeVersionedNonce` | Decodes a versioned nonce and prints the decoded arguments |
| `encodeCrossDomainMessage` | Encodes a cross domain message and prints the encoded message |
| `hashCrossDomainMessage` | Encodes and hashes a cross domain message and prints the digest |
| `hashDepositTransaction` | Encodes and hashes a deposit transaction and prints the digest |
| `encodeDepositTransaction` | RLP encodes a deposit transaction |
| `hashWithdrawal` | Hashes a withdrawal message and prints the digest |
| `hashOutputRootProof` | Hashes an output root proof and prints the digest |
| `getProveWithdrawalTransactionInputs` | Generates the inputs for a `getProveWithdrawalTransaction` call to the `OptimismPortal` given a withdrawal message |
| `cannonMemoryProof` | Computes a merkle proof of Cannon's memory |
#### `trie` #### `trie`
> **Note** > **Note**
......
package main
import "os"
func main() {
switch os.Args[1] {
case "diff":
DiffTestUtils()
case "trie":
FuzzTrie()
}
}
...@@ -74,8 +74,8 @@ var ( ...@@ -74,8 +74,8 @@ var (
} }
) )
func main() { func DiffTestUtils() {
args := os.Args[1:] args := os.Args[2:]
// This command requires arguments // This command requires arguments
if len(args) == 0 { if len(args) == 0 {
......
package trie package main
import ( import (
"crypto/rand" "crypto/rand"
"fmt" "fmt"
"log" "log"
"math/big" "math/big"
"os"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethdb/memorydb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/trie"
) )
...@@ -39,7 +40,8 @@ const ( ...@@ -39,7 +40,8 @@ const (
) )
// Generate an abi-encoded `trieTestCase` of a specified variant // Generate an abi-encoded `trieTestCase` of a specified variant
func FuzzTrie(variant string) { func FuzzTrie() {
variant := os.Args[2]
if len(variant) < 1 { if len(variant) < 1 {
log.Fatal("Must pass a variant to the trie fuzzer!") log.Fatal("Must pass a variant to the trie fuzzer!")
} }
...@@ -132,8 +134,8 @@ func FuzzTrie(variant string) { ...@@ -132,8 +134,8 @@ func FuzzTrie(variant string) {
// Generate a random test case for Bedrock's MerkleTrie verifier. // Generate a random test case for Bedrock's MerkleTrie verifier.
func genTrieTestCase(selectEmptyKey bool) trieTestCase { func genTrieTestCase(selectEmptyKey bool) trieTestCase {
// Create an empty merkle trie // Create an empty merkle trie
memdb := memorydb.New() memdb := rawdb.NewMemoryDatabase()
randTrie := trie.NewEmpty(trie.NewDatabase(memdb)) randTrie := trie.NewEmpty(trie.NewDatabase(memdb, nil))
// Get a random number of elements to put into the trie // Get a random number of elements to put into the trie
randN := randRange(2, 1024) randN := randRange(2, 1024)
...@@ -161,7 +163,7 @@ func genTrieTestCase(selectEmptyKey bool) trieTestCase { ...@@ -161,7 +163,7 @@ func genTrieTestCase(selectEmptyKey bool) trieTestCase {
} }
// Insert the random k/v pair into the trie // Insert the random k/v pair into the trie
if err := randTrie.TryUpdate(randKey, randValue); err != nil { if err := randTrie.Update(randKey, randValue); err != nil {
log.Fatal("Error adding key-value pair to trie") log.Fatal("Error adding key-value pair to trie")
} }
...@@ -174,7 +176,7 @@ func genTrieTestCase(selectEmptyKey bool) trieTestCase { ...@@ -174,7 +176,7 @@ func genTrieTestCase(selectEmptyKey bool) trieTestCase {
// Generate proof for `key`'s inclusion in our trie // Generate proof for `key`'s inclusion in our trie
var proof proofList var proof proofList
if err := randTrie.Prove(key, 0, &proof); err != nil { if err := randTrie.Prove(key, &proof); err != nil {
log.Fatal("Error creating proof for randomly selected key's inclusion in generated trie") log.Fatal("Error creating proof for randomly selected key's inclusion in generated trie")
} }
...@@ -233,15 +235,3 @@ func randRange(min int64, max int64) int64 { ...@@ -233,15 +235,3 @@ func randRange(min int64, max int64) int64 {
return (new(big.Int).Add(r, new(big.Int).SetInt64(min))).Int64() return (new(big.Int).Add(r, new(big.Int).SetInt64(min))).Int64()
} }
// Custom type to write the generated proof to
type proofList [][]byte
func (n *proofList) Put(key []byte, value []byte) error {
*n = append(*n, value)
return nil
}
func (n *proofList) Delete(key []byte) error {
panic("not supported")
}
package main
import (
"flag"
"log"
t "github.com/ethereum-optimism/optimism/packages/contracts-bedrock/ctb-test-case-generator/trie"
)
// Mode enum
const (
// Enables the `trie` fuzzer
trie string = "trie"
)
func main() {
mode := flag.String("m", "", "Fuzzer mode")
variant := flag.String("v", "", "Mode variant")
flag.Parse()
if len(*mode) < 1 {
log.Fatal("Must pass a mode for the fuzzer!")
}
switch *mode {
case trie:
t.FuzzTrie(*variant)
default:
log.Fatal("Invalid mode!")
}
}
module github.com/ethereum-optimism/optimism/packages/contracts-bedrock/ctb-test-case-generator
go 1.20
require github.com/ethereum/go-ethereum v1.10.26
require (
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/VictoriaMetrics/fastcache v1.6.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
)
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s=
github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA=
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4=
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
...@@ -502,15 +502,16 @@ contract FFIInterface is Test { ...@@ -502,15 +502,16 @@ contract FFIInterface is Test {
external external
returns (bytes32, bytes32, bytes32, bytes32, bytes[] memory) returns (bytes32, bytes32, bytes32, bytes32, bytes[] memory)
{ {
string[] memory cmds = new string[](8); string[] memory cmds = new string[](9);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "getProveWithdrawalTransactionInputs"; cmds[1] = "diff";
cmds[2] = vm.toString(_tx.nonce); cmds[2] = "getProveWithdrawalTransactionInputs";
cmds[3] = vm.toString(_tx.sender); cmds[3] = vm.toString(_tx.nonce);
cmds[4] = vm.toString(_tx.target); cmds[4] = vm.toString(_tx.sender);
cmds[5] = vm.toString(_tx.value); cmds[5] = vm.toString(_tx.target);
cmds[6] = vm.toString(_tx.gasLimit); cmds[6] = vm.toString(_tx.value);
cmds[7] = vm.toString(_tx.data); cmds[7] = vm.toString(_tx.gasLimit);
cmds[8] = vm.toString(_tx.data);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
( (
...@@ -535,15 +536,16 @@ contract FFIInterface is Test { ...@@ -535,15 +536,16 @@ contract FFIInterface is Test {
external external
returns (bytes32) returns (bytes32)
{ {
string[] memory cmds = new string[](8); string[] memory cmds = new string[](9);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "hashCrossDomainMessage"; cmds[1] = "diff";
cmds[2] = vm.toString(_nonce); cmds[2] = "hashCrossDomainMessage";
cmds[3] = vm.toString(_sender); cmds[3] = vm.toString(_nonce);
cmds[4] = vm.toString(_target); cmds[4] = vm.toString(_sender);
cmds[5] = vm.toString(_value); cmds[5] = vm.toString(_target);
cmds[6] = vm.toString(_gasLimit); cmds[6] = vm.toString(_value);
cmds[7] = vm.toString(_data); cmds[7] = vm.toString(_gasLimit);
cmds[8] = vm.toString(_data);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes32)); return abi.decode(result, (bytes32));
...@@ -560,15 +562,16 @@ contract FFIInterface is Test { ...@@ -560,15 +562,16 @@ contract FFIInterface is Test {
external external
returns (bytes32) returns (bytes32)
{ {
string[] memory cmds = new string[](8); string[] memory cmds = new string[](9);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "hashWithdrawal"; cmds[1] = "diff";
cmds[2] = vm.toString(_nonce); cmds[2] = "hashWithdrawal";
cmds[3] = vm.toString(_sender); cmds[3] = vm.toString(_nonce);
cmds[4] = vm.toString(_target); cmds[4] = vm.toString(_sender);
cmds[5] = vm.toString(_value); cmds[5] = vm.toString(_target);
cmds[6] = vm.toString(_gasLimit); cmds[6] = vm.toString(_value);
cmds[7] = vm.toString(_data); cmds[7] = vm.toString(_gasLimit);
cmds[8] = vm.toString(_data);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes32)); return abi.decode(result, (bytes32));
...@@ -583,13 +586,14 @@ contract FFIInterface is Test { ...@@ -583,13 +586,14 @@ contract FFIInterface is Test {
external external
returns (bytes32) returns (bytes32)
{ {
string[] memory cmds = new string[](6); string[] memory cmds = new string[](7);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "hashOutputRootProof"; cmds[1] = "diff";
cmds[2] = Strings.toHexString(uint256(_version)); cmds[2] = "hashOutputRootProof";
cmds[3] = Strings.toHexString(uint256(_stateRoot)); cmds[3] = Strings.toHexString(uint256(_version));
cmds[4] = Strings.toHexString(uint256(_messagePasserStorageRoot)); cmds[4] = Strings.toHexString(uint256(_stateRoot));
cmds[5] = Strings.toHexString(uint256(_latestBlockhash)); cmds[5] = Strings.toHexString(uint256(_messagePasserStorageRoot));
cmds[6] = Strings.toHexString(uint256(_latestBlockhash));
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes32)); return abi.decode(result, (bytes32));
...@@ -607,35 +611,37 @@ contract FFIInterface is Test { ...@@ -607,35 +611,37 @@ contract FFIInterface is Test {
external external
returns (bytes32) returns (bytes32)
{ {
string[] memory cmds = new string[](10); string[] memory cmds = new string[](11);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "hashDepositTransaction"; cmds[1] = "diff";
cmds[2] = "0x0000000000000000000000000000000000000000000000000000000000000000"; cmds[2] = "hashDepositTransaction";
cmds[3] = vm.toString(_logIndex); cmds[3] = "0x0000000000000000000000000000000000000000000000000000000000000000";
cmds[4] = vm.toString(_from); cmds[4] = vm.toString(_logIndex);
cmds[5] = vm.toString(_to); cmds[5] = vm.toString(_from);
cmds[6] = vm.toString(_mint); cmds[6] = vm.toString(_to);
cmds[7] = vm.toString(_value); cmds[7] = vm.toString(_mint);
cmds[8] = vm.toString(_gas); cmds[8] = vm.toString(_value);
cmds[9] = vm.toString(_data); cmds[9] = vm.toString(_gas);
cmds[10] = vm.toString(_data);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes32)); return abi.decode(result, (bytes32));
} }
function encodeDepositTransaction(Types.UserDepositTransaction calldata txn) external returns (bytes memory) { function encodeDepositTransaction(Types.UserDepositTransaction calldata txn) external returns (bytes memory) {
string[] memory cmds = new string[](11); string[] memory cmds = new string[](12);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "encodeDepositTransaction"; cmds[1] = "diff";
cmds[2] = vm.toString(txn.from); cmds[2] = "encodeDepositTransaction";
cmds[3] = vm.toString(txn.to); cmds[3] = vm.toString(txn.from);
cmds[4] = vm.toString(txn.value); cmds[4] = vm.toString(txn.to);
cmds[5] = vm.toString(txn.mint); cmds[5] = vm.toString(txn.value);
cmds[6] = vm.toString(txn.gasLimit); cmds[6] = vm.toString(txn.mint);
cmds[7] = vm.toString(txn.isCreation); cmds[7] = vm.toString(txn.gasLimit);
cmds[8] = vm.toString(txn.data); cmds[8] = vm.toString(txn.isCreation);
cmds[9] = vm.toString(txn.l1BlockHash); cmds[9] = vm.toString(txn.data);
cmds[10] = vm.toString(txn.logIndex); cmds[10] = vm.toString(txn.l1BlockHash);
cmds[11] = vm.toString(txn.logIndex);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes)); return abi.decode(result, (bytes));
...@@ -652,25 +658,27 @@ contract FFIInterface is Test { ...@@ -652,25 +658,27 @@ contract FFIInterface is Test {
external external
returns (bytes memory) returns (bytes memory)
{ {
string[] memory cmds = new string[](8); string[] memory cmds = new string[](9);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "encodeCrossDomainMessage"; cmds[1] = "diff";
cmds[2] = vm.toString(_nonce); cmds[2] = "encodeCrossDomainMessage";
cmds[3] = vm.toString(_sender); cmds[3] = vm.toString(_nonce);
cmds[4] = vm.toString(_target); cmds[4] = vm.toString(_sender);
cmds[5] = vm.toString(_value); cmds[5] = vm.toString(_target);
cmds[6] = vm.toString(_gasLimit); cmds[6] = vm.toString(_value);
cmds[7] = vm.toString(_data); cmds[7] = vm.toString(_gasLimit);
cmds[8] = vm.toString(_data);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (bytes)); return abi.decode(result, (bytes));
} }
function decodeVersionedNonce(uint256 nonce) external returns (uint256, uint256) { function decodeVersionedNonce(uint256 nonce) external returns (uint256, uint256) {
string[] memory cmds = new string[](3); string[] memory cmds = new string[](4);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "decodeVersionedNonce"; cmds[1] = "diff";
cmds[2] = vm.toString(nonce); cmds[2] = "decodeVersionedNonce";
cmds[3] = vm.toString(nonce);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
return abi.decode(result, (uint256, uint256)); return abi.decode(result, (uint256, uint256));
...@@ -680,22 +688,21 @@ contract FFIInterface is Test { ...@@ -680,22 +688,21 @@ contract FFIInterface is Test {
external external
returns (bytes32, bytes memory, bytes memory, bytes[] memory) returns (bytes32, bytes memory, bytes memory, bytes[] memory)
{ {
string[] memory cmds = new string[](5); string[] memory cmds = new string[](6);
cmds[0] = "./test-case-generator/fuzz"; cmds[0] = "./scripts/go-ffi/go-ffi";
cmds[1] = "-m"; cmds[1] = "trie";
cmds[2] = "trie"; cmds[2] = variant;
cmds[3] = "-v";
cmds[4] = variant;
return abi.decode(vm.ffi(cmds), (bytes32, bytes, bytes, bytes[])); return abi.decode(vm.ffi(cmds), (bytes32, bytes, bytes, bytes[]));
} }
function getCannonMemoryProof(uint32 pc, uint32 insn) external returns (bytes32, bytes memory) { function getCannonMemoryProof(uint32 pc, uint32 insn) external returns (bytes32, bytes memory) {
string[] memory cmds = new string[](4); string[] memory cmds = new string[](5);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "cannonMemoryProof"; cmds[1] = "diff";
cmds[2] = vm.toString(pc); cmds[2] = "cannonMemoryProof";
cmds[3] = vm.toString(insn); cmds[3] = vm.toString(pc);
cmds[4] = vm.toString(insn);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
(bytes32 memRoot, bytes memory proof) = abi.decode(result, (bytes32, bytes)); (bytes32 memRoot, bytes memory proof) = abi.decode(result, (bytes32, bytes));
return (memRoot, proof); return (memRoot, proof);
...@@ -710,13 +717,14 @@ contract FFIInterface is Test { ...@@ -710,13 +717,14 @@ contract FFIInterface is Test {
external external
returns (bytes32, bytes memory) returns (bytes32, bytes memory)
{ {
string[] memory cmds = new string[](6); string[] memory cmds = new string[](7);
cmds[0] = "scripts/differential-testing/differential-testing"; cmds[0] = "scripts/go-ffi/go-ffi";
cmds[1] = "cannonMemoryProof"; cmds[1] = "diff";
cmds[2] = vm.toString(pc); cmds[2] = "cannonMemoryProof";
cmds[3] = vm.toString(insn); cmds[3] = vm.toString(pc);
cmds[4] = vm.toString(memAddr); cmds[4] = vm.toString(insn);
cmds[5] = vm.toString(memVal); cmds[5] = vm.toString(memAddr);
cmds[6] = vm.toString(memVal);
bytes memory result = vm.ffi(cmds); bytes memory result = vm.ffi(cmds);
(bytes32 memRoot, bytes memory proof) = abi.decode(result, (bytes32, bytes)); (bytes32 memRoot, bytes memory proof) = abi.decode(result, (bytes32, bytes));
return (memRoot, proof); return (memRoot, proof);
......
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