@inco/lightning 1.0.0-devnet-9 → 1.0.0-rc-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/manifest.yaml +26 -0
- package/package.json +1 -1
- package/src/DeployUtils.sol +28 -39
- package/src/Lib.sol +2 -2
- package/src/Lib.testnet.sol +2 -2
- package/src/libs/incoLightning_testnet_v12_687186260.sol +1242 -0
- package/src/periphery/SaltLib.sol +65 -0
- package/src/test/IncoTest.sol +1 -1
- package/src/test/TestUpgrade.t.sol +2 -1
- package/src/version/IncoLightningConfig.sol +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
/// @dev Flag controlling cross-chain deployment authorization.
|
|
5
|
+
/// Set to 0x00 to allow same contract at same address on all chains.
|
|
6
|
+
/// Set to 0x01 to restrict to single chain deployment.
|
|
7
|
+
bytes1 constant CROSS_CHAIN_DEPLOY_AUTHORIZED_FLAG = 0x00;
|
|
8
|
+
|
|
9
|
+
/// @title Salt
|
|
10
|
+
/// @notice Shared salt derivation for CREATE3 deployments of Inco Lightning contracts.
|
|
11
|
+
/// @dev Layout of every salt produced by this library:
|
|
12
|
+
/// - bytes 0..19 : deployer address (CreateX `_guard` requires `salt[0..19] == msg.sender`,
|
|
13
|
+
/// i.e. the entity calling CreateX must match the address encoded here —
|
|
14
|
+
/// this is what binds the deterministic address to a specific deployer key
|
|
15
|
+
/// or Safe).
|
|
16
|
+
/// - byte 20 : `CROSS_CHAIN_DEPLOY_AUTHORIZED_FLAG` (0x00 = cross-chain auth allowed).
|
|
17
|
+
/// - bytes 21..31 : keccak-based entropy derived from the contract identity (name +
|
|
18
|
+
/// MAJOR version + pepper for proxy salts; proxy salt + "impl" +
|
|
19
|
+
/// MINOR + PATCH for impl salts).
|
|
20
|
+
///
|
|
21
|
+
/// `getSalt` builds a proxy salt — one per (contract, MAJOR, deployer, pepper) tuple, so
|
|
22
|
+
/// the proxy address is stable across MINOR/PATCH upgrades. `getImplSalt` derives a fresh
|
|
23
|
+
/// salt for each new implementation by mixing in MINOR/PATCH, ensuring each version maps
|
|
24
|
+
/// to a distinct impl address and an `upgradeToAndCall` never targets an already-used slot.
|
|
25
|
+
library Salt {
|
|
26
|
+
|
|
27
|
+
/// @notice Computes a deployment salt from contract metadata
|
|
28
|
+
/// @dev The salt incorporates:
|
|
29
|
+
/// - Deployer address (first 20 bytes)
|
|
30
|
+
/// - Cross-chain flag (1 byte)
|
|
31
|
+
/// - Hash of name, version, and pepper (last 11 bytes)
|
|
32
|
+
/// @param name The contract name (e.g., "IncoLightning")
|
|
33
|
+
/// @param majorVersionNumber The major version number
|
|
34
|
+
/// @param deployer The address that will deploy the contract
|
|
35
|
+
/// @param pepper Additional entropy to avoid address collisions
|
|
36
|
+
/// @return The 32-byte salt for CreateX deployment
|
|
37
|
+
function getSalt(string memory name, uint8 majorVersionNumber, address deployer, string memory pepper)
|
|
38
|
+
internal
|
|
39
|
+
pure
|
|
40
|
+
returns (bytes32)
|
|
41
|
+
{
|
|
42
|
+
return bytes32(
|
|
43
|
+
abi.encodePacked(
|
|
44
|
+
deployer,
|
|
45
|
+
CROSS_CHAIN_DEPLOY_AUTHORIZED_FLAG,
|
|
46
|
+
bytes11(keccak256(abi.encodePacked(name, majorVersionNumber, pepper)))
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// @notice Derives a salt for an implementation from its proxy salt + minor + patch version.
|
|
52
|
+
/// @dev Each minor/patch version gets a distinct implementation address, preventing
|
|
53
|
+
/// collision when upgrading (CREATE3 reverts if target address already has code).
|
|
54
|
+
/// The deployer address and cross-chain flag are preserved from the proxy salt.
|
|
55
|
+
function getImplSalt(bytes32 proxySalt, uint8 minor, uint8 patch) internal pure returns (bytes32) {
|
|
56
|
+
address deployer = address(bytes20(proxySalt));
|
|
57
|
+
bytes1 crossChainFlag = proxySalt[20];
|
|
58
|
+
return bytes32(
|
|
59
|
+
abi.encodePacked(
|
|
60
|
+
deployer, crossChainFlag, bytes11(keccak256(abi.encodePacked(proxySalt, "impl", minor, patch)))
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
package/src/test/IncoTest.sol
CHANGED
|
@@ -62,7 +62,7 @@ contract IncoTest is MockOpHandler, DeployUtils, FakeDecryptionAttester, MockRem
|
|
|
62
62
|
deployer: testDeployer,
|
|
63
63
|
owner: owner,
|
|
64
64
|
// The highest precedent deployment pepper
|
|
65
|
-
pepper: "
|
|
65
|
+
pepper: "testnet",
|
|
66
66
|
quoteVerifier: new FakeQuoteVerifier()
|
|
67
67
|
});
|
|
68
68
|
vm.stopPrank();
|
|
@@ -16,6 +16,7 @@ import {IVersion} from "../version/interfaces/IVersion.sol";
|
|
|
16
16
|
import {Version} from "../version/Version.sol";
|
|
17
17
|
import {IIncoVerifier} from "../interfaces/IIncoVerifier.sol";
|
|
18
18
|
import {MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION} from "../version/IncoLightningConfig.sol";
|
|
19
|
+
import {Salt} from "../periphery/SaltLib.sol";
|
|
19
20
|
|
|
20
21
|
interface IUUPS {
|
|
21
22
|
|
|
@@ -57,7 +58,7 @@ contract TestUpgrade is IncoTest {
|
|
|
57
58
|
incoProxyAddr = address(inco);
|
|
58
59
|
|
|
59
60
|
// Deploy V2
|
|
60
|
-
bytes32 salt = getSalt("IncoLightningV2", 255, testDeployer, "testnet");
|
|
61
|
+
bytes32 salt = Salt.getSalt("IncoLightningV2", 255, testDeployer, "testnet");
|
|
61
62
|
v2Impl = new IncoLightningV2(salt);
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -13,6 +13,6 @@ uint8 constant MINOR_VERSION = 0;
|
|
|
13
13
|
// otherwise make test_upgrade will fail
|
|
14
14
|
// consequently, when we do a patch release, we don't need to pump it as it's already pumped
|
|
15
15
|
// when the previous release was done
|
|
16
|
-
uint8 constant PATCH_VERSION =
|
|
16
|
+
uint8 constant PATCH_VERSION = 3;
|
|
17
17
|
|
|
18
18
|
string constant VERIFIER_NAME = "incoVerifier";
|