Ver Fonte

Increase trusted signer array to size 200

Darun Seethammagari há 11 meses atrás
pai
commit
c9e3160880

+ 1 - 0
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()");

+ 11 - 2
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";
     }
 }

+ 13 - 2
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));