Skip to content

Commit

Permalink
fix: latest deployment fixes (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvtaveras authored Apr 30, 2024
1 parent c09b24a commit b6f39c1
Show file tree
Hide file tree
Showing 13 changed files with 221,240 additions and 178,381 deletions.
56 changes: 10 additions & 46 deletions bin/merkle-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,9 @@
*/

import { parseArgs } from "node:util";
import { MerkleTree } from "merkletreejs";
import { keccak256, AbiCoder, parseEther } from "ethers";
import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import * as fs from "fs";
import { parse } from "csv-parse/sync";
import assert from "assert";

interface DistributionRecord {
Address: string;
"MENTO based on locked CELO": string;
"MENTO based on cStables balances": string;
"MENTO based on cStables volumes": string;
total_distributed: string;
}

const {
values: { network },
Expand All @@ -32,45 +22,19 @@ if (network !== "baklava" && network !== "alfajores" && network !== "celo") {
throw new Error("Invalid network");
}

export const generateTree = async (): Promise<MerkleTree> => {
const abicoder = new AbiCoder();
const fileContent = fs.readFileSync(`data/airgrab.${network}.csv`, "utf8");
const records = parse(fileContent, {
columns: true,
skipEmptyLines: true,
});

const leaves = records.map((row: DistributionRecord) => {
const address = row.Address;
const totalDistributed = row.total_distributed;

const fromLockedCelo = parseFloat(row["MENTO based on locked CELO"] || "0");
const fromStablesBalances = parseFloat(row["MENTO based on cStables balances"] || "0");
const fromStablesVolumes = parseFloat(row["MENTO based on cStables volumes"] || "0");
assert(
fromLockedCelo + fromStablesBalances + fromStablesVolumes === parseFloat(totalDistributed),
"Invalid distribution",
);

const encoded = abicoder.encode(["address", "uint256"], [address, parseEther(totalDistributed)]);
const leafHash = keccak256(encoded);
const leaf = keccak256(Buffer.concat([Buffer.from(leafHash.slice(2), "hex")])); // Remove '0x' and convert to Buffer
return leaf;
export const generateTree = async (): Promise<any> => {
const snapshot = parse(fs.readFileSync(`data/airgrab.${network}.csv`, "utf8"), {
columns: false,
});

const merkleTree = new MerkleTree(leaves, keccak256, { sortPairs: true });

console.log("Merkle root: ", merkleTree.getHexRoot());

const treeData = {
root: merkleTree.getHexRoot(),
leaves: merkleTree.getHexLeaves(),
layers: merkleTree.getHexLayers(),
};
const tree = StandardMerkleTree.of(snapshot, ["address", "uint256"]);
console.log("Number of records in snapshot:", snapshot.length);
console.log("Root:", tree.root);

fs.writeFileSync(`data/airgrab.${network}.tree.json`, JSON.stringify(treeData, null, 2));
fs.writeFileSync(`data/airgrab.${network}.tree.json`, JSON.stringify(tree.dump()));
fs.writeFileSync(`data/airgrab.${network}.root.json`, JSON.stringify({ root: tree.root }));

return merkleTree;
return tree;
};

generateTree();
665 changes: 303 additions & 362 deletions broadcast/ExecuteProposal.sol/44787/run-latest.json

Large diffs are not rendered by default.

150 changes: 75 additions & 75 deletions broadcast/MUGOV-00-Create-Factory.sol/44787/run-latest.json

Large diffs are not rendered by default.

51 changes: 26 additions & 25 deletions broadcast/MUGOV.sol/44787/run-latest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"transactions": [
{
"hash": "0xae41ff5fdc8b7a51026bcfb5b1588f96cade74b726a5ceb87a794e9ba7f3d418",
"hash": "0x6c3d266ed0ed0689f00866dfe6b7e5ec1d5f19ce574993ddd0542bcc7f7ce3aa",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0xAA963FC97281d9632d96700aB62A4D1340F9a28a",
Expand All @@ -14,13 +14,13 @@
"gas": "0x9bae",
"value": "0x0",
"data": "0x41b3d185",
"nonce": "0x318"
"nonce": "0x37e"
},
"additionalContracts": [],
"isFixedGasLimit": false
},
{
"hash": "0xba803bc3d53b0a94eb6be4773251be4f29db93f76207ead2c3c0c850c5cecd44",
"hash": "0x95a3dfa824ce8524c484a263f1e0778409f62398c3bcb63dbfea607304347730",
"transactionType": "CALL",
"contractName": null,
"contractAddress": "0xAA963FC97281d9632d96700aB62A4D1340F9a28a",
Expand All @@ -30,24 +30,24 @@
"type": "0x00",
"from": "0x56fd3f2bee130e9867942d0f463a16fbe49b8d81",
"to": "0xaa963fc97281d9632d96700ab62a4d1340f9a28a",
"gas": "0x1365f5",
"gas": "0xf99c7",
"value": "0x56bc75e2d63100000",
"data": "0x65bbdaa000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000004a000000000000000000000000000000000000000000000000000000000000004e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008452a4d5c6cc09f29225a0c3aa0afe1b845397e20000000000000000000000000000000000000000000000000000000000000344b5a612c800000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81fb9d4e884da909e46207d6bcfd7616ee8627f1bfcff5041b30ac3c0fff9910310000000000000000000000002fcab633adfa6af8266025d63228047033c3ced0000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000800000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d8100000000000000000000000099995570bc88340d726d15d172e668271fbc9e200000000000000000000000009999f469fa49bb921ea385f1de49dcbccfbc9a820000000000000000000000009999700347b57a3152e8b63123649949a9abe20d0000000000000000000000009999db67bf5151668aaff29ed4baca3926747ed70000000000000000000000009999c6de88ebdf0aff022d127c36541d53f8789a00000000000000000000000099994874b3b90e690287c85df1ba26e886ff87f000000000000000000000000099990ea09dd56949dbafe97fc34dbc69bda81027000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000034400000000000000000000000000000000000000000000000000000000000000054d55474f56000000000000000000000000000000000000000000000000000000",
"nonce": "0x319"
"data": "0x65bbdaa000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000003a000000000000000000000000000000000000000000000000000000000000003e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000003a519bae6a64726a25d0e81a16e79fd2a989460b0000000000000000000000000000000000000000000000000000000000000244b5a612c8000000000000000000000000823655c966be3b6344efd4d2a0fe8d0a1e3d691b5764ac3d0900de8be7807056ec05f28969d52f9d7c7577a8d54063d9d865a4b10000000000000000000000002fcab633adfa6af8266025d63228047033c3ced000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000000400000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d810000000000000000000000006bd481a12cb2790e7ee805b9e6e7e91917deee6a000000000000000000000000707d2b6bd0acf76821ad5a09a1c6f43d6d6f692c000000000000000000000000a7ed835288aa4524bb6c73dd23c0bf4315d9fe3e0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000320000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000024400000000000000000000000000000000000000000000000000000000000000054d55474f56000000000000000000000000000000000000000000000000000000",
"nonce": "0x37f"
},
"additionalContracts": [],
"isFixedGasLimit": false
}
],
"receipts": [
{
"transactionHash": "0xae41ff5fdc8b7a51026bcfb5b1588f96cade74b726a5ceb87a794e9ba7f3d418",
"transactionIndex": "0x0",
"blockHash": "0xc39723f678af8d30bf8522c2ee87d554e8928510b1a9b04a35721b461e14350d",
"blockNumber": "0x1659e7c",
"transactionHash": "0x6c3d266ed0ed0689f00866dfe6b7e5ec1d5f19ce574993ddd0542bcc7f7ce3aa",
"transactionIndex": "0x1",
"blockHash": "0x769059b8c46c56c29eceaab8053de7f8b146065ec4b8833c2d6a03987970f91c",
"blockNumber": "0x16b29d2",
"from": "0x56fD3F2bEE130e9867942D0F463a16fBE49B8d81",
"to": "0xAA963FC97281d9632d96700aB62A4D1340F9a28a",
"cumulativeGasUsed": "0x70b6",
"cumulativeGasUsed": "0xf03b",
"gasUsed": "0x70b6",
"contractAddress": null,
"logs": [],
Expand All @@ -57,34 +57,34 @@
"effectiveGasPrice": "0x2540be400"
},
{
"transactionHash": "0xba803bc3d53b0a94eb6be4773251be4f29db93f76207ead2c3c0c850c5cecd44",
"transactionHash": "0x95a3dfa824ce8524c484a263f1e0778409f62398c3bcb63dbfea607304347730",
"transactionIndex": "0x1",
"blockHash": "0xc39723f678af8d30bf8522c2ee87d554e8928510b1a9b04a35721b461e14350d",
"blockNumber": "0x1659e7c",
"blockHash": "0xd0f1cb5fbff634f37cdfb51082f1024bb8c28a7c2207d6907934b97cee81160c",
"blockNumber": "0x16b29d3",
"from": "0x56fD3F2bEE130e9867942D0F463a16fBE49B8d81",
"to": "0xAA963FC97281d9632d96700aB62A4D1340F9a28a",
"cumulativeGasUsed": "0xe7bfa",
"gasUsed": "0xe0b44",
"cumulativeGasUsed": "0xbaf3f",
"gasUsed": "0xb4b6d",
"contractAddress": null,
"logs": [
{
"address": "0xAA963FC97281d9632d96700aB62A4D1340F9a28a",
"topics": [
"0x1bfe527f3548d9258c2512b6689f0acfccdd0557d80a53845db25fc57e93d8fe",
"0x0000000000000000000000000000000000000000000000000000000000000115",
"0x000000000000000000000000000000000000000000000000000000000000011a",
"0x00000000000000000000000056fd3f2bee130e9867942d0f463a16fbe49b8d81"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000006613d5af",
"blockHash": "0xc39723f678af8d30bf8522c2ee87d554e8928510b1a9b04a35721b461e14350d",
"blockNumber": "0x1659e7c",
"transactionHash": "0xba803bc3d53b0a94eb6be4773251be4f29db93f76207ead2c3c0c850c5cecd44",
"data": "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000056bc75e2d6310000000000000000000000000000000000000000000000000000000000000662f9475",
"blockHash": "0xd0f1cb5fbff634f37cdfb51082f1024bb8c28a7c2207d6907934b97cee81160c",
"blockNumber": "0x16b29d3",
"transactionHash": "0x95a3dfa824ce8524c484a263f1e0778409f62398c3bcb63dbfea607304347730",
"transactionIndex": "0x1",
"logIndex": "0x0",
"logIndex": "0x1",
"removed": false
}
],
"status": "0x1",
"logsBloom": "0x00000000000000000000000000000100000000000000000020000000000000000000010000000000000002000000010000000000000200000000000000000000000000000000000010000000010000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000",
"logsBloom": "0x00000000000002000000000000000000000000000000000020000000000000000000000000000000000002000000010000000000000200000040000000000000000000000000000010000000010000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000004000000000000000000000000000000000000000000000000000000000000",
"type": "0x0",
"effectiveGasPrice": "0x2540be400"
}
Expand All @@ -95,7 +95,8 @@
],
"pending": [],
"returns": {},
"timestamp": 1712575924,
"timestamp": 1714394230,
"chain": 44787,
"commit": "5d0af32"
"multi": false,
"commit": "b314f2b"
}
Loading

0 comments on commit b6f39c1

Please sign in to comment.