From 7f0faa6c5641195d7b334294a00ddfb281429580 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Tue, 3 Dec 2024 09:05:42 -0800 Subject: [PATCH 01/13] Add fees and test --- lazer/contracts/evm/src/PythLazer.sol | 9 +++++- lazer/contracts/evm/test/PythLazer.t.sol | 36 ++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index 023be19b92..0b0bb10671 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -6,6 +6,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { TrustedSignerInfo[2] public trustedSigners; + uint256 public verification_fee = 0.01 ether; struct TrustedSignerInfo { address pubkey; @@ -62,7 +63,13 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { function verifyUpdate( bytes calldata update - ) external view returns (bytes calldata payload, address signer) { + ) external payable returns (bytes calldata payload, address signer) { + // Require fee and refund excess + require(msg.value >= verification_fee, "Insufficient fee provided"); + if (msg.value > verification_fee) { + payable(msg.sender).transfer(msg.value - verification_fee); + } + if (update.length < 71) { revert("input too short"); } diff --git a/lazer/contracts/evm/test/PythLazer.t.sol b/lazer/contracts/evm/test/PythLazer.t.sol index 0c8fc626c4..b1f5fc0fde 100644 --- a/lazer/contracts/evm/test/PythLazer.t.sol +++ b/lazer/contracts/evm/test/PythLazer.t.sol @@ -20,4 +20,40 @@ contract PythLazerTest is Test { skip(2000); assert(!pythLazer.isValidSigner(address(2))); } + + function test_verify_with_fee() public { + // Prepare dummy update and signer + address trustedSigner = 0xEfEf56cD66896f6799A90A4e4d512C330c094e44; + vm.prank(address(1)); + pythLazer.updateTrustedSigner(trustedSigner, 3000000000000000); + bytes memory update = hex"2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100"; + + uint256 fee = pythLazer.verification_fee(); + + address alice = makeAddr("alice"); + vm.deal(alice, 1 ether); + address bob = makeAddr("bob"); + vm.deal(bob, 1 ether); + + // Alice provides appropriate fee + vm.prank(alice); + pythLazer.verifyUpdate{ value: fee }(update); + assertEq(alice.balance, 1 ether - fee); + + // Alice overpays and is refunded + vm.prank(alice); + pythLazer.verifyUpdate{ value: 0.5 ether }(update); + assertEq(alice.balance, 1 ether - fee - fee); + + // Bob does not attach a fee + vm.prank(bob); + vm.expectRevert("Insufficient fee provided"); + pythLazer.verifyUpdate(update); + assertEq(bob.balance, 1 ether); + + // Bob does not attach enough fees + vm.expectRevert("Insufficient fee provided"); + pythLazer.verifyUpdate{ value: 0.00001 ether }(update); + assertEq(bob.balance, 1 ether); + } } From 51cdc0019827eae46dd8a1c8f7a20fa39f6819fc Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Tue, 3 Dec 2024 09:08:14 -0800 Subject: [PATCH 02/13] Adjust values --- lazer/contracts/evm/src/PythLazer.sol | 2 +- lazer/contracts/evm/test/PythLazer.t.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index 0b0bb10671..7657bf6a17 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -6,7 +6,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { TrustedSignerInfo[2] public trustedSigners; - uint256 public verification_fee = 0.01 ether; + uint256 public verification_fee = 0.00001 ether; struct TrustedSignerInfo { address pubkey; diff --git a/lazer/contracts/evm/test/PythLazer.t.sol b/lazer/contracts/evm/test/PythLazer.t.sol index b1f5fc0fde..4396e9293c 100644 --- a/lazer/contracts/evm/test/PythLazer.t.sol +++ b/lazer/contracts/evm/test/PythLazer.t.sol @@ -53,7 +53,7 @@ contract PythLazerTest is Test { // Bob does not attach enough fees vm.expectRevert("Insufficient fee provided"); - pythLazer.verifyUpdate{ value: 0.00001 ether }(update); + pythLazer.verifyUpdate{ value: 1 wei }(update); assertEq(bob.balance, 1 ether); } } From 3276d497373c2f511439f1c511dd07453cbf36d3 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Tue, 3 Dec 2024 09:12:16 -0800 Subject: [PATCH 03/13] Bob calls --- lazer/contracts/evm/test/PythLazer.t.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/lazer/contracts/evm/test/PythLazer.t.sol b/lazer/contracts/evm/test/PythLazer.t.sol index 4396e9293c..6dac845676 100644 --- a/lazer/contracts/evm/test/PythLazer.t.sol +++ b/lazer/contracts/evm/test/PythLazer.t.sol @@ -52,6 +52,7 @@ contract PythLazerTest is Test { assertEq(bob.balance, 1 ether); // Bob does not attach enough fees + vm.prank(bob); vm.expectRevert("Insufficient fee provided"); pythLazer.verifyUpdate{ value: 1 wei }(update); assertEq(bob.balance, 1 ether); From 9342d235e4e4e649663a79d49ed10ec6848d3c84 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Tue, 3 Dec 2024 09:21:47 -0800 Subject: [PATCH 04/13] precommit --- lazer/contracts/evm/test/PythLazer.t.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lazer/contracts/evm/test/PythLazer.t.sol b/lazer/contracts/evm/test/PythLazer.t.sol index 6dac845676..7639706f0b 100644 --- a/lazer/contracts/evm/test/PythLazer.t.sol +++ b/lazer/contracts/evm/test/PythLazer.t.sol @@ -26,7 +26,8 @@ contract PythLazerTest is Test { address trustedSigner = 0xEfEf56cD66896f6799A90A4e4d512C330c094e44; vm.prank(address(1)); pythLazer.updateTrustedSigner(trustedSigner, 3000000000000000); - bytes memory update = hex"2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100"; + bytes + memory update = hex"2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100"; uint256 fee = pythLazer.verification_fee(); @@ -37,12 +38,12 @@ contract PythLazerTest is Test { // Alice provides appropriate fee vm.prank(alice); - pythLazer.verifyUpdate{ value: fee }(update); + pythLazer.verifyUpdate{value: fee}(update); assertEq(alice.balance, 1 ether - fee); // Alice overpays and is refunded vm.prank(alice); - pythLazer.verifyUpdate{ value: 0.5 ether }(update); + pythLazer.verifyUpdate{value: 0.5 ether}(update); assertEq(alice.balance, 1 ether - fee - fee); // Bob does not attach a fee @@ -54,7 +55,7 @@ contract PythLazerTest is Test { // Bob does not attach enough fees vm.prank(bob); vm.expectRevert("Insufficient fee provided"); - pythLazer.verifyUpdate{ value: 1 wei }(update); + pythLazer.verifyUpdate{value: 1 wei}(update); assertEq(bob.balance, 1 ether); } } From 2d2d81ff9e76650d948217c499920bbbfc876202 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Tue, 3 Dec 2024 09:37:13 -0800 Subject: [PATCH 05/13] Change fee to 1 wei --- lazer/contracts/evm/src/PythLazer.sol | 2 +- lazer/contracts/evm/test/PythLazer.t.sol | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index 7657bf6a17..bd370b28f1 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -6,7 +6,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { TrustedSignerInfo[2] public trustedSigners; - uint256 public verification_fee = 0.00001 ether; + uint256 public verification_fee = 1 wei; struct TrustedSignerInfo { address pubkey; diff --git a/lazer/contracts/evm/test/PythLazer.t.sol b/lazer/contracts/evm/test/PythLazer.t.sol index 7639706f0b..13023c99d4 100644 --- a/lazer/contracts/evm/test/PythLazer.t.sol +++ b/lazer/contracts/evm/test/PythLazer.t.sol @@ -51,11 +51,5 @@ contract PythLazerTest is Test { vm.expectRevert("Insufficient fee provided"); pythLazer.verifyUpdate(update); assertEq(bob.balance, 1 ether); - - // Bob does not attach enough fees - vm.prank(bob); - vm.expectRevert("Insufficient fee provided"); - pythLazer.verifyUpdate{value: 1 wei}(update); - assertEq(bob.balance, 1 ether); } } From 0173c4952433b44f15a1c8a89530723ef4dd89ba Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Wed, 4 Dec 2024 13:20:28 -0800 Subject: [PATCH 06/13] Initialize verification fee in init function --- lazer/contracts/evm/src/PythLazer.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index bd370b28f1..4c99cce46b 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -6,7 +6,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { TrustedSignerInfo[2] public trustedSigners; - uint256 public verification_fee = 1 wei; + uint256 public verification_fee; struct TrustedSignerInfo { address pubkey; @@ -16,6 +16,8 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { function initialize(address _topAuthority) public initializer { __Ownable_init(_topAuthority); __UUPSUpgradeable_init(); + + verification_fee = 1 wei; } function _authorizeUpgrade(address) internal override onlyOwner {} From 87672a749a9f002d6037fbda420c79dc86010864 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 5 Dec 2024 16:41:21 -0800 Subject: [PATCH 07/13] Successfully perform upgrade on local anvil --- .../contracts/evm/script/PythLazerDeploy.s.sol | 17 +++++++++++++++++ lazer/contracts/evm/src/PythLazer.sol | 2 ++ 2 files changed, 19 insertions(+) diff --git a/lazer/contracts/evm/script/PythLazerDeploy.s.sol b/lazer/contracts/evm/script/PythLazerDeploy.s.sol index a5c22ef3b9..10dcc40c66 100644 --- a/lazer/contracts/evm/script/PythLazerDeploy.s.sol +++ b/lazer/contracts/evm/script/PythLazerDeploy.s.sol @@ -6,6 +6,7 @@ import {PythLazer} from "../src/PythLazer.sol"; import {ICreateX} from "createx/ICreateX.sol"; import {CreateX} from "createx/CreateX.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; // This script deploys the PythLazer proxy and implementation contract using // CreateX's contract factory to a deterministic address. Having deterministic @@ -168,8 +169,24 @@ contract PythLazerDeployScript is Script { return addr; } + function getProxyAddress(bytes11 seed) public view returns (address addr) { + (, bytes32 guardedSalt) = generateSalt(seed); + address proxyAddr = createX.computeCreate3Address({salt: guardedSalt}); + return proxyAddr; + } + function run() public { address impl = deployImplementation("lazer:impl"); deployProxy("lazer:proxy", impl); } + + function migrate() public { + address proxyAddress = getProxyAddress("lazer:proxy"); + address newImpl = deployImplementation("lazer:impl"); + bytes memory migrateCall = abi.encodeWithSignature("migrate()"); + vm.startBroadcast(); + UUPSUpgradeable proxy = UUPSUpgradeable(proxyAddress); + proxy.upgradeToAndCall(newImpl, migrateCall); + vm.stopBroadcast(); + } } diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index 4c99cce46b..14491ff6c9 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -16,7 +16,9 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { function initialize(address _topAuthority) public initializer { __Ownable_init(_topAuthority); __UUPSUpgradeable_init(); + } + function migrate() public onlyOwner { verification_fee = 1 wei; } From 5488bc5982889a8117a8dfa900819daaec5e0bb9 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 5 Dec 2024 17:01:13 -0800 Subject: [PATCH 08/13] Update README --- lazer/contracts/evm/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lazer/contracts/evm/README.md b/lazer/contracts/evm/README.md index c3f38123f9..1b3fe0e3f0 100644 --- a/lazer/contracts/evm/README.md +++ b/lazer/contracts/evm/README.md @@ -32,8 +32,9 @@ $ forge snapshot ### Anvil +Anvil does not come with CreateX by default. It can be deployed or an RPC which has the contract can be forked. The below command forks an RPC with a functional CreateX contract. ```shell -$ anvil +$ anvil --fork-url "https://eth-sepolia.public.blastapi.io" ``` ### Deploy @@ -42,6 +43,14 @@ $ anvil $ forge script script/PythLazerDeploy.s.sol --rpc-url --private-key --broadcast ``` +### Upgrade +The UUPSUpgradeable feature adds functions to the cocntract which support upgrading through the use of an UUPS/ERC1967Proxy. A function can be defined to migrate state if needed. Be careful of changing storage slots when upgrading. See [Documentation](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable) for more details. +In addition, the private key is necessary or contracts will be deployed to different addresses than expected. + +```shell +$ forge script script/PythLazerDeploy.s.sol --rpc-url --private-key --broadcast --sig "migrate()" +``` + ### Cast ```shell From c9e316088088881bb7045926b08757e9183a792e Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 5 Dec 2024 17:28:34 -0800 Subject: [PATCH 09/13] Increase trusted signer array to size 200 --- lazer/contracts/evm/script/PythLazerDeploy.s.sol | 1 + lazer/contracts/evm/src/PythLazer.sol | 13 +++++++++++-- lazer/contracts/evm/test/PythLazer.t.sol | 15 +++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lazer/contracts/evm/script/PythLazerDeploy.s.sol b/lazer/contracts/evm/script/PythLazerDeploy.s.sol index 10dcc40c66..86c4bed3ef 100644 --- a/lazer/contracts/evm/script/PythLazerDeploy.s.sol +++ b/lazer/contracts/evm/script/PythLazerDeploy.s.sol @@ -181,6 +181,7 @@ contract PythLazerDeployScript is Script { } function migrate() public { + // Deploys new version and updates proxy to use new address address proxyAddress = getProxyAddress("lazer:proxy"); address newImpl = deployImplementation("lazer:impl"); bytes memory migrateCall = abi.encodeWithSignature("migrate()"); diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index 14491ff6c9..f08f296493 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -5,8 +5,9 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { - TrustedSignerInfo[2] public trustedSigners; + TrustedSignerInfo[2] private deprecatedTrustedSigners; uint256 public verification_fee; + TrustedSignerInfo[200] internal trustedSigners; struct TrustedSignerInfo { address pubkey; @@ -16,10 +17,18 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { function initialize(address _topAuthority) public initializer { __Ownable_init(_topAuthority); __UUPSUpgradeable_init(); + + verification_fee = 1 wei; } function migrate() public onlyOwner { + require(trustedSigners.length >= deprecatedTrustedSigners.length, "trustedSigners cannot be migrated to smaller array"); + verification_fee = 1 wei; + for (uint8 i = 0; i < deprecatedTrustedSigners.length; i++) { + trustedSigners[i].pubkey = deprecatedTrustedSigners[i].pubkey; + trustedSigners[i].expiresAt = deprecatedTrustedSigners[i].expiresAt; + } } function _authorizeUpgrade(address) internal override onlyOwner {} @@ -104,6 +113,6 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { } function version() public pure returns (string memory) { - return "0.1.0"; + return "0.1.1"; } } diff --git a/lazer/contracts/evm/test/PythLazer.t.sol b/lazer/contracts/evm/test/PythLazer.t.sol index 13023c99d4..17a6d73043 100644 --- a/lazer/contracts/evm/test/PythLazer.t.sol +++ b/lazer/contracts/evm/test/PythLazer.t.sol @@ -12,7 +12,7 @@ contract PythLazerTest is Test { pythLazer.initialize(address(1)); } - function test_update() public { + function test_update_add_signer() public { assert(!pythLazer.isValidSigner(address(2))); vm.prank(address(1)); pythLazer.updateTrustedSigner(address(2), block.timestamp + 1000); @@ -21,7 +21,18 @@ contract PythLazerTest is Test { assert(!pythLazer.isValidSigner(address(2))); } - function test_verify_with_fee() public { + function test_update_remove_signer() public { + assert(!pythLazer.isValidSigner(address(2))); + vm.prank(address(1)); + pythLazer.updateTrustedSigner(address(2), block.timestamp + 1000); + assert(pythLazer.isValidSigner(address(2))); + + vm.prank(address(1)); + pythLazer.updateTrustedSigner(address(2), 0); + assert(!pythLazer.isValidSigner(address(2))); + } + + function test_verify() public { // Prepare dummy update and signer address trustedSigner = 0xEfEf56cD66896f6799A90A4e4d512C330c094e44; vm.prank(address(1)); From b20cef485b20621bfad89ee619f0bebc8021165f Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 5 Dec 2024 17:30:30 -0800 Subject: [PATCH 10/13] Reduce size to 100 for smaller gas cost --- lazer/contracts/evm/src/PythLazer.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index f08f296493..9258caa694 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -7,7 +7,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { TrustedSignerInfo[2] private deprecatedTrustedSigners; uint256 public verification_fee; - TrustedSignerInfo[200] internal trustedSigners; + TrustedSignerInfo[100] internal trustedSigners; struct TrustedSignerInfo { address pubkey; From 57c302d0bc32ba2e48a2980e79fcf04853623b63 Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 5 Dec 2024 17:57:21 -0800 Subject: [PATCH 11/13] pre-commit --- lazer/contracts/evm/script/PythLazerDeploy.s.sol | 2 +- lazer/contracts/evm/src/PythLazer.sol | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lazer/contracts/evm/script/PythLazerDeploy.s.sol b/lazer/contracts/evm/script/PythLazerDeploy.s.sol index 86c4bed3ef..0fb95fdc2c 100644 --- a/lazer/contracts/evm/script/PythLazerDeploy.s.sol +++ b/lazer/contracts/evm/script/PythLazerDeploy.s.sol @@ -182,7 +182,7 @@ contract PythLazerDeployScript is Script { function migrate() public { // Deploys new version and updates proxy to use new address - address proxyAddress = getProxyAddress("lazer:proxy"); + address proxyAddress = getProxyAddress("lazer:proxy"); address newImpl = deployImplementation("lazer:impl"); bytes memory migrateCall = abi.encodeWithSignature("migrate()"); vm.startBroadcast(); diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index 9258caa694..dcfe50fb24 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -22,7 +22,10 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { } function migrate() public onlyOwner { - require(trustedSigners.length >= deprecatedTrustedSigners.length, "trustedSigners cannot be migrated to smaller array"); + require( + trustedSigners.length >= deprecatedTrustedSigners.length, + "trustedSigners cannot be migrated to smaller array" + ); verification_fee = 1 wei; for (uint8 i = 0; i < deprecatedTrustedSigners.length; i++) { From 1bf3ae1b42dabf3a879c6d51efa5e7405ce3fc7c Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Thu, 5 Dec 2024 18:02:51 -0800 Subject: [PATCH 12/13] Pre-commit... again?! --- lazer/contracts/evm/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lazer/contracts/evm/README.md b/lazer/contracts/evm/README.md index 1b3fe0e3f0..7802fb15bf 100644 --- a/lazer/contracts/evm/README.md +++ b/lazer/contracts/evm/README.md @@ -32,9 +32,10 @@ $ forge snapshot ### Anvil -Anvil does not come with CreateX by default. It can be deployed or an RPC which has the contract can be forked. The below command forks an RPC with a functional CreateX contract. +Anvil does not come with CreateX by default. It can be deployed or an RPC which has the contract can be forked. The below command forks an RPC with a functional CreateX contract. + ```shell -$ anvil --fork-url "https://eth-sepolia.public.blastapi.io" +$ anvil --fork-url "https://eth-sepolia.public.blastapi.io" ``` ### Deploy @@ -44,6 +45,7 @@ $ forge script script/PythLazerDeploy.s.sol --rpc-url --private-k ``` ### Upgrade + The UUPSUpgradeable feature adds functions to the cocntract which support upgrading through the use of an UUPS/ERC1967Proxy. A function can be defined to migrate state if needed. Be careful of changing storage slots when upgrading. See [Documentation](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable) for more details. In addition, the private key is necessary or contracts will be deployed to different addresses than expected. From 28aa2c2f2221c7e78d3e63946f1cde0f7b63f57c Mon Sep 17 00:00:00 2001 From: Darun Seethammagari Date: Fri, 6 Dec 2024 13:01:01 -0800 Subject: [PATCH 13/13] Change storage layout for trusted signers --- lazer/contracts/evm/src/PythLazer.sol | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lazer/contracts/evm/src/PythLazer.sol b/lazer/contracts/evm/src/PythLazer.sol index dcfe50fb24..b2b72480bb 100644 --- a/lazer/contracts/evm/src/PythLazer.sol +++ b/lazer/contracts/evm/src/PythLazer.sol @@ -5,9 +5,8 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { - TrustedSignerInfo[2] private deprecatedTrustedSigners; - uint256 public verification_fee; TrustedSignerInfo[100] internal trustedSigners; + uint256 public verification_fee; struct TrustedSignerInfo { address pubkey; @@ -22,16 +21,7 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable { } function migrate() public onlyOwner { - require( - trustedSigners.length >= deprecatedTrustedSigners.length, - "trustedSigners cannot be migrated to smaller array" - ); - verification_fee = 1 wei; - for (uint8 i = 0; i < deprecatedTrustedSigners.length; i++) { - trustedSigners[i].pubkey = deprecatedTrustedSigners[i].pubkey; - trustedSigners[i].expiresAt = deprecatedTrustedSigners[i].expiresAt; - } } function _authorizeUpgrade(address) internal override onlyOwner {}