Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Merkle Tree #1

Merged
merged 31 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d6875c1
Add Merkle Tree
Phanco Nov 30, 2023
4719b19
Changed editing, update main.ts scripts
Phanco Nov 30, 2023
09c12e5
Rename package to align with repo name
Phanco Nov 30, 2023
bba45fb
Added more details at README
Phanco Nov 30, 2023
0faa955
Addresses are now sorted, betting naming of `leaf`
Phanco Dec 7, 2023
54d60fe
Update Beddows value to balances.json
Phanco Dec 7, 2023
90672e9
Add unit test
Phanco Dec 8, 2023
1c931af
Update README
Phanco Dec 8, 2023
97b5279
Modulized merkleTree building process, updated test cases
Phanco Jan 2, 2024
c753d7c
Updated README
Phanco Jan 3, 2024
a9037d6
Add set instruction to README
Phanco Jan 3, 2024
3ff9267
Update test cases
Phanco Jan 4, 2024
37e9bfe
Rename merkleTree files, added merkleRoot file
Phanco Jan 4, 2024
e95c789
Improve README
Phanco Jan 4, 2024
7caf394
Merge branch 'main' of github.com:LiskHQ/lisk-token-claim into 115-im…
Phanco Jan 8, 2024
52753b6
Updated README and code according to PR suggestions
Phanco Jan 8, 2024
480430a
Update README
Phanco Jan 8, 2024
0392fc2
Fix unit test
Phanco Jan 8, 2024
2f73a29
Update format
Phanco Jan 9, 2024
4add790
keyPairs are calculated instead of stored, users can custom number of…
Phanco Jan 9, 2024
8f257da
Update comments
Phanco Jan 10, 2024
ade43be
Added append0x function, update tsconfig
Phanco Jan 10, 2024
28d64d5
Update files to snake case
Phanco Jan 10, 2024
d892067
Undo irrelavant changes
Phanco Jan 10, 2024
d3795d9
Update format
Phanco Jan 10, 2024
bedb635
Change example args to flags
Phanco Jan 10, 2024
523510c
Update code according to PR comments
Phanco Jan 11, 2024
044e9c7
Update test file names
Phanco Jan 12, 2024
2a0a7fa
Use oclif logging
Phanco Jan 17, 2024
646fc49
Update formatting and tsconfig
Phanco Jan 17, 2024
cd17364
Update log import, changed fn name build_tree -> buildTree
Phanco Jan 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@

This library builds Merkle Tree from a snapshot and computes Merkle Root.
AndreasKendziorra marked this conversation as resolved.
Show resolved Hide resolved

## Installation
## Setup and Installation

```
$ git clone [email protected]:LiskHQ/lisk-token-claim.git && cd lisk-token-claim
shuse2 marked this conversation as resolved.
Show resolved Hide resolved
$ yarn
AndreasKendziorra marked this conversation as resolved.
Show resolved Hide resolved
```

## Run

```
$ yarn generate-merkle-tree # Using ./data/mainnet
$ yarn generate-merkle-tree:mainnet # Using ./data/mainnet
$ yarn generate-merkle-tree:testnet # Using ./data/testnet
$ yarn generate-merkle-tree:example # Using ./data/example
```

## Files

| Name | Description | Generated By |
|--------------------------------------------------|---------------------------------------------------------------------------------------------------| ----------------------------- |
| `/data/<network>/balance.json` | Stores balance by address after a snapshot is taken, addresses must be sorted in ascending order. | Snapshot |
| `/data/<network>/merkle-tree-result.json` | Stores MerkleRoot, and leaves for each account. | `$ yarn generate-merkle-tree` |
| `/data/<network>/merkle-tree-result-simple.json` | Stores MerkleRoot, and leaves for each account. | `$ yarn generate-merkle-tree` |
| Name | Description | Generated By |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |-----------------------------------------|
| `/data/<network>/accounts.json` | Stores addresses, balances, and multisig details(If any) by address after a snapshot is taken, addresses must be sorted in ascending order. | Snapshot |
AndreasKendziorra marked this conversation as resolved.
Show resolved Hide resolved
AndreasKendziorra marked this conversation as resolved.
Show resolved Hide resolved
| `/data/<network>/merkle-tree-result.json` | Stores MerkleRoot, and leaves for each account. | `$ yarn generate-merkle-tree:<network>` |
| `/data/<network>/merkle-tree-result-simple.json` | Stores MerkleRoot, and leaves for each account. | `$ yarn generate-merkle-tree:<network>` |

## Merkle Leaf

Each leaf will be encoded as ABI-format, in the following order:

```
LSK_ADDRESS_IN_HEX: bytes20
BALANCE_IN_BEDDOWS: uint64
Expand All @@ -39,7 +42,7 @@ P.S. If the address is not a multisig address, NUMBER_OF_SIGNATURES would be 0,
## Params

```
balance.json:
accounts.json:
{
lskAddress: string;
balance: number;
matjazv marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -88,10 +91,10 @@ Due to the constraint of vm.parseJson in Foundry, fields in `merkle-tree-result`

## _Testing Only_

### Generate balance.json from `dev-validators.json`
### Generate accounts.json from `dev-validators.json`

```
$ yarn create-balances:example
$ yarn create-accounts:example
```

### (After running `generate-merkle-tree:example`) Sign all accounts and generates `signatures.json`
Expand All @@ -101,6 +104,7 @@ $ yarn sign:example
```

### Params (For testing purposes only)

```
signatures.json:
{
Expand All @@ -111,4 +115,4 @@ signatures.json:
s: string
}[];
}[];
```
```
Loading