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

test changeset #370

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"linked": [],
"access": "public",
"baseBranch": "main",
"baseBranch": "origin/main",
"updateInternalDependencies": "patch",
"snapshot": {
"useCalculatedVersion": true,
Expand Down
5 changes: 5 additions & 0 deletions .changeset/pretty-hats-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fuel-bridge/solidity-contracts': patch
---

test changeset
5 changes: 2 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
# need this to get full git-history/clone in order to build changelogs and check changesets
fetch-depth: 0
- uses: FuelLabs/github-actions/setups/node@master
fetch-depth: 0 # Fetch full history
- uses: FuelLabs/github-actions/setups/node@ps/chore/enable-docs-with-snippets-inline
with:
node-version: 20.16.0
pnpm-version: 9.0.6
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@fuels/eslint-plugin": "0.20.0",
"@fuels/prettier-config": "0.0.10",
"@fuels/ts-config": "0.0.10",
"fuels": "0.96.1",
"eslint": "^8.49.0",
"fuels": "0.96.1",
"prettier": "^2.7.1",
"tsup": "^8.3.0",
"tsx": "^3.12.7",
Expand All @@ -52,7 +52,9 @@
"elliptic@>=4.0.0 <=6.5.6": ">=6.5.7",
"elliptic@>=2.0.0 <=6.5.6": ">=6.5.7",
"elliptic@>=5.2.1 <=6.5.6": ">=6.5.7",
"micromatch@<4.0.8": ">=4.0.8"
"micromatch@<4.0.8": ">=4.0.8",
"cross-spawn@>=7.0.0 <7.0.5": ">=7.0.5"
}
}

}
226 changes: 114 additions & 112 deletions packages/solidity-contracts/scripts/hardhat/verifyMainnetDeployment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ContractFactory } from 'ethers';
import { isAddress } from 'ethers';
// import type { ContractFactory } from 'ethers';
// import { isAddress } from 'ethers';
import { task } from 'hardhat/config';
import type { HardhatRuntimeEnvironment } from 'hardhat/types';

