Skip to content

Commit

Permalink
improves handling off odd situation states for governance proposals. (#…
Browse files Browse the repository at this point in the history
…173)

* improves handling off odd situation states for governance proposals.

* yolo

* fix delegates (empty string caused massive fail)

update

* prettier
  • Loading branch information
aaronmgdr authored Feb 26, 2025
1 parent fe9af3c commit 5a3a374
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/app/governance/[id]/markdown-api/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export const revalidate = 60 * 2;
export const revalidate = 60 * 3;

const URL_BASE = 'https://raw.githubusercontent.com/celo-org/governance/main/CGPs/cgp-';

// TODO consider doing more parsing of yaml / markdown here instead of in browser
export async function GET(request: Request, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const url = URL_BASE + zeroPad(id) + '.md';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
"logoUri": "/logos/delegatees/0xba3982536F79090D4d68cD14e1B7d15fF1014030.jpeg",
"date": "2025-01-29",
"links": {
"website": "https://celo.org",
"twitter": "https://x.com/ndukaanthonya"
},
"interests": [
"Community",
"NFTs",
"DAO",
"Stablecoins",
""
"Stablecoins"
],
"description": "Community Developer"
}
106 changes: 106 additions & 0 deletions src/config/delegates.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,5 +648,111 @@
"Nature Conservation"
],
"description": "David Dao is the Co-Founder of GainForest.Earth, a decentralized science non-profit dedicated to tackling the climate and biodiversity crisis with regenerative intelligence. Previously, David won the XPRIZE Rainforest Impact Prize and is the co-inventor of data valuation for machine learning. He earned his doctorate degree in computer science from ETH Zurich, and was a postdoctoral scholar in environmental science with research fellowships at MIT, UC Berkeley and Stanford."
},
"0x140D3f60AC840571a3e08e218B823094d4715564": {
"name": "koH",
"address": "0x140D3f60AC840571a3e08e218B823094d4715564",
"logoUri": "/logos/delegatees/0x140D3f60AC840571a3e08e218B823094d4715564.jpg",
"date": "2025-01-24",
"links": {
"website": "https://handprotocol.org",
"twitter": "https://x.com/crypto_koh"
},
"interests": ["Gov", "Regen", "Art", "AI", "OSS"],
"description": "Hey I'm koH and my main focus is leveraging blockchain to help positive change projects. My main project is Hand Protocol which is focused on assisting regen projects or people to accomplish their missions!"
},
"0x1d8b86f4E261b6329465358f573c3B31A4a2A646": {
"name": "Marie-Claire Graf",
"address": "0x1d8b86f4E261b6329465358f573c3B31A4a2A646",
"logoUri": "/logos/delegatees/0x1d8b86f4E261b6329465358f573c3B31A4a2A646.jpg",
"date": "2025-01-31",
"links": {
"website": "https://marieclairegraf.com",
"twitter": "https://x.com/MarieClaireGraf"
},
"interests": ["climate", "diplomacy", "negotiations", "nature", "sailing"],
"description": "Co-Founder of Youth Negotiators Academy for democratic governance and intergenerational leadership in environmental policy, diplomacy and decision-making processes to create a momentum for systemic change. She was initiating and is leading several associations and movements on the intersections of climate, youth and women representation, food systems transformation and education. She studied environmental and political sciences in Zurich and was a climate negotiator for Switzerland."
},
"0x20F50b8832f87104853df3FdDA47Dd464f885a49": {
"name": "Felix Eligbue",
"address": "0x20F50b8832f87104853df3FdDA47Dd464f885a49",
"logoUri": "/logos/delegatees/0x20F50b8832f87104853df3FdDA47Dd464f885a49.jpg",
"date": "2025-01-18",
"links": {
"website": "https://philix.vercel.app",
"twitter": "https://x.com/philixbob"
},
"interests": ["Stablecoin", "Defi", "Impact"],
"description": "Software developer and Founder @pharmoprep"
},
"0x3DDC7d25c7a1dc381443e491Bbf1Caa8928A05B0": {
"name": "Ignas",
"address": "0x3DDC7d25c7a1dc381443e491Bbf1Caa8928A05B0",
"logoUri": "/logos/delegatees/0x3DDC7d25c7a1dc381443e491Bbf1Caa8928A05B0.png",
"date": "2025-01-17",
"links": {
"twitter": "https://x.com/DefiIgnas"
},
"interests": ["DeFi", "L1s", "L2s", "DAO governance"],
"description": "I’m Ignas, a solo researcher with the main focus on DeFi. My mission is to provide clear, in-depth insights helping my audiences stay up-to-date with the latest trends while actively supporting DAO development. I believe in the decentralized future and it means actively participating in Arbitrum DAO in every way I can—whether it’s by serving as a delegate, joining working groups, discussing any proposals or seizing new opportunities that come up. I’ll also be sharing key DAO decisions on X and my blog."
},
"0x5523058cdFfe5F3c1EaDADD5015E55C6E00fb439": {
"name": "Grassroots Economics",
"address": "0x5523058cdFfe5F3c1EaDADD5015E55C6E00fb439",
"logoUri": "/logos/delegatees/0x5523058cdFfe5F3c1EaDADD5015E55C6E00fb439.png",
"date": "2025-01-20",
"links": {
"website": "https://grassrootseconomics.org",
"twitter": "https://x.com/grassecon"
},
"interests": ["Open Source", "Governance", "ReFi", "Community", "Engineering"],
"description": "Grassroots Economics is a non-profit foundation that seeks to support communities to take charge of their own livelihoods and economic future. We focus on community development through commons and are dedicated to helping communities realize and share their abundance through Economic Commons with Instruments like Community Asset Vouchers and Commitment Pooling that can act as a medium of exchange and commons. While core beneficiaries of our programs include businesses and people living in informal settlements as well as rural areas, the documentation and tools have been broadly applied worldwide. It is tremendously important to us that people take, use, build on and share what we've found to be useful. Join us in demonstrating, disseminating, designing & curating the best practices to empower communities to create and manage their own financial instruments. All our software, websites, materials are CopyLeft under AGPL 3.0 for software and Creative Commons Share-Alike With Attribution. Please copy, modify and"
},
"0x6820442229778647b77cA1bb1746d1966dEbe3Ea": {
"name": "Vow",
"address": "0x6820442229778647b77cA1bb1746d1966dEbe3Ea",
"logoUri": "/logos/delegatees/0x6820442229778647b77cA1bb1746d1966dEbe3Ea.jpg",
"date": "2025-01-15",
"links": {
"website": "https://x.com/VowIMTX",
"twitter": "https://x.com/VowIMTX"
},
"interests": ["Blockchain", "Sustainable"],
"description": "Advisor at KohCelo"
},
"0xCDaba8e196D9BF1DabdF6b5D3Bc3BFD175FF81c8": {
"name": "UMN Blockchain",
"address": "0xCDaba8e196D9BF1DabdF6b5D3Bc3BFD175FF81c8",
"logoUri": "/logos/delegatees/0xCDaba8e196D9BF1DabdF6b5D3Bc3BFD175FF81c8.jpg",
"date": "2025-01-22",
"links": {
"website": "https://www.umnbc.org/",
"twitter": "https://x.com/umnblockchain"
},
"interests": ["Blockchain"],
"description": "Club at University of Minnesota dedicated to Blockchain"
},
"0xba3982536F79090D4d68cD14e1B7d15fF1014030": {
"name": "Anthony Annaelechukwu Nduka",
"address": "0xba3982536F79090D4d68cD14e1B7d15fF1014030",
"logoUri": "/logos/delegatees/0xba3982536F79090D4d68cD14e1B7d15fF1014030.jpeg",
"date": "2025-01-29",
"links": {
"twitter": "https://x.com/ndukaanthonya"
},
"interests": ["Community", "NFTs", "DAO", "Stablecoins"],
"description": "Community Developer"
},
"0xcFB5a8A167c1E437e34d82C25Cc0Ef24d4f27d4b": {
"name": "CalBlockchain",
"address": "0xcFB5a8A167c1E437e34d82C25Cc0Ef24d4f27d4b",
"logoUri": "/logos/delegatees/0xcFB5a8A167c1E437e34d82C25Cc0Ef24d4f27d4b.jpg",
"date": "2025-02-03",
"links": {
"website": "https://blockchain.studentorg.berkeley.edu/",
"twitter": "https://x.com/CalBlockchain"
},
"interests": ["Blockchain"],
"description": "Student Organization at Berkeley focused on blockchain innovation, education, consulting, and research. Founded in 2014."
}
}
2 changes: 1 addition & 1 deletion src/config/proposals.json
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@
"cgpUrl": "https://github.com/celo-org/governance/blob/main/CGPs/cgp-0155.md",
"cgpUrlRaw": "https://raw.githubusercontent.com/celo-org/governance/main/CGPs/cgp-0155.md",
"title": "Add CeloToken and LockedCelo to the registry",
"author": "Sebastien Benoit (@soloseng), Martín Volpe (@martinvol)",
"author": "@soloseng, Martín Volpe (@martinvol)",
"stage": 0,
"timestamp": 1731974400000
},
Expand Down
108 changes: 107 additions & 1 deletion src/features/governance/hooks/useGovernanceProposals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { TransactionLog } from 'src/features/explorers/types';
import { publicClient } from 'src/test/anvil/utils';
import { logger } from 'src/utils/logger';
import { afterAll, describe, expect, it, test, vi } from 'vitest';
import { ProposalStage } from '../types';
import { Proposal, ProposalMetadata, ProposalStage } from '../types';
import {
MergedProposalData,
fetchExecutedProposalIds,
fetchGovernanceMetadata,
fetchGovernanceProposals,
getExpiryTimestamp,
mergeProposalsWithMetadata,
pessimisticallyHandleMismatchedIDs,
useGovernanceProposal,
} from './useGovernanceProposals';

