│ └── <ahref="./trie">trie</a>: Utility for generating random merkle trie roots / inclusion proofs
│ ├── <ahref="./trie.go">trie</a>: Utility for generating random merkle trie roots / inclusion proofs
│ └── <ahref="./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.
### In a Forge Test
To use `go-ffi` in a forge test, simply invoke the binary via the `vm.ffi` cheatcode.
```solidity
function myFFITest() public {
string[] memory commands = new string[](3);
commands[0] = "./scripts/go-ffi/go-ffi";
commands[1] = "trie";
commands[2] = "valid";
bytes memory result = vm.ffi(commands);
// Do something with the result of the command
}
```
### Available Modes
### Available Modes
There are two modes available in `go-ffi`: `diff` and `trie`. Each are present as a subcommand to the `go-ffi` binary, with their own set of variants.
| `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 |