Skip to content

Commit

Permalink
add support for mnenomic offset
Browse files Browse the repository at this point in the history
  • Loading branch information
alysiahuggins committed Jul 11, 2024
1 parent fe05b8d commit 3deae0e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions contracts/script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ forge script contracts/script/LightClient.s.sol:DeployLightClientContractScript
To Upgrade

```bash
forge script contracts/script/UpgradeLightClient.s.sol:UpgradeLightClientScript $admin $mostRecentlyDeployedProxy \
--sig 'run(address, address)' \
forge script contracts/script/UpgradeLightClient.s.sol:UpgradeLightClientScript $offset $mostRecentlyDeployedProxy \
--sig 'run(uint32, address)' \
--ffi \
--rpc-url https://ethereum-sepolia.publicnode.com \
--broadcast --legacy
Expand Down
7 changes: 5 additions & 2 deletions contracts/script/UpgradeLightClient.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ contract UpgradeLightClientScript is Script {
/// @param mostRecentlyDeployedProxy address of deployed proxy
/// @return address of the proxy
/// TODO get the most recent deployment from the devops tooling
function run(address mostRecentlyDeployedProxy) external returns (address) {
function run(uint32 seedPhraseOffset, address mostRecentlyDeployedProxy)
external
returns (address)
{
string memory seedPhrase = vm.envString("MNEMONIC");
(address admin,) = deriveRememberKey(seedPhrase, 0);
(address admin,) = deriveRememberKey(seedPhrase, seedPhraseOffset);
vm.startBroadcast(admin);
address proxy = upgradeLightClient(mostRecentlyDeployedProxy, address(new LCV2()));
return proxy;
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/LightClientUpgrade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract LightClientUpgradeTest is Test {
// Upgrade LightClient and check that the genesis state is not changed and that the new
// field
// of the upgraded contract is set to 0
lcV2Proxy = LCV2(upgrader.run(proxy));
lcV2Proxy = LCV2(upgrader.run(0, proxy));

assertEq(lcV2Proxy.newField(), 0);
assertEq(lcV2Proxy.blocksPerEpoch(), 10);
Expand Down Expand Up @@ -75,7 +75,7 @@ contract LightClientUpgradeTest is Test {
assertEq(patch, 0);

//upgrade box
lcV2Proxy = LCV2(upgrader.run(proxy));
lcV2Proxy = LCV2(upgrader.run(0, proxy));
assertEq(address(lcV2Proxy), address(lcV1Proxy));
(uint8 majorV2, uint8 minorV2, uint8 patchV2) = lcV2Proxy.getVersion();
assertEq(majorV2, 2);
Expand All @@ -89,6 +89,6 @@ contract LightClientUpgradeTest is Test {
//attempted upgrade as attacker will revert
vm.prank(attacker);
vm.expectRevert();
lcV2Proxy = LCV2(upgrader.run(address(proxy)));
lcV2Proxy = LCV2(upgrader.run(0, address(proxy)));
}
}

0 comments on commit 3deae0e

Please sign in to comment.