-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add manifesto and voting delay cross-chain sync (#167)
add manifesto
- Loading branch information
Showing
10 changed files
with
897 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import hre, { ethers } from "hardhat" | ||
import { Gov__factory } from "../typechain-types/factories/contracts/variants/crosschain/Gov__factory" | ||
import * as fs from "fs" | ||
import * as path from "path" | ||
import color from "cli-color" | ||
var msg = color.xterm(39).bgXterm(128) | ||
|
||
function getDeployedAddress(network: string, contractName: string): string { | ||
try { | ||
const deploymentPath = path.join( | ||
__dirname, | ||
"..", | ||
"deployments", | ||
network, | ||
`${contractName}.json` | ||
) | ||
const deployment = JSON.parse(fs.readFileSync(deploymentPath, "utf8")) | ||
return deployment.address | ||
} catch (error) { | ||
throw new Error( | ||
`Failed to read deployment for ${contractName} on ${network}: ${error}` | ||
) | ||
} | ||
} | ||
|
||
function getProofFromData(): string { | ||
try { | ||
const dataPath = path.join(__dirname, "..", "data.json") | ||
const data = JSON.parse(fs.readFileSync(dataPath, "utf8")) | ||
return data.proof | ||
} catch (error) { | ||
throw new Error(`Failed to read proof from data.json: ${error}`) | ||
} | ||
} | ||
|
||
async function main() { | ||
const SIGNER_PRIVATE_KEY = process.env.SIGNER_PRIVATE_KEY | ||
if (!SIGNER_PRIVATE_KEY) { | ||
throw new Error("Please set SIGNER_PRIVATE_KEY in your .env file") | ||
} | ||
|
||
const networkName = hre.network.name | ||
const GOV_ADDRESS = getDeployedAddress(networkName, "CrosschainGov") | ||
console.log("Using Gov contract address:", GOV_ADDRESS) | ||
|
||
const provider = new ethers.JsonRpcProvider( | ||
networkName === "op-sepolia" | ||
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL | ||
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL | ||
) | ||
const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) | ||
const gov = Gov__factory.connect(GOV_ADDRESS, signer) | ||
|
||
const proof = getProofFromData() | ||
console.log("\nUsing manifesto proof:", proof) | ||
|
||
try { | ||
console.log("Simulating manifesto update claim...") | ||
await gov.claimManifestoUpdate.staticCall(proof) | ||
console.log("✅ Simulation successful") | ||
|
||
console.log("Submitting manifesto update claim...") | ||
const tx = await gov.claimManifestoUpdate(proof, { | ||
gasLimit: 500000 | ||
}) | ||
|
||
console.log("Transaction submitted:", msg(tx.hash)) | ||
console.log("Waiting for confirmation...") | ||
|
||
const receipt = await tx.wait() | ||
console.log("Manifesto update claimed successfully!") | ||
|
||
const updateEvent = receipt?.logs.find(log => { | ||
try { | ||
return gov.interface.parseLog(log)?.name === "ManifestoUpdated" | ||
} catch { | ||
return false | ||
} | ||
}) | ||
|
||
if (updateEvent) { | ||
const parsedEvent = gov.interface.parseLog(updateEvent) | ||
const oldManifesto = parsedEvent?.args?.oldManifesto | ||
const newManifesto = parsedEvent?.args?.newManifesto | ||
console.log("Old manifesto:", oldManifesto) | ||
console.log("New manifesto:", newManifesto) | ||
} | ||
} catch (error: any) { | ||
console.error("\nError details:", error) | ||
throw error | ||
} | ||
} | ||
|
||
main().catch(error => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import hre, { ethers } from "hardhat" | ||
import { Gov__factory } from "../typechain-types/factories/contracts/variants/crosschain/Gov__factory" | ||
import * as fs from "fs" | ||
import * as path from "path" | ||
import color from "cli-color" | ||
var msg = color.xterm(39).bgXterm(128) | ||
|
||
function getDeployedAddress(network: string, contractName: string): string { | ||
try { | ||
const deploymentPath = path.join( | ||
__dirname, | ||
"..", | ||
"deployments", | ||
network, | ||
`${contractName}.json` | ||
) | ||
const deployment = JSON.parse(fs.readFileSync(deploymentPath, "utf8")) | ||
return deployment.address | ||
} catch (error) { | ||
throw new Error( | ||
`Failed to read deployment for ${contractName} on ${network}: ${error}` | ||
) | ||
} | ||
} | ||
|
||
function getProofFromData(): string { | ||
try { | ||
const dataPath = path.join(__dirname, "..", "data.json") | ||
const data = JSON.parse(fs.readFileSync(dataPath, "utf8")) | ||
return data.proof | ||
} catch (error) { | ||
throw new Error(`Failed to read proof from data.json: ${error}`) | ||
} | ||
} | ||
|
||
async function main() { | ||
const SIGNER_PRIVATE_KEY = process.env.SIGNER_PRIVATE_KEY | ||
if (!SIGNER_PRIVATE_KEY) { | ||
throw new Error("Please set SIGNER_PRIVATE_KEY in your .env file") | ||
} | ||
|
||
const networkName = hre.network.name | ||
const GOV_ADDRESS = getDeployedAddress(networkName, "CrosschainGov") | ||
console.log("Using Gov contract address:", GOV_ADDRESS) | ||
|
||
const provider = new ethers.JsonRpcProvider( | ||
networkName === "op-sepolia" | ||
? process.env.OP_SEPOLIA_RPC_ENDPOINT_URL | ||
: process.env.ARBITRUM_SEPOLIA_RPC_ENDPOINT_URL | ||
) | ||
const signer = new ethers.Wallet(SIGNER_PRIVATE_KEY, provider) | ||
const gov = Gov__factory.connect(GOV_ADDRESS, signer) | ||
|
||
const proof = getProofFromData() | ||
console.log("\nUsing voting delay proof:", proof) | ||
|
||
try { | ||
console.log("Simulating voting delay update claim...") | ||
await gov.claimParameterUpdate.staticCall(proof) | ||
console.log("✅ Simulation successful") | ||
|
||
console.log("Submitting voting delay update claim...") | ||
const tx = await gov.claimParameterUpdate(proof, { | ||
gasLimit: 500000 | ||
}) | ||
|
||
console.log("Transaction submitted:", msg(tx.hash)) | ||
console.log("Waiting for confirmation...") | ||
|
||
const receipt = await tx.wait() | ||
console.log("Voting delay update claimed successfully!") | ||
|
||
const updateEvent = receipt?.logs.find(log => { | ||
try { | ||
return ( | ||
gov.interface.parseLog(log)?.name === | ||
"GovernanceParameterUpdated" | ||
) | ||
} catch { | ||
return false | ||
} | ||
}) | ||
|
||
if (updateEvent) { | ||
const parsedEvent = gov.interface.parseLog(updateEvent) | ||
const oldValue = parsedEvent?.args?.oldValue | ||
const newValue = parsedEvent?.args?.newValue | ||
console.log("Old voting delay:", oldValue) | ||
console.log("New voting delay:", newValue) | ||
} | ||
} catch (error: any) { | ||
console.error("\nError details:", error) | ||
throw error | ||
} | ||
} | ||
|
||
main().catch(error => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Color codes | ||
GREEN='\033[0;32m' | ||
RED='\033[0;31m' | ||
BLUE='\033[0;34m' | ||
NC='\033[0m' # No Color | ||
|
||
echo -e "${BLUE}Starting cross-chain manifesto update process...${NC}\n" | ||
|
||
# Create proposal on OP Sepolia | ||
echo -e "\n${BLUE}Creating manifesto update proposal on OP Sepolia...${NC}" | ||
if npx hardhat run scripts/propose-manifesto.ts --network op-sepolia; then | ||
echo -e "${GREEN}✓ Manifesto update proposal creation successful${NC}" | ||
else | ||
echo -e "${RED}✗ Manifesto update proposal creation failed${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Generate manifesto proof from OP Sepolia | ||
echo -e "\n${BLUE}Generating manifesto proof from OP Sepolia...${NC}" | ||
if npx hardhat run scripts/verify-manifesto-proof.ts --network op-sepolia; then | ||
echo -e "${GREEN}✓ Manifesto proof generation successful${NC}" | ||
else | ||
echo -e "${RED}✗ Manifesto proof generation failed${NC}" | ||
exit 1 | ||
fi | ||
|
||
# Claim manifesto update on Arbitrum Sepolia | ||
echo -e "\n${BLUE}Claiming manifesto update on Arbitrum Sepolia...${NC}" | ||
if npx hardhat run scripts/claim-manifesto.ts --network arbitrum-sepolia; then | ||
echo -e "${GREEN}✓ Manifesto update claim successful${NC}" | ||
echo -e "\n${GREEN}✓ All manifesto update steps completed successfully!${NC}" | ||
exit 0 | ||
else | ||
echo -e "${RED}✗ Manifesto update claim failed${NC}" | ||
exit 1 | ||
fi |
Oops, something went wrong.