csm-test-tree
v1.1.0
Published
Merkle tree builder for Lido CSM
Readme
CSM Test Tree
A Node.js/TypeScript utility for generating and managing Merkle trees for Lido's Community Staking Module (CSM). This tool handles two types of data: addresses for ICS (Initial Custody Service) and node operator strikes tracking.
Overview
The CSM Test Tree tool creates Merkle trees from JSON data, uploads them to IPFS via Pinata, and updates smart contracts with the new tree parameters. It supports two workflows:
- ICS: Manages Ethereum addresses for vetted gate access
- Strikes: Tracks node operator performance violations
Prerequisites
- Node.js and npm installed
- Foundry with
castcommand available - Pinata account for IPFS uploads
- Access to deployed contracts (VettedGate and CSStrikes)
Setup
Install dependencies:
npm installCreate a
.envfile with required variables:PINATA_API_KEY=your_pinata_api_key PINATA_API_SECRET=your_pinata_secret DEPLOY_JSON_PATH=path/to/your/deploy.jsonEnsure your deployment JSON contains contract addresses:
{ "VettedGate": "0x...", "CSStrikes": "0x..." }
Data Files
addresses.json
Contains an array of Ethereum addresses for ICS whitelist:
[
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
]strikes.json
Contains node operator strike data:
[
{
"nodeOperatorId": 4,
"pubkey": "0x8a1c6881aa97ac4e31694e42f837cd510355fed4760ac2495bb4d4b0df4ce2ce78bb27ee145e284563cb8582f7ee14e7",
"strikes": [0, 0, 0, 0, 0, 1]
}
]Usage
Main Commands
Run the complete ICS workflow (generate tree + update contract):
npm run icsRun the complete strikes workflow (generate tree + update contract):
npm run strikesIndividual Steps
Generate ICS Merkle tree only:
npm run make-icsUpdate VettedGate contract only:
npm run set-icsGenerate strikes Merkle tree only:
npm run make-strikesUpdate CSStrikes contract only:
npm run set-strikesHow It Works
- Tree Generation: Creates OpenZeppelin StandardMerkleTree from JSON data
- IPFS Upload: Uploads tree structure to Pinata IPFS
- Config Storage: Saves tree root and IPFS CID to
tmp/config-*.json - Contract Update: Uses Foundry's
castto update smart contracts with new parameters
Output
After running the commands, you'll see:
- Tree root hash
- IPFS CID
- Updated configuration files in
tmp/directory - Contract transaction results
Troubleshooting
- Ensure all environment variables are set correctly
- Verify contract addresses in your deployment JSON
- Check that Anvil is running if testing locally
- Confirm Pinata credentials have sufficient quota
- Make sure
castcommand is available in your PATH
License
MIT
