Skip to content

0xdevant/stakeland

Repository files navigation

Stakeland

This repository contains the core smart contracts for the Stakeland Protocol.

Getting started

  1. Run forge --version to verify your installation of Foundry. If you haven't installed Foundry on your machine, click here
  2. Run yarn to install dependencies
  3. Run cp .env.example .env to create a .env file from example and input the respective values inside
  4. Run yarn build to get the ABI and artifacts of contracts
  5. [Optional]If you are using VS Code, it is recommended to install Hardhat Solidity extensions by Nomic Foundation (Click here)
  6. Install Solidity extensions by Juan Blanco (For auto formatting .sol files using Forge)
  7. That's it! You can start development with Hardhat and run test with Foundry

Test

  1. Go through Getting started to ensure necessary dependencies are installed
  2. Run yarn test:cache:apply to copy committed cache to foundry for fork testing
  3. Run yarn test or yarn test:watch

NB: console.log won't work on Foundry Fuzz Tests

For any new test that gets updated blockchain data from RPC

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

Reasons we use PRB-Test over Foundry's DSTest

https://github.com/PaulRBerg/prb-test#why-choose-prbtest-over-dstest

Unable to get blockchain data from RPC

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 using test:cache:update to repo and commit afterwards

About

A liquid-staking protocol that aims to be more efficient than Lido.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published