Solidity implementations of the Nomad Bridge.
yarn build: compile smart contracts and create definitions for the SDK
For testing, we use Foundry.
yarn build:accumulator-clifrom the root directory of the monorepo. It will build a rust-based cli tool that creates Sparse Merkle Tree proofs for arbitrary data. It's used in our testing suite via the
--ffiflag for Forge. The binary is built in there
/scriptstop-level directory of the monorepo
--ffimeans that Forge will run arbitrary shell commands as part of the testing suite. You should never run
forge --ffiwithout knowing what exactly are the shell commands that will be executed, as the testing suite could be malicious and execute malicious commands. This is why the feature is disabled by default and must be explicitly enabled.
yarn test:unitwill run all unit tests. Note that
--ffiis enabled by default,
yarn snapshotwill create a new
.gas-snapshot. You can inspect the different gas usage via
- 'yarn snapshot:check' will run the test suite and check gas consumption against the existing
.gas-snapshot. It will
passonly if there is no change in the gas consumption
yarn gen-proofwill execute the
- Define feature
- Write tests based on Foundry best practices and the existing test structure
- Run test suite with
FOUNDRY_PROFILE=bridge forge test --ffi -vvvand verify that your new tests
- Write the new feature
- Run again the test suite and verify that the tests
yarn snapshotto produce the new gas snapshot. You can't use
yarn snapshot:check, since you added new tests that are not present in the current
.gas-snapshot. Gas snapshots showcase how much gas your tests consume and are useful to serve as a benchmark for the gas consumption of your code. As you write new features and/or refactor your code, the gas snapshot can change, illustrating where your changes affected the already defined codepaths. You can read more about gas snapshots on the Foyndry book
yarn storage-inspect:checkto see if the storage layout of the smart contracts have changed. If it has, this could potentially create problems in the upgrade process. If the new layout is correct, run
yarn storage-inspect:generateto create a new layout file (replacing the old one) and commit the new file. If we don't commit the new layout, the CI will fail.
Tip: It is advised to run the forge commands on their own and not via
npm for faster development cycle.
yarn will add a few seconds of lag, due to the fact that it has to spin up a
Node runtime and the interpret the
yarn source code.
We suggest all contributors to use slither while developing, to avoid common mistakes.
- Install Slither
We use a
yarn command because we need to link the top-level
node_modules directory in the
bridge-contracts package. It's a known issue for which the workaround is to link the directory.
The NFT Accountant is a system for recording unbridging events on Ethereum.
Users receive an NFT representing the amount being unbridged. Users can use this NFT to recover funds on a continual basis.