@@ -12,14 +12,30 @@ task("upgrade-spokepool", "Generate calldata to upgrade a SpokePool deployment")
1212
1313 const { ethers } = hre ;
1414
15+ const artifact = await hre . artifacts . readArtifact ( "SpokePool" ) ;
16+
1517 // @dev Any spoke pool's interface can be used here since they all should have the same upgradeTo function signature.
16- const abi = [ "function upgradeTo(address newImplementation) external" ] ;
18+ const abi = artifact . abi ;
1719 const spokePool = new ethers . Contract ( implementation , abi ) ;
1820
19- const upgradeTo = spokePool . interface . encodeFunctionData ( "upgradeTo" , [ implementation ] ) ;
20- console . log ( `upgradeTo bytes: ` , upgradeTo ) ;
21+ let calldata = "" ;
22+
23+ /**
24+ * We perform this seemingly unnecessary pause/unpause sequence because we want to ensure that the
25+ * upgrade is successful and the new implementation gets forwarded calls by the proxy contract as expected
26+ *
27+ * Since the upgrade and call happens atomically, the upgrade will revert if the new implementation
28+ * is not functioning correctly.
29+ */
30+ const data = spokePool . interface . encodeFunctionData ( "multicall" , [
31+ [
32+ spokePool . interface . encodeFunctionData ( "pauseDeposits" , [ true ] ) ,
33+ spokePool . interface . encodeFunctionData ( "pauseDeposits" , [ false ] ) ,
34+ ] ,
35+ ] ) ;
2136
37+ calldata = spokePool . interface . encodeFunctionData ( "upgradeToAndCall" , [ implementation , data ] ) ;
2238 console . log (
23- `Call relaySpokePoolAdminFunction() with the params [<chainId>, ${ upgradeTo } ] on the hub pool from the owner's account.`
39+ `Call relaySpokePoolAdminFunction() with the params [<chainId>, ${ calldata } ] on the hub pool from the owner's account.`
2440 ) ;
2541 } ) ;
0 commit comments