Expand Down Expand Up @@ -161,7 +162,112 @@ describe('mergeProposalsWithMetadata', () => {
} else if (proposal.metadata?.cgp === 149) {
// draft
expect(proposal.stage).toBe(ProposalStage.Executed);
} else if (proposal.metadata?.cgp === 163) {
expect(proposal.stage).toBe(ProposalStage.Executed);
}
});
});
}, 10000);

describe('pessimisticallyHandleMismatchedIDs', () => {
const executedIDS = [1, 3, 5, 7, 11, 21, 99, 101];
const metdataCommon = {
cgpUrl: 'https://github.com/celo-org/governance/blob/main/CGPs/cgp-0101.md',
cgpUrlRaw: 'https://raw.githubusercontent.com/celo-org/governance/main/CGPs/cgp-0101.md',
title: 'test proposal',
author: 'test author',
votes: undefined,
} as const;

// values not used in test
const proposalCommon = {
timestamp: Date.now(),
url: 'https://github.com/celo-org/governance/blob/main/CGPs/cgp-0101.md',
deposit: 100000000000000000000n,
numTransactions: 2n,
proposer: '0x1234567890123456789012345678901234567890',
networkWeight: 100000000000000000000n,
votes: {
yes: 1000000000000000000000n,
no: 1000000000000000000000n,
abstain: 1000000000000000000000n,
},
upvotes: 1000000000000000000000n,
} as const;

describe('when on chain proposal id has been executed', () => {
it('returns with proposal as truth', () => {
const executedID = executedIDS[0];
const nonExecutedId = 4;
expect(executedIDS.includes(nonExecutedId)).toBe(false);
const proposal: Proposal = {
id: executedID,
stage: ProposalStage.Executed,
...proposalCommon,
isApproved: true,
};
const metadata: ProposalMetadata = {
id: nonExecutedId,
stage: ProposalStage.Queued,
cgp: 101,
...metdataCommon,
};
expect(pessimisticallyHandleMismatchedIDs(executedIDS, metadata, proposal)).toEqual({
id: executedID,
metadata: { ...metadata, id: executedID },
stage: ProposalStage.Executed,
proposal,
});
});
});
describe('when id from github metadata has been executed', () => {
it('returns metadata as truth', () => {
const executedID = executedIDS[3];
const nonExecutedId = 22;
expect(executedIDS.includes(nonExecutedId)).toBe(false);
const proposal: Proposal = {
id: nonExecutedId,
stage: ProposalStage.Expiration,
...proposalCommon,
isApproved: true,
};
const metadata: ProposalMetadata = {
id: executedID,
stage: ProposalStage.Queued,
cgp: 101,
...metdataCommon,
};
expect(pessimisticallyHandleMismatchedIDs(executedIDS, metadata, proposal)).toEqual({
id: executedID,
stage: ProposalStage.Executed,
metadata: metadata,
});
});
});
// realistcally this should never happen so not bothering with it for now
describe.todo('when both id has been executed', () => {
it('returns with higher as truth', () => {});
});
describe('when on chain is expired and gh hub stage is withdrawn/rejected', () => {
it('returns with x as truth and uses metadata for status', () => {
const proposal: Proposal = {
id: 4,
stage: ProposalStage.Expiration,
...proposalCommon,
isApproved: true,
};
const metadata: ProposalMetadata = {
id: 62,
stage: ProposalStage.Rejected,
cgp: 101,
...metdataCommon,
};
expect(pessimisticallyHandleMismatchedIDs(executedIDS, metadata, proposal)).toEqual({
id: 62,
metadata: { ...metadata, votes: undefined },
stage: metadata.stage,
proposal,
});
});
});
});
Loading

0 comments on commit 5a3a374

Please sign in to comment.