Skip to content

Commit

Permalink
[CI] [OPS-SCRIPTS] switch canary to optimism-sepolia (#1892)
Browse files Browse the repository at this point in the history
* switch canary to optimism-sepolia and change deploy script to fix the possibility of testnet bricking if interrupted

* fix gda code changed detection

* remove excess newlines

* missing branch

chore: remove repetitive words (#1893)

Signed-off-by: tgolang <[email protected]>

* fix reset case

---------

Signed-off-by: tgolang <[email protected]>
  • Loading branch information
d10r authored Mar 14, 2024
1 parent dc41b52 commit a968425
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 58 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ jobs:
strategy:
fail-fast: false
matrix:
network: [avalanche-fuji]
network: [optimism-sepolia]

defaults:
run:
Expand All @@ -307,5 +307,5 @@ jobs:
tasks/etherscan-verify-framework.sh ${{ matrix.network }} addresses.vars
env:
RELEASE_VERSION: canary
AVALANCHE_FUJI_MNEMONIC: ${{ secrets.BUILD_AGENT_MNEMONIC }}
AVALANCHE_FUJI_PROVIDER_URL: ${{ secrets.AVALANCHE_FUJI_PROVIDER_URL }}
OPTIMISM_SEPOLIA_MNEMONIC: ${{ secrets.BUILD_AGENT_MNEMONIC }}
OPTIMISM_SEPOLIA_PROVIDER_URL: ${{ secrets.OPTIMISM_SEPOLIA_PROVIDER_URL }}
94 changes: 40 additions & 54 deletions packages/ethereum-contracts/ops-scripts/deploy-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,27 +305,6 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (

// =========== BOOTSTRAPPING (initial deployment) ===========

// deploy new governance contract
let governanceInitializationRequired = false;
let governance;
if (!config.disableTestGovernance && !process.env.NO_NEW_GOVERNANCE) {
governance = await deployAndRegisterContractIf(
TestGovernance,
`TestGovernance.${protocolReleaseVersion}`,
async (contractAddress) =>
await codeChanged(web3, TestGovernance, contractAddress),
async () => {
governanceInitializationRequired = true;
const c = await web3tx(
TestGovernance.new,
"TestGovernance.new"
)();
output += `SUPERFLUID_GOVERNANCE=${c.address}\n`;
return c;
}
);
}

// deploy superfluid loader
await deployAndRegisterContractIf(
SuperfluidLoader,
Expand All @@ -341,14 +320,32 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
}
);

// deploy new TestGovernance contract
// (only on testnets, devnets and initial mainnet deployment)
let testGovernanceInitRequired = false;
let governance;
if (!config.disableTestGovernance && !process.env.NO_NEW_GOVERNANCE) {
const prevGovAddr = await resolver.get.call(`TestGovernance.${protocolReleaseVersion}`);
if (resetSuperfluidFramework || await codeChanged(web3, TestGovernance, prevGovAddr)) {
console.log(`TestGovernance needs new deployment.`);
const c = await web3tx(TestGovernance.new,"TestGovernance.new")();
governance = await TestGovernance.at(c.address);
testGovernanceInitRequired = true;
output += `SUPERFLUID_GOVERNANCE=${c.address}\n`;
} else {
governance = await TestGovernance.at(prevGovAddr);
}
// defer resolver update to after the initialization
// this avoids testnet bricking in case script execution is interrupted
}

// deploy new superfluid host contract
const SuperfluidLogic = useMocks ? SuperfluidMock : Superfluid;
const superfluid = await deployAndRegisterContractIf(
SuperfluidLogic,
`Superfluid.${protocolReleaseVersion}`,
async (contractAddress) => !(await hasCode(web3, contractAddress)),
async () => {
governanceInitializationRequired = true;
let superfluidAddress;
const superfluidLogic = await web3tx(
SuperfluidLogic.new,
Expand Down Expand Up @@ -410,8 +407,8 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
console.log("Governance address", governance.address);
}

// initialize the new governance
if (governanceInitializationRequired) {
// initialize the new TestGovernance
if (testGovernanceInitRequired) {
const accounts = await web3.eth.getAccounts();
const trustedForwarders = [];
if (config.trustedForwarders) {
Expand All @@ -423,7 +420,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
if (config.gdaFwd) {
trustedForwarders.push(config.gdaFwd);
}
console.log(`initializing governance with config: ${JSON.stringify({
console.log(`initializing TestGovernance with config: ${JSON.stringify({
liquidationPeriod: config.liquidationPeriod,
patricianPeriod: config.patricityPeriod,
trustedForwarders
Expand All @@ -440,6 +437,13 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
// trustedForwarders
trustedForwarders
);

// update the resolver
await setResolver(
sfObjForGovAndResolver,
`TestGovernance.${protocolReleaseVersion}`,
governance.address
);
}

// replace with new governance
Expand Down Expand Up @@ -573,9 +577,6 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (

let gdaIsLinked = false;
const deployGDAv1 = async (superfluidPoolBeaconAddr) => {
// TODO: why do we want to allow this to fail? Do we really?
//try {
// deploy and link SuperfluidPoolDeployerLibrary
if (!gdaIsLinked) {
await deployExternalLibraryAndLink(
SuperfluidPoolDeployerLibrary,
Expand Down Expand Up @@ -610,16 +611,6 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
}
gdaIsLinked = true;
}
/*} catch (err) {
console.error(err);
}*/
if (superfluidPoolBeaconAddr === undefined) {
// update case, we cat get from previous deployment
const GDAv1 = await GeneralDistributionAgreementV1.at(
await superfluid.getAgreementClass.call(GDAv1_TYPE)
);
superfluidPoolBeaconAddr = await GDAv1.superfluidPoolBeacon.call();
}

const agreement = await web3tx(
GeneralDistributionAgreementV1.new,
Expand Down Expand Up @@ -823,11 +814,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
)
).getCodeAddress(),
async () => (await deployCFAv1()).address,
[
// See SuperToken constructor parameter
superfluidConstructorParam,
ZERO_ADDRESS.toLowerCase().slice(2).padStart(64, "0"),
]
[ superfluidConstructorParam ]
);
if (cfaNewLogicAddress !== ZERO_ADDRESS) {
agreementsToUpdate.push(cfaNewLogicAddress);
Expand All @@ -842,27 +829,26 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function (
)
).getCodeAddress(),
async () => (await deployIDAv1()).address,
[
// See SuperToken constructor parameter
superfluidConstructorParam,
]
[ superfluidConstructorParam ]
);
if (idaNewLogicAddress !== ZERO_ADDRESS) {
agreementsToUpdate.push(idaNewLogicAddress);
}
// deploy new GDA logic
const gdaAddr = await (await UUPSProxiable.at(
await superfluid.getAgreementClass.call(GDAv1_TYPE)
)).getCodeAddress();
const superfluidPoolBeaconAddr = await (
await GeneralDistributionAgreementV1.at(gdaAddr)
).superfluidPoolBeacon.call();
const gdaNewLogicAddress = await deployContractIfCodeChanged(
web3,
GeneralDistributionAgreementV1,
await (
await UUPSProxiable.at(
await superfluid.getAgreementClass.call(GDAv1_TYPE)
)
).getCodeAddress(),
async () => (await deployGDAv1()).address,
gdaAddr,
async () => (await deployGDAv1(superfluidPoolBeaconAddr)).address,
[
// See SuperToken constructor parameter
superfluidConstructorParam,
ap(superfluidPoolBeaconAddr)
]
);
if (gdaNewLogicAddress !== ZERO_ADDRESS) {
Expand Down
2 changes: 1 addition & 1 deletion packages/subgraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Open another terminal window and navigate to `packages/ethereum-contracts` and r
yarn build
```

Now go to to `packages/ethereum-contracts` and run the following command to deploy contracts:
Now go to `packages/ethereum-contracts` and run the following command to deploy contracts:

```bash
npx hardhat run dev-scripts/run-deploy-contracts-and-token.js
Expand Down

0 comments on commit a968425

Please sign in to comment.