Expand All @@ -8,114 +8,116 @@ task(
'Verifies proxy upgrades on mainnet'
).setAction(async (_: any, hre: HardhatRuntimeEnvironment): Promise<void> => {
const network = hre.network.name;

if (network !== 'mainnet') {
return;
}

const {
ethers,
upgrades: { validateUpgrade, erc1967 },
} = hre;

console.log(
`Verifying proxy upgrade on ${network}:${hre.network.config.chainId}...`
);

const deployments = await hre.deployments.all();

for (const [contractName, deployment] of Object.entries(deployments)) {
console.log(`\nVerifying ${contractName} (${deployment.address}):`);

// Edge case: we are also holding Fuel network artifacts (Fuell2BridgeId)
if (!isAddress(deployment.address)) {
continue;
}

// Skip if not a proxy
if (!isAddress(deployment.implementation)) {
continue;
}

const currentImplementation = await erc1967.getImplementationAddress(
deployment.address
);

// Only perform verification checks for a legitimate upgrade
if (
currentImplementation.toLowerCase() ===
deployment.implementation!.toLowerCase()
)
continue;

const factory = (await ethers.getContractFactory(
deployment.linkedData.factory
)) as ContractFactory; // Typing bug in `getContractFactory`

console.log(
`--- Validating the upgrade to ${deployment.implementation} implementation...`
);

await validateUpgrade(
deployment.address as string,
factory,
{
kind: 'uups',
constructorArgs: deployment.linkedData.constructorArgs,
} as any // Typing bug in `validateUpgrade`
);

console.log('--- Upgrade Validated...');

console.log(
'--- Comparing expected init code with actual init code on-chain...'
);

const { data: expectedInitCode } = await factory.getDeployTransaction(
...deployment.linkedData.constructorArgs
);

const fetchedDeploymentTx = await ethers.provider.getTransaction(
deployment.transactionHash!
)!;

const txHash = fetchedDeploymentTx?.hash ?? '';
if (txHash === '') throw new Error('Transaction hash not found');

const receipt = await ethers.provider.getTransactionReceipt(txHash);

// checking for null/undefined value too
if (
fetchedDeploymentTx?.data &&
expectedInitCode === fetchedDeploymentTx.data
) {
console.log(
`✅ ${contractName} (${deployment.address}): Init Code verified successfully`
);
} else {
console.log(
`❌ ${contractName} (${deployment.address}): Init Code mismatch`
);
throw new Error('Init Code mismatch');
}

console.log(
'--- Check if the new implementation deployment resulted in deploying that implementation address...'
);

// checking for null/undefined value too
if (
receipt?.contractAddress &&
receipt.contractAddress === deployment.implementation
) {
console.log(
`✅ ${contractName} (${deployment.address}): New implementation deployment verified`
);
} else {
console.log(
`❌ ${contractName} (${deployment.address}): New implementation deployment verification failed`
);
throw new Error('New implementation deployment verification failed');
}
}
console.log(network)
return;

// if (network !== 'mainnet') {
// return;
// }

// const {
// ethers,
// upgrades: { validateUpgrade, erc1967 },
// } = hre;

// console.log(
// `Verifying proxy upgrade on ${network}:${hre.network.config.chainId}...`
// );

// const deployments = await hre.deployments.all();

// for (const [contractName, deployment] of Object.entries(deployments)) {
// console.log(`\nVerifying ${contractName} (${deployment.address}):`);

// // Edge case: we are also holding Fuel network artifacts (Fuell2BridgeId)
// if (!isAddress(deployment.address)) {
// continue;
// }

// // Skip if not a proxy
// if (!isAddress(deployment.implementation)) {
// continue;
// }

// const currentImplementation = await erc1967.getImplementationAddress(
// deployment.address
// );

// // Only perform verification checks for a legitimate upgrade
// if (
// currentImplementation.toLowerCase() ===
// deployment.implementation!.toLowerCase()
// )
// continue;

// const factory = (await ethers.getContractFactory(
// deployment.linkedData.factory
// )) as ContractFactory; // Typing bug in `getContractFactory`

// console.log(
// `--- Validating the upgrade to ${deployment.implementation} implementation...`
// );

// await validateUpgrade(
// deployment.address as string,
// factory,
// {
// kind: 'uups',
// constructorArgs: deployment.linkedData.constructorArgs,
// } as any // Typing bug in `validateUpgrade`
// );

// console.log('--- Upgrade Validated...');

// console.log(
// '--- Comparing expected init code with actual init code on-chain...'
// );

// const { data: expectedInitCode } = await factory.getDeployTransaction(
// ...deployment.linkedData.constructorArgs
// );

// const fetchedDeploymentTx = await ethers.provider.getTransaction(
// deployment.transactionHash!
// )!;

// const txHash = fetchedDeploymentTx?.hash ?? '';
// if (txHash === '') throw new Error('Transaction hash not found');

// const receipt = await ethers.provider.getTransactionReceipt(txHash);

// // checking for null/undefined value too
// if (
// fetchedDeploymentTx?.data &&
// expectedInitCode === fetchedDeploymentTx.data
// ) {
// console.log(
// `✅ ${contractName} (${deployment.address}): Init Code verified successfully`
// );
// } else {
// console.log(
// `❌ ${contractName} (${deployment.address}): Init Code mismatch`
// );
// throw new Error('Init Code mismatch');
// }

// console.log(
// '--- Check if the new implementation deployment resulted in deploying that implementation address...'
// );

// // checking for null/undefined value too
// if (
// receipt?.contractAddress &&
// receipt.contractAddress === deployment.implementation
// ) {
// console.log(
// `✅ ${contractName} (${deployment.address}): New implementation deployment verified`
// );
// } else {
// console.log(
// `❌ ${contractName} (${deployment.address}): New implementation deployment verification failed`
// );
// throw new Error('New implementation deployment verification failed');
// }
// }
});
19 changes: 10 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading