This repository contains the core smart contracts for the Stakeland Protocol.
- Run
forge --versionto verify your installation of Foundry. If you haven't installed Foundry on your machine, click here - Run
yarnto install dependencies - Run
cp .env.example .envto create a.envfile from example and input the respective values inside - Run
yarn buildto get the ABI and artifacts of contracts - [Optional]If you are using VS Code, it is recommended to install Hardhat Solidity extensions by Nomic Foundation (Click here)
- Install Solidity extensions by Juan Blanco (For auto formatting .sol files using
Forge) - That's it! You can start development with Hardhat and run test with Foundry
- Go through
Getting startedto ensure necessary dependencies are installed - Run
yarn test:cache:applyto copy committed cache to foundry for fork testing - Run
yarn testoryarn test:watch
NB: console.log won't work on Foundry Fuzz Tests
If you have updated cache from rpc, make sure you commit the latest cache to repo by running yarn test:cache:update.
So when others apply the cache, they will have the latest cache and no need for them to get blockchain data from RPC
https://github.com/PaulRBerg/prb-test#why-choose-prbtest-over-dstest
In fork testing, we are forking states from remote to local and Foundry creates a local cache to allow reusing the
necessary states for testing. We have specified block SEPOLIA_BLOCK_NO = 5567682 in Constants.sol to lock the
contract states on Sepolia to ensure fork tests won't fail. Though we have committed cache that we can apply. As new
test cases are added, it's possible Foundry needs to retrieve more states from RPC. As you try to get blockchain data
from RPC, it's likely that you will encounter the RPC error missing trie node ... (path ) <nil>, data: None'. This
happens when you try to querying for a state past the immediately previous 16-128 blocks and this often requires an
archive node. There are 2 fixes:
- Click here to register for a RPC URL that supports archive node. They provide querying of archive data for free (At least for now).
- Use specified block by
setUpSepoliaFork(uint256 blockNo)and save the newly created cache usingtest:cache:updateto repo and commit afterwards