diff --git a/kms/auth-eth/contracts/DstackApp.sol b/kms/auth-eth/contracts/DstackApp.sol index a0093b0a9..7eafcd703 100644 --- a/kms/auth-eth/contracts/DstackApp.sol +++ b/kms/auth-eth/contracts/DstackApp.sol @@ -33,23 +33,50 @@ contract DstackApp is // Mapping of allowed device IDs for this app mapping(bytes32 => bool) public allowedDeviceIds; + // Whether to require TCB status to be UpToDate + bool public requireTcbUpToDate; + // Additional events specific to DstackApp event UpgradesDisabled(); event AllowAnyDeviceSet(bool allowAny); + event RequireTcbUpToDateSet(bool requireUpToDate); /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } - // Initialize the contract + // Old initialize — preserved for upgrade compatibility + function initialize( + address initialOwner, + bool _disableUpgrades, + bool _allowAnyDevice, + bytes32 initialDeviceId, + bytes32 initialComposeHash + ) public initializer { + _initializeCommon(initialOwner, _disableUpgrades, _allowAnyDevice, initialDeviceId, initialComposeHash); + } + + // New initialize — includes requireTcbUpToDate function initialize( address initialOwner, bool _disableUpgrades, + bool _requireTcbUpToDate, bool _allowAnyDevice, bytes32 initialDeviceId, bytes32 initialComposeHash ) public initializer { + requireTcbUpToDate = _requireTcbUpToDate; + _initializeCommon(initialOwner, _disableUpgrades, _allowAnyDevice, initialDeviceId, initialComposeHash); + } + + function _initializeCommon( + address initialOwner, + bool _disableUpgrades, + bool _allowAnyDevice, + bytes32 initialDeviceId, + bytes32 initialComposeHash + ) internal { require(initialOwner != address(0), "invalid owner address"); _upgradesDisabled = _disableUpgrades; @@ -72,6 +99,10 @@ contract DstackApp is __ERC165_init(); } + function version() public pure returns (uint256) { + return 2; + } + /** * @dev See {IERC165-supportsInterface}. * @notice Returns true if this contract implements the interface defined by interfaceId @@ -114,6 +145,12 @@ contract DstackApp is emit AllowAnyDeviceSet(_allowAnyDevice); } + // Set whether TCB status must be UpToDate to boot this app + function setRequireTcbUpToDate(bool _requireUpToDate) external onlyOwner { + requireTcbUpToDate = _requireUpToDate; + emit RequireTcbUpToDateSet(_requireUpToDate); + } + // Add a device ID to allowed list function addDevice(bytes32 deviceId) external onlyOwner { allowedDeviceIds[deviceId] = true; @@ -130,6 +167,15 @@ contract DstackApp is function isAppAllowed( IAppAuth.AppBootInfo calldata bootInfo ) external view override returns (bool isAllowed, string memory reason) { + // Optionally require TCB status to be up to date + if ( + requireTcbUpToDate && + keccak256(abi.encodePacked(bootInfo.tcbStatus)) != + keccak256(abi.encodePacked("UpToDate")) + ) { + return (false, "TCB status is not up to date"); + } + // Check if compose hash is allowed if (!allowedComposeHashes[bootInfo.composeHash]) { return (false, "Compose hash not allowed"); @@ -150,5 +196,5 @@ contract DstackApp is } // Add storage gap for upgradeable contracts - uint256[50] private __gap; + uint256[49] private __gap; } diff --git a/kms/auth-eth/contracts/DstackKms.sol b/kms/auth-eth/contracts/DstackKms.sol index 9a26ef4ff..64031076c 100644 --- a/kms/auth-eth/contracts/DstackKms.sol +++ b/kms/auth-eth/contracts/DstackKms.sol @@ -144,30 +144,47 @@ contract DstackKms is function deployAndRegisterApp( address initialOwner, bool disableUpgrades, + bool requireTcbUpToDate, bool allowAnyDevice, bytes32 initialDeviceId, bytes32 initialComposeHash - ) external returns (address appId) { + ) public returns (address appId) { require(appImplementation != address(0), "DstackApp implementation not set"); require(initialOwner != address(0), "Invalid owner address"); - // Prepare initialization data bytes memory initData = abi.encodeWithSelector( - bytes4(keccak256("initialize(address,bool,bool,bytes32,bytes32)")), + bytes4(keccak256("initialize(address,bool,bool,bool,bytes32,bytes32)")), initialOwner, disableUpgrades, + requireTcbUpToDate, allowAnyDevice, initialDeviceId, initialComposeHash ); - // Deploy proxy contract appId = address(new ERC1967Proxy(appImplementation, initData)); - // Register to KMS registerApp(appId); emit AppDeployedViaFactory(appId, msg.sender); } + // Backward compatible factory method for old SDK callers (pre TCB flag) + function deployAndRegisterApp( + address initialOwner, + bool disableUpgrades, + bool allowAnyDevice, + bytes32 initialDeviceId, + bytes32 initialComposeHash + ) external returns (address appId) { + return deployAndRegisterApp( + initialOwner, + disableUpgrades, + false, + allowAnyDevice, + initialDeviceId, + initialComposeHash + ); + } + // Function to register an aggregated MR measurement function addKmsAggregatedMr(bytes32 mrAggregated) external onlyOwner { kmsAllowedAggregatedMrs[mrAggregated] = true; diff --git a/kms/auth-eth/foundry-cast-cheatsheet.md b/kms/auth-eth/foundry-cast-cheatsheet.md index b26449345..d8f13add1 100644 --- a/kms/auth-eth/foundry-cast-cheatsheet.md +++ b/kms/auth-eth/foundry-cast-cheatsheet.md @@ -84,6 +84,10 @@ npx hardhat kms:deploy-impl --network test cast send $KMS_CONTRACT_ADDRESS "upgradeTo(address)" "NEW_IMPL_ADDRESS" \ --private-key $PRIVATE_KEY --rpc-url $RPC_URL --gas-limit 500000 +# Note: Existing KMS proxy deployments can be upgraded in-place using the steps above. +# This release only adds optional app boot TCB checks in DstackApp and keeps the KMS +# storage layout unchanged, so no initializer is required for the KMS upgrade. + # Verify upgrade success cast storage $KMS_CONTRACT_ADDRESS 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc --rpc-url $RPC_URL # Should show the new implementation address @@ -181,18 +185,18 @@ cast send $KMS_CONTRACT_ADDRESS "removeKmsDevice(bytes32)" \ ```bash # kms:create-app - Deploy and register DstackApp in single transaction -cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" \ - "$DEPLOYER_ADDRESS" false true \ +cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" \ + "$DEPLOYER_ADDRESS" false false true \ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \ "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321" \ --private-key $PRIVATE_KEY --rpc-url $RPC_URL -# Parameters: (owner, disableUpgrades, allowAnyDevice, initialDeviceId, initialComposeHash) +# Parameters: (owner, disableUpgrades, requireTcbUpToDate, allowAnyDevice, initialDeviceId, initialComposeHash) # Use 0x0000...0000 for empty device/hash values -# To decode return: cast abi-decode "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)(address,address)" RETURN_DATA +# To decode return: cast abi-decode "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)(address,address)" RETURN_DATA # Example with no initial data: -cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" \ - "$DEPLOYER_ADDRESS" false true \ +cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" \ + "$DEPLOYER_ADDRESS" false false true \ "0x0000000000000000000000000000000000000000000000000000000000000000" \ "0x0000000000000000000000000000000000000000000000000000000000000000" \ --private-key $PRIVATE_KEY --rpc-url $RPC_URL @@ -379,7 +383,7 @@ cast abi-decode "kmsAllowedAggregatedMrs(bytes32)(bool)" RETURN_DATA cast abi-decode "isAppAllowed((address,bytes32,address,bytes32,bytes32,bytes32,bytes32,string,string[]))(bool,string)" RETURN_DATA # Decode factory deployment response -cast abi-decode "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)(address,address)" RETURN_DATA +cast abi-decode "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)(address,address)" RETURN_DATA ``` ### Get Contract Information @@ -459,7 +463,7 @@ cast send $KMS_CONTRACT_ADDRESS "addKmsAggregatedMr(bytes32)" "0x..." \ --private-key $PRIVATE_KEY --rpc-url $RPC_URL # 3. Users can now deploy apps via factory immediately! -cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" \ +cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" \ "$USER_ADDRESS" false true "0x..." "0x..." \ --private-key $USER_PRIVATE_KEY --rpc-url $RPC_URL ``` @@ -485,7 +489,7 @@ cast send $KMS_CONTRACT_ADDRESS "addKmsAggregatedMr(bytes32)" "0x..." \ --private-key $PRIVATE_KEY --rpc-url $RPC_URL # 5. Users can now deploy apps via factory -cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" \ +cast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" \ "$USER_ADDRESS" false true "0x..." "0x..." \ --private-key $USER_PRIVATE_KEY --rpc-url $RPC_URL ``` @@ -547,7 +551,7 @@ mycast send $APP_AUTH_ADDRESS "addDevice(bytes32)" \ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" # Example: Factory deployment -mycast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" \ +mycast send $KMS_CONTRACT_ADDRESS "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" \ "$DEPLOYER_ADDRESS" false true \ "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef" \ "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321" @@ -557,4 +561,4 @@ mycast storage $KMS_CONTRACT_ADDRESS 0x360894a13ba1a3210667c828492db98dca3e2076c # Example: Upgrade contract mycast send $KMS_CONTRACT_ADDRESS "upgradeTo(address)" "NEW_IMPL_ADDRESS" --gas-limit 500000 -``` \ No newline at end of file +``` diff --git a/kms/auth-eth/hardhat.config.ts b/kms/auth-eth/hardhat.config.ts index dd7c660c5..4a635e171 100644 --- a/kms/auth-eth/hardhat.config.ts +++ b/kms/auth-eth/hardhat.config.ts @@ -244,6 +244,7 @@ task("kms:get-app-implementation", "Get current DstackApp implementation address task("app:deploy", "Deploy DstackApp with a UUPS proxy") .addFlag("allowAnyDevice", "Allow any device to boot this app") + .addFlag("requireTcbUpToDate", "Require TCB status to be UpToDate") .addOptionalParam("device", "Initial device ID", "", types.string) .addOptionalParam("hash", "Initial compose hash", "", types.string) .setAction(async (taskArgs, hre) => { @@ -267,14 +268,14 @@ task("app:deploy", "Deploy DstackApp with a UUPS proxy") console.log("Initial compose hash:", composeHash === "0x0000000000000000000000000000000000000000000000000000000000000000" ? "none" : composeHash); } - // Use standard deployment - all cases use the same 6-parameter initializer const appContract = await deployContract(hre, "DstackApp", [ - deployerAddress, - false, - taskArgs.allowAnyDevice, + deployerAddress, + false, // _disableUpgrades + taskArgs.requireTcbUpToDate, // _requireTcbUpToDate + taskArgs.allowAnyDevice, // _allowAnyDevice deviceId, composeHash - ]); + ], false, "initialize(address,bool,bool,bool,bytes32,bytes32)"); if (!appContract) { return; @@ -333,6 +334,7 @@ task("app:deploy", "Deploy DstackApp with a UUPS proxy") task("kms:create-app", "Create DstackApp via KMS factory method (single transaction)") .addFlag("allowAnyDevice", "Allow any device to boot this app") + .addFlag("requireTcbUpToDate", "Require TCB status to be UpToDate") .addOptionalParam("device", "Initial device ID", "", types.string) .addOptionalParam("hash", "Initial compose hash", "", types.string) .setAction(async (taskArgs, hre) => { @@ -351,10 +353,11 @@ task("kms:create-app", "Create DstackApp via KMS factory method (single transact console.log("Initial compose hash:", composeHash === "0x0000000000000000000000000000000000000000000000000000000000000000" ? "none" : composeHash); console.log("Using factory method for single-transaction deployment..."); - // Single transaction deployment via factory - const tx = await kmsContract.deployAndRegisterApp( + // Single transaction deployment via factory (explicit signature to disambiguate overloads) + const tx = await kmsContract["deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"]( deployerAddress, // deployer owns the contract false, // disableUpgrades + taskArgs.requireTcbUpToDate, taskArgs.allowAnyDevice, deviceId, composeHash diff --git a/kms/auth-eth/lib/deployment-helpers.ts b/kms/auth-eth/lib/deployment-helpers.ts index dbcb2b66f..3e824491a 100644 --- a/kms/auth-eth/lib/deployment-helpers.ts +++ b/kms/auth-eth/lib/deployment-helpers.ts @@ -62,14 +62,15 @@ export async function accountBalance(ethers: any, address: string) { export async function estimateDeploymentCost( hre: HardhatRuntimeEnvironment, contractName: string, - initializerArgs: any[] = [] + initializerArgs: any[] = [], + initializer?: string ) { console.log("Estimating deployment costs..."); const factory = await hre.ethers.getContractFactory(contractName); // Get the data for initialize function const initData = factory.interface.encodeFunctionData( - "initialize", + initializer || "initialize", initializerArgs ); diff --git a/kms/auth-eth/scripts/deploy.ts b/kms/auth-eth/scripts/deploy.ts index 95b5587ac..9ad4a2cde 100644 --- a/kms/auth-eth/scripts/deploy.ts +++ b/kms/auth-eth/scripts/deploy.ts @@ -6,7 +6,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import * as helpers from "../lib/deployment-helpers"; // This function should be called directly by Hardhat tasks -export async function deployContract(hre: HardhatRuntimeEnvironment, contractName: string, initializerArgs: any[] = [], quiet: boolean = false) { +export async function deployContract(hre: HardhatRuntimeEnvironment, contractName: string, initializerArgs: any[] = [], quiet: boolean = false, initializer?: string) { try { function log(...msgs: any[]) { if (!quiet) { @@ -29,7 +29,8 @@ export async function deployContract(hre: HardhatRuntimeEnvironment, contractNam await helpers.estimateDeploymentCost( hre, contractName, - initializerArgs + initializerArgs, + initializer ); // Prompt for confirmation @@ -43,7 +44,7 @@ export async function deployContract(hre: HardhatRuntimeEnvironment, contractNam log("Deploying proxy..."); const contract = await hre.upgrades.deployProxy(contractFactory, initializerArgs, - { kind: 'uups' } + { kind: 'uups', ...(initializer ? { initializer } : {}) } ); log("Waiting for deployment..."); await contract.waitForDeployment(); diff --git a/kms/auth-eth/test/DstackApp.test.ts b/kms/auth-eth/test/DstackApp.test.ts index 6421402e3..67fc21646 100644 --- a/kms/auth-eth/test/DstackApp.test.ts +++ b/kms/auth-eth/test/DstackApp.test.ts @@ -18,12 +18,13 @@ describe("DstackApp", function () { beforeEach(async function () { [owner, user] = await ethers.getSigners(); appAuth = await deployContract(hre, "DstackApp", [ - owner.address, + owner.address, false, // _disableUpgrades + false, // _requireTcbUpToDate true, // _allowAnyDevice ethers.ZeroHash, // initialDeviceId (empty) ethers.ZeroHash // initialComposeHash (empty) - ], true) as DstackApp; + ], true, "initialize(address,bool,bool,bool,bytes32,bytes32)") as DstackApp; appId = await appAuth.getAddress(); }); @@ -31,6 +32,10 @@ describe("DstackApp", function () { it("Should set the correct owner", async function () { expect(await appAuth.owner()).to.equal(owner.address); }); + + it("Should return version 2", async function () { + expect(await appAuth.version()).to.equal(2); + }); }); describe("Compose hash management", function () { @@ -61,6 +66,68 @@ describe("DstackApp", function () { }); }); + describe("TCB requirement via initialize", function () { + it("Should reject outdated TCB when initialized with requireTcbUpToDate=true", async function () { + const tcbApp = await deployContract(hre, "DstackApp", [ + owner.address, + false, // _disableUpgrades + true, // _requireTcbUpToDate + true, // _allowAnyDevice + ethers.ZeroHash, + ethers.ZeroHash + ], true, "initialize(address,bool,bool,bool,bytes32,bytes32)") as DstackApp; + + const composeHash = ethers.randomBytes(32); + await tcbApp.addComposeHash(composeHash); + + const bootInfo = { + appId: await tcbApp.getAddress(), + composeHash, + instanceId: ethers.Wallet.createRandom().address, + deviceId: ethers.randomBytes(32), + mrAggregated: ethers.randomBytes(32), + mrSystem: ethers.randomBytes(32), + osImageHash: ethers.randomBytes(32), + tcbStatus: "OutOfDate", + advisoryIds: [] + }; + + const [isAllowed, reason] = await tcbApp.isAppAllowed(bootInfo); + expect(isAllowed).to.be.false; + expect(reason).to.equal("TCB status is not up to date"); + }); + + it("Should allow UpToDate TCB when initialized with requireTcbUpToDate=true", async function () { + const tcbApp = await deployContract(hre, "DstackApp", [ + owner.address, + false, + true, // _requireTcbUpToDate + true, // _allowAnyDevice + ethers.ZeroHash, + ethers.ZeroHash + ], true, "initialize(address,bool,bool,bool,bytes32,bytes32)") as DstackApp; + + const composeHash = ethers.randomBytes(32); + await tcbApp.addComposeHash(composeHash); + + const bootInfo = { + appId: await tcbApp.getAddress(), + composeHash, + instanceId: ethers.Wallet.createRandom().address, + deviceId: ethers.randomBytes(32), + mrAggregated: ethers.randomBytes(32), + mrSystem: ethers.randomBytes(32), + osImageHash: ethers.randomBytes(32), + tcbStatus: "UpToDate", + advisoryIds: [] + }; + + const [isAllowed, reason] = await tcbApp.isAppAllowed(bootInfo); + expect(isAllowed).to.be.true; + expect(reason).to.equal(""); + }); + }); + describe("isAppAllowed", function () { const composeHash = ethers.randomBytes(32); const deviceId = ethers.randomBytes(32); @@ -91,6 +158,26 @@ describe("DstackApp", function () { expect(isAllowed).to.be.true; }); + it("Should reject outdated TCB when required", async function () { + await appAuth.setRequireTcbUpToDate(true); + + const bootInfo = { + appId: appId, + composeHash, + instanceId, + deviceId, + mrAggregated, + mrSystem, + osImageHash, + tcbStatus: "OutOfDate", + advisoryIds: [] + }; + + const [isAllowed, reason] = await appAuth.isAppAllowed(bootInfo); + expect(isAllowed).to.be.false; + expect(reason).to.equal("TCB status is not up to date"); + }); + it("Should reject unallowed compose hash", async function () { const bootInfo = { tcbStatus: "UpToDate", @@ -138,9 +225,10 @@ describe("DstackApp", function () { const contractFactory = await ethers.getContractFactory("DstackApp"); appAuthWithData = await hre.upgrades.deployProxy( contractFactory, - [owner.address, false, false, testDevice, testHash], - { - kind: 'uups' + [owner.address, false, false, false, testDevice, testHash], + { + kind: 'uups', + initializer: 'initialize(address,bool,bool,bool,bytes32,bytes32)' } ) as DstackApp; @@ -237,9 +325,10 @@ describe("DstackApp", function () { const contractFactory = await ethers.getContractFactory("DstackApp"); const appAuthEmpty = await hre.upgrades.deployProxy( contractFactory, - [owner.address, false, false, ethers.ZeroHash, ethers.ZeroHash], + [owner.address, false, false, false, ethers.ZeroHash, ethers.ZeroHash], { - kind: 'uups' + kind: 'uups', + initializer: 'initialize(address,bool,bool,bool,bytes32,bytes32)' } ) as DstackApp; diff --git a/kms/auth-eth/test/DstackApp.upgrade.test.ts b/kms/auth-eth/test/DstackApp.upgrade.test.ts new file mode 100644 index 000000000..97e2132c8 --- /dev/null +++ b/kms/auth-eth/test/DstackApp.upgrade.test.ts @@ -0,0 +1,304 @@ +// SPDX-FileCopyrightText: © 2025 Phala Network +// +// SPDX-License-Identifier: Apache-2.0 + +import { expect } from "chai"; +import { ethers } from "hardhat"; +import { DstackApp, DstackKms } from "../typechain-types"; +import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers"; +import hre from "hardhat"; + +describe("DstackApp upgrade", function () { + let owner: SignerWithAddress; + let other: SignerWithAddress; + + beforeEach(async function () { + [owner, other] = await ethers.getSigners(); + }); + + // Deploy a proxy using the old 5-param initialize to simulate a pre-upgrade deployment. + async function deployOldApp( + allowAnyDevice: boolean, + initialDeviceId: string, + initialComposeHash: string + ): Promise { + const factory = await ethers.getContractFactory("DstackApp"); + const proxy = await hre.upgrades.deployProxy( + factory, + [owner.address, false, allowAnyDevice, initialDeviceId, initialComposeHash], + { + kind: "uups", + initializer: "initialize(address,bool,bool,bytes32,bytes32)", + } + ) as DstackApp; + await proxy.waitForDeployment(); + return proxy; + } + + // Upgrade an existing proxy to the (same, current) DstackApp implementation. + // In a real scenario the new bytecode would differ; hardhat-upgrades still validates + // storage layout compatibility and swaps the implementation slot. + async function upgradeApp(proxy: DstackApp): Promise { + const factory = await ethers.getContractFactory("DstackApp"); + const upgraded = await hre.upgrades.upgradeProxy( + await proxy.getAddress(), + factory, + { kind: "uups" } + ) as DstackApp; + return upgraded; + } + + describe("Upgrade from old 5-param initialize", function () { + let app: DstackApp; + const composeHash = ethers.encodeBytes32String("upgrade-test-hash"); + const deviceId = ethers.encodeBytes32String("upgrade-test-dev"); + + beforeEach(async function () { + // Deploy with old initializer (no requireTcbUpToDate param) + app = await deployOldApp(false, deviceId, composeHash); + }); + + it("should preserve existing storage after upgrade", async function () { + // Verify pre-upgrade state + expect(await app.owner()).to.equal(owner.address); + expect(await app.allowAnyDevice()).to.be.false; + expect(await app.allowedDeviceIds(deviceId)).to.be.true; + expect(await app.allowedComposeHashes(composeHash)).to.be.true; + + // Upgrade + const upgraded = await upgradeApp(app); + + // Storage must be preserved + expect(await upgraded.owner()).to.equal(owner.address); + expect(await upgraded.allowAnyDevice()).to.be.false; + expect(await upgraded.allowedDeviceIds(deviceId)).to.be.true; + expect(await upgraded.allowedComposeHashes(composeHash)).to.be.true; + }); + + it("should expose version() = 2 after upgrade", async function () { + const upgraded = await upgradeApp(app); + expect(await upgraded.version()).to.equal(2); + }); + + it("should default requireTcbUpToDate to false after upgrade", async function () { + const upgraded = await upgradeApp(app); + // Old proxy never set this slot — it should be zero (false) + expect(await upgraded.requireTcbUpToDate()).to.be.false; + }); + + it("should allow setting requireTcbUpToDate after upgrade", async function () { + const upgraded = await upgradeApp(app); + + await expect(upgraded.setRequireTcbUpToDate(true)) + .to.emit(upgraded, "RequireTcbUpToDateSet") + .withArgs(true); + expect(await upgraded.requireTcbUpToDate()).to.be.true; + + await upgraded.setRequireTcbUpToDate(false); + expect(await upgraded.requireTcbUpToDate()).to.be.false; + }); + + it("should allow outdated TCB by default after upgrade (no silent behavior change)", async function () { + const upgraded = await upgradeApp(app); + + const bootInfo = { + appId: await upgraded.getAddress(), + composeHash, + instanceId: ethers.Wallet.createRandom().address, + deviceId, + mrAggregated: ethers.randomBytes(32), + mrSystem: ethers.randomBytes(32), + osImageHash: ethers.randomBytes(32), + tcbStatus: "OutOfDate", + advisoryIds: [], + }; + + const [isAllowed, reason] = await upgraded.isAppAllowed(bootInfo); + expect(isAllowed).to.be.true; + expect(reason).to.equal(""); + }); + + it("should enforce TCB check after owner opts in post-upgrade", async function () { + const upgraded = await upgradeApp(app); + await upgraded.setRequireTcbUpToDate(true); + + const bootInfoBad = { + appId: await upgraded.getAddress(), + composeHash, + instanceId: ethers.Wallet.createRandom().address, + deviceId, + mrAggregated: ethers.randomBytes(32), + mrSystem: ethers.randomBytes(32), + osImageHash: ethers.randomBytes(32), + tcbStatus: "OutOfDate", + advisoryIds: [], + }; + + const [rejected, rejectReason] = await upgraded.isAppAllowed(bootInfoBad); + expect(rejected).to.be.false; + expect(rejectReason).to.equal("TCB status is not up to date"); + + const bootInfoGood = { ...bootInfoBad, tcbStatus: "UpToDate" }; + const [allowed, allowReason] = await upgraded.isAppAllowed(bootInfoGood); + expect(allowed).to.be.true; + expect(allowReason).to.equal(""); + }); + + it("should reject non-owner calling setRequireTcbUpToDate after upgrade", async function () { + const upgraded = await upgradeApp(app); + await expect( + upgraded.connect(other).setRequireTcbUpToDate(true) + ).to.be.revertedWithCustomError(upgraded, "OwnableUnauthorizedAccount"); + }); + }); + + describe("KMS factory after upgrade", function () { + it("should deploy new apps with TCB flag via factory", async function () { + // Deploy DstackApp implementation + const appFactory = await ethers.getContractFactory("DstackApp"); + const appImpl = await appFactory.deploy(); + await appImpl.waitForDeployment(); + const appImplAddr = await appImpl.getAddress(); + + // Deploy KMS with app implementation + const kmsFactory = await ethers.getContractFactory("DstackKms"); + const kms = await hre.upgrades.deployProxy( + kmsFactory, + [owner.address, appImplAddr], + { kind: "uups" } + ) as DstackKms; + await kms.waitForDeployment(); + + // Add an OS image hash (required by KMS.isAppAllowed) + const osImageHash = ethers.encodeBytes32String("os-img"); + await kms.addOsImageHash(osImageHash); + + const composeHash = ethers.encodeBytes32String("factory-hash"); + + // Deploy app with requireTcbUpToDate = true via factory + const tx = await kms["deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"]( + owner.address, + false, // disableUpgrades + true, // requireTcbUpToDate + true, // allowAnyDevice + ethers.ZeroHash, + composeHash + ); + const receipt = await tx.wait(); + + // Extract app address from AppDeployedViaFactory event + let appAddr: string | undefined; + for (const log of receipt!.logs) { + try { + const parsed = kms.interface.parseLog({ + topics: log.topics as string[], + data: log.data, + }); + if (parsed?.name === "AppDeployedViaFactory") { + appAddr = parsed.args.appId; + } + } catch { + continue; + } + } + expect(appAddr).to.not.be.undefined; + + const factoryApp = await ethers.getContractAt("DstackApp", appAddr!) as DstackApp; + + expect(await factoryApp.version()).to.equal(2); + expect(await factoryApp.requireTcbUpToDate()).to.be.true; + expect(await factoryApp.allowAnyDevice()).to.be.true; + expect(await factoryApp.allowedComposeHashes(composeHash)).to.be.true; + + // Verify TCB enforcement + const bootInfo = { + appId: appAddr!, + composeHash, + instanceId: ethers.Wallet.createRandom().address, + deviceId: ethers.randomBytes(32), + mrAggregated: ethers.randomBytes(32), + mrSystem: ethers.randomBytes(32), + osImageHash, + tcbStatus: "OutOfDate", + advisoryIds: [], + }; + + // KMS-level isAppAllowed should delegate to DstackApp and reject + const [rejected, reason] = await kms.isAppAllowed(bootInfo); + expect(rejected).to.be.false; + expect(reason).to.equal("TCB status is not up to date"); + + // Same boot info with UpToDate should pass + const [allowed, allowReason] = await kms.isAppAllowed({ + ...bootInfo, + tcbStatus: "UpToDate", + }); + expect(allowed).to.be.true; + expect(allowReason).to.equal(""); + }); + + it("should deploy new apps without TCB flag via factory", async function () { + const appFactory = await ethers.getContractFactory("DstackApp"); + const appImpl = await appFactory.deploy(); + await appImpl.waitForDeployment(); + + const kmsFactory = await ethers.getContractFactory("DstackKms"); + const kms = await hre.upgrades.deployProxy( + kmsFactory, + [owner.address, await appImpl.getAddress()], + { kind: "uups" } + ) as DstackKms; + await kms.waitForDeployment(); + + const osImageHash = ethers.encodeBytes32String("os-img-2"); + await kms.addOsImageHash(osImageHash); + + const composeHash = ethers.encodeBytes32String("no-tcb-hash"); + + const tx = await kms["deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)"]( + owner.address, + false, // disableUpgrades + false, // requireTcbUpToDate = false + true, // allowAnyDevice + ethers.ZeroHash, + composeHash + ); + const receipt = await tx.wait(); + + let appAddr: string | undefined; + for (const log of receipt!.logs) { + try { + const parsed = kms.interface.parseLog({ + topics: log.topics as string[], + data: log.data, + }); + if (parsed?.name === "AppDeployedViaFactory") { + appAddr = parsed.args.appId; + } + } catch { + continue; + } + } + + const factoryApp = await ethers.getContractAt("DstackApp", appAddr!) as DstackApp; + expect(await factoryApp.requireTcbUpToDate()).to.be.false; + + // OutOfDate TCB should be allowed when flag is off + const bootInfo = { + appId: appAddr!, + composeHash, + instanceId: ethers.Wallet.createRandom().address, + deviceId: ethers.randomBytes(32), + mrAggregated: ethers.randomBytes(32), + mrSystem: ethers.randomBytes(32), + osImageHash, + tcbStatus: "OutOfDate", + advisoryIds: [], + }; + + const [allowed, reason] = await kms.isAppAllowed(bootInfo); + expect(allowed).to.be.true; + expect(reason).to.equal(""); + }); + }); +}); diff --git a/kms/auth-eth/test/setup.ts b/kms/auth-eth/test/setup.ts index 9e5547b2a..577ff2529 100644 --- a/kms/auth-eth/test/setup.ts +++ b/kms/auth-eth/test/setup.ts @@ -31,12 +31,13 @@ beforeAll(async () => { ], true) as DstackKms; const appAuth = await deployContract(hre, "DstackApp", [ - owner.address, + owner.address, false, // _disableUpgrades + false, // _requireTcbUpToDate true, // _allowAnyDevice ethers.ZeroHash, // initialDeviceId (empty) ethers.ZeroHash // initialComposeHash (empty) - ], true) as DstackApp; + ], true, "initialize(address,bool,bool,bool,bytes32,bytes32)") as DstackApp; const appId = await appAuth.getAddress(); await kmsContract.registerApp(appId); diff --git a/kms/auth-eth/typechain-types/contracts/DstackApp.ts b/kms/auth-eth/typechain-types/contracts/DstackApp.ts index 643df03a8..ea689b9ba 100644 --- a/kms/auth-eth/typechain-types/contracts/DstackApp.ts +++ b/kms/auth-eth/typechain-types/contracts/DstackApp.ts @@ -69,17 +69,21 @@ export interface DstackAppInterface extends Interface { | "allowedComposeHashes" | "allowedDeviceIds" | "disableUpgrades" - | "initialize" + | "initialize(address,bool,bool,bytes32,bytes32)" + | "initialize(address,bool,bool,bool,bytes32,bytes32)" | "isAppAllowed" | "owner" | "proxiableUUID" | "removeComposeHash" | "removeDevice" | "renounceOwnership" + | "requireTcbUpToDate" | "setAllowAnyDevice" + | "setRequireTcbUpToDate" | "supportsInterface" | "transferOwnership" | "upgradeToAndCall" + | "version" ): FunctionFragment; getEvent( @@ -91,6 +95,7 @@ export interface DstackAppInterface extends Interface { | "DeviceRemoved" | "Initialized" | "OwnershipTransferred" + | "RequireTcbUpToDateSet" | "Upgraded" | "UpgradesDisabled" ): EventFragment; @@ -124,9 +129,13 @@ export interface DstackAppInterface extends Interface { values?: undefined ): string; encodeFunctionData( - functionFragment: "initialize", + functionFragment: "initialize(address,bool,bool,bytes32,bytes32)", values: [AddressLike, boolean, boolean, BytesLike, BytesLike] ): string; + encodeFunctionData( + functionFragment: "initialize(address,bool,bool,bool,bytes32,bytes32)", + values: [AddressLike, boolean, boolean, boolean, BytesLike, BytesLike] + ): string; encodeFunctionData( functionFragment: "isAppAllowed", values: [IAppAuth.AppBootInfoStruct] @@ -148,10 +157,18 @@ export interface DstackAppInterface extends Interface { functionFragment: "renounceOwnership", values?: undefined ): string; + encodeFunctionData( + functionFragment: "requireTcbUpToDate", + values?: undefined + ): string; encodeFunctionData( functionFragment: "setAllowAnyDevice", values: [boolean] ): string; + encodeFunctionData( + functionFragment: "setRequireTcbUpToDate", + values: [boolean] + ): string; encodeFunctionData( functionFragment: "supportsInterface", values: [BytesLike] @@ -164,6 +181,7 @@ export interface DstackAppInterface extends Interface { functionFragment: "upgradeToAndCall", values: [AddressLike, BytesLike] ): string; + encodeFunctionData(functionFragment: "version", values?: undefined): string; decodeFunctionResult( functionFragment: "UPGRADE_INTERFACE_VERSION", @@ -190,7 +208,14 @@ export interface DstackAppInterface extends Interface { functionFragment: "disableUpgrades", data: BytesLike ): Result; - decodeFunctionResult(functionFragment: "initialize", data: BytesLike): Result; + decodeFunctionResult( + functionFragment: "initialize(address,bool,bool,bytes32,bytes32)", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "initialize(address,bool,bool,bool,bytes32,bytes32)", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "isAppAllowed", data: BytesLike @@ -212,10 +237,18 @@ export interface DstackAppInterface extends Interface { functionFragment: "renounceOwnership", data: BytesLike ): Result; + decodeFunctionResult( + functionFragment: "requireTcbUpToDate", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "setAllowAnyDevice", data: BytesLike ): Result; + decodeFunctionResult( + functionFragment: "setRequireTcbUpToDate", + data: BytesLike + ): Result; decodeFunctionResult( functionFragment: "supportsInterface", data: BytesLike @@ -228,6 +261,7 @@ export interface DstackAppInterface extends Interface { functionFragment: "upgradeToAndCall", data: BytesLike ): Result; + decodeFunctionResult(functionFragment: "version", data: BytesLike): Result; } export namespace AllowAnyDeviceSetEvent { @@ -315,6 +349,18 @@ export namespace OwnershipTransferredEvent { export type LogDescription = TypedLogDescription; } +export namespace RequireTcbUpToDateSetEvent { + export type InputTuple = [requireUpToDate: boolean]; + export type OutputTuple = [requireUpToDate: boolean]; + export interface OutputObject { + requireUpToDate: boolean; + } + export type Event = TypedContractEvent; + export type Filter = TypedDeferredTopicFilter; + export type Log = TypedEventLog; + export type LogDescription = TypedLogDescription; +} + export namespace UpgradedEvent { export type InputTuple = [implementation: AddressLike]; export type OutputTuple = [implementation: string]; @@ -402,7 +448,7 @@ export interface DstackApp extends BaseContract { disableUpgrades: TypedContractMethod<[], [void], "nonpayable">; - initialize: TypedContractMethod< + "initialize(address,bool,bool,bytes32,bytes32)": TypedContractMethod< [ initialOwner: AddressLike, _disableUpgrades: boolean, @@ -414,6 +460,19 @@ export interface DstackApp extends BaseContract { "nonpayable" >; + "initialize(address,bool,bool,bool,bytes32,bytes32)": TypedContractMethod< + [ + initialOwner: AddressLike, + _disableUpgrades: boolean, + _requireTcbUpToDate: boolean, + _allowAnyDevice: boolean, + initialDeviceId: BytesLike, + initialComposeHash: BytesLike + ], + [void], + "nonpayable" + >; + isAppAllowed: TypedContractMethod< [bootInfo: IAppAuth.AppBootInfoStruct], [[boolean, string] & { isAllowed: boolean; reason: string }], @@ -438,12 +497,20 @@ export interface DstackApp extends BaseContract { renounceOwnership: TypedContractMethod<[], [void], "nonpayable">; + requireTcbUpToDate: TypedContractMethod<[], [boolean], "view">; + setAllowAnyDevice: TypedContractMethod< [_allowAnyDevice: boolean], [void], "nonpayable" >; + setRequireTcbUpToDate: TypedContractMethod< + [_requireUpToDate: boolean], + [void], + "nonpayable" + >; + supportsInterface: TypedContractMethod< [interfaceId: BytesLike], [boolean], @@ -462,6 +529,8 @@ export interface DstackApp extends BaseContract { "payable" >; + version: TypedContractMethod<[], [bigint], "view">; + getFunction( key: string | FunctionFragment ): T; @@ -488,7 +557,7 @@ export interface DstackApp extends BaseContract { nameOrSignature: "disableUpgrades" ): TypedContractMethod<[], [void], "nonpayable">; getFunction( - nameOrSignature: "initialize" + nameOrSignature: "initialize(address,bool,bool,bytes32,bytes32)" ): TypedContractMethod< [ initialOwner: AddressLike, @@ -500,6 +569,20 @@ export interface DstackApp extends BaseContract { [void], "nonpayable" >; + getFunction( + nameOrSignature: "initialize(address,bool,bool,bool,bytes32,bytes32)" + ): TypedContractMethod< + [ + initialOwner: AddressLike, + _disableUpgrades: boolean, + _requireTcbUpToDate: boolean, + _allowAnyDevice: boolean, + initialDeviceId: BytesLike, + initialComposeHash: BytesLike + ], + [void], + "nonpayable" + >; getFunction( nameOrSignature: "isAppAllowed" ): TypedContractMethod< @@ -522,9 +605,15 @@ export interface DstackApp extends BaseContract { getFunction( nameOrSignature: "renounceOwnership" ): TypedContractMethod<[], [void], "nonpayable">; + getFunction( + nameOrSignature: "requireTcbUpToDate" + ): TypedContractMethod<[], [boolean], "view">; getFunction( nameOrSignature: "setAllowAnyDevice" ): TypedContractMethod<[_allowAnyDevice: boolean], [void], "nonpayable">; + getFunction( + nameOrSignature: "setRequireTcbUpToDate" + ): TypedContractMethod<[_requireUpToDate: boolean], [void], "nonpayable">; getFunction( nameOrSignature: "supportsInterface" ): TypedContractMethod<[interfaceId: BytesLike], [boolean], "view">; @@ -538,6 +627,9 @@ export interface DstackApp extends BaseContract { [void], "payable" >; + getFunction( + nameOrSignature: "version" + ): TypedContractMethod<[], [bigint], "view">; getEvent( key: "AllowAnyDeviceSet" @@ -588,6 +680,13 @@ export interface DstackApp extends BaseContract { OwnershipTransferredEvent.OutputTuple, OwnershipTransferredEvent.OutputObject >; + getEvent( + key: "RequireTcbUpToDateSet" + ): TypedContractEvent< + RequireTcbUpToDateSetEvent.InputTuple, + RequireTcbUpToDateSetEvent.OutputTuple, + RequireTcbUpToDateSetEvent.OutputObject + >; getEvent( key: "Upgraded" ): TypedContractEvent< @@ -681,6 +780,17 @@ export interface DstackApp extends BaseContract { OwnershipTransferredEvent.OutputObject >; + "RequireTcbUpToDateSet(bool)": TypedContractEvent< + RequireTcbUpToDateSetEvent.InputTuple, + RequireTcbUpToDateSetEvent.OutputTuple, + RequireTcbUpToDateSetEvent.OutputObject + >; + RequireTcbUpToDateSet: TypedContractEvent< + RequireTcbUpToDateSetEvent.InputTuple, + RequireTcbUpToDateSetEvent.OutputTuple, + RequireTcbUpToDateSetEvent.OutputObject + >; + "Upgraded(address)": TypedContractEvent< UpgradedEvent.InputTuple, UpgradedEvent.OutputTuple, diff --git a/kms/auth-eth/typechain-types/contracts/DstackKms.ts b/kms/auth-eth/typechain-types/contracts/DstackKms.ts index 71a78fffa..2b3458886 100644 --- a/kms/auth-eth/typechain-types/contracts/DstackKms.ts +++ b/kms/auth-eth/typechain-types/contracts/DstackKms.ts @@ -84,7 +84,8 @@ export interface DstackKmsInterface extends Interface { | "addOsImageHash" | "allowedOsImages" | "appImplementation" - | "deployAndRegisterApp" + | "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" + | "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" | "gatewayAppId" | "initialize" | "isAppAllowed" @@ -153,9 +154,13 @@ export interface DstackKmsInterface extends Interface { values?: undefined ): string; encodeFunctionData( - functionFragment: "deployAndRegisterApp", + functionFragment: "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)", values: [AddressLike, boolean, boolean, BytesLike, BytesLike] ): string; + encodeFunctionData( + functionFragment: "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)", + values: [AddressLike, boolean, boolean, boolean, BytesLike, BytesLike] + ): string; encodeFunctionData( functionFragment: "gatewayAppId", values?: undefined @@ -268,7 +273,11 @@ export interface DstackKmsInterface extends Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "deployAndRegisterApp", + functionFragment: "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)", + data: BytesLike + ): Result; + decodeFunctionResult( + functionFragment: "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -590,10 +599,23 @@ export interface DstackKms extends BaseContract { appImplementation: TypedContractMethod<[], [string], "view">; - deployAndRegisterApp: TypedContractMethod< + "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)": TypedContractMethod< + [ + initialOwner: AddressLike, + disableUpgrades: boolean, + allowAnyDevice: boolean, + initialDeviceId: BytesLike, + initialComposeHash: BytesLike + ], + [string], + "nonpayable" + >; + + "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)": TypedContractMethod< [ initialOwner: AddressLike, disableUpgrades: boolean, + requireTcbUpToDate: boolean, allowAnyDevice: boolean, initialDeviceId: BytesLike, initialComposeHash: BytesLike @@ -738,11 +760,25 @@ export interface DstackKms extends BaseContract { nameOrSignature: "appImplementation" ): TypedContractMethod<[], [string], "view">; getFunction( - nameOrSignature: "deployAndRegisterApp" + nameOrSignature: "deployAndRegisterApp(address,bool,bool,bytes32,bytes32)" + ): TypedContractMethod< + [ + initialOwner: AddressLike, + disableUpgrades: boolean, + allowAnyDevice: boolean, + initialDeviceId: BytesLike, + initialComposeHash: BytesLike + ], + [string], + "nonpayable" + >; + getFunction( + nameOrSignature: "deployAndRegisterApp(address,bool,bool,bool,bytes32,bytes32)" ): TypedContractMethod< [ initialOwner: AddressLike, disableUpgrades: boolean, + requireTcbUpToDate: boolean, allowAnyDevice: boolean, initialDeviceId: BytesLike, initialComposeHash: BytesLike diff --git a/kms/auth-eth/typechain-types/factories/contracts/DstackApp__factory.ts b/kms/auth-eth/typechain-types/factories/contracts/DstackApp__factory.ts index e755222ab..e9c9d03f9 100644 --- a/kms/auth-eth/typechain-types/factories/contracts/DstackApp__factory.ts +++ b/kms/auth-eth/typechain-types/factories/contracts/DstackApp__factory.ts @@ -194,6 +194,19 @@ const _abi = [ name: "OwnershipTransferred", type: "event", }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bool", + name: "requireUpToDate", + type: "bool", + }, + ], + name: "RequireTcbUpToDateSet", + type: "event", + }, { anonymous: false, inputs: [ @@ -343,6 +356,44 @@ const _abi = [ stateMutability: "nonpayable", type: "function", }, + { + inputs: [ + { + internalType: "address", + name: "initialOwner", + type: "address", + }, + { + internalType: "bool", + name: "_disableUpgrades", + type: "bool", + }, + { + internalType: "bool", + name: "_requireTcbUpToDate", + type: "bool", + }, + { + internalType: "bool", + name: "_allowAnyDevice", + type: "bool", + }, + { + internalType: "bytes32", + name: "initialDeviceId", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "initialComposeHash", + type: "bytes32", + }, + ], + name: "initialize", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, { inputs: [ { @@ -473,6 +524,19 @@ const _abi = [ stateMutability: "nonpayable", type: "function", }, + { + inputs: [], + name: "requireTcbUpToDate", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [ { @@ -486,6 +550,19 @@ const _abi = [ stateMutability: "nonpayable", type: "function", }, + { + inputs: [ + { + internalType: "bool", + name: "_requireUpToDate", + type: "bool", + }, + ], + name: "setRequireTcbUpToDate", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, { inputs: [ { @@ -536,10 +613,23 @@ const _abi = [ stateMutability: "payable", type: "function", }, + { + inputs: [], + name: "version", + outputs: [ + { + internalType: "uint256", + name: "", + type: "uint256", + }, + ], + stateMutability: "pure", + type: "function", + }, ] as const; const _bytecode = - "0x60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516111d76100fd60003960008181610a1401528181610a3d0152610be001526111d76000f3fe6080604052600436106101095760003560e01c806367b3f22c11610095578063ad3cb1cc11610064578063ad3cb1cc146102f4578063bf8b211b14610332578063dfc7722314610362578063ec66903614610382578063f2fde38b1461039757600080fd5b806367b3f22c14610258578063715018a6146102785780637c4beeb81461028d5780638da5cb5b146102ad57600080fd5b80632a819728116100dc5780632a819728146101b35780632f6622e5146101d35780633440a16a146102035780634f1ef2861461022257806352d1902d1461023557600080fd5b806301ffc9a71461010e578063187515ca146101435780631d266200146101655780631e07919814610185575b600080fd5b34801561011a57600080fd5b5061012e610129366004610eb8565b6103b7565b60405190151581526020015b60405180910390f35b34801561014f57600080fd5b5061016361015e366004610f0e565b610409565b005b34801561017157600080fd5b50610163610180366004610f63565b610650565b34801561019157600080fd5b506101a56101a0366004610f7c565b6106ab565b60405161013a929190611008565b3480156101bf57600080fd5b506101636101ce366004610f63565b610784565b3480156101df57600080fd5b5061012e6101ee366004610f63565b60006020819052908152604090205460ff1681565b34801561020f57600080fd5b5060015461012e90610100900460ff1681565b610163610230366004611041565b6107d7565b34801561024157600080fd5b5061024a6107f6565b60405190815260200161013a565b34801561026457600080fd5b50610163610273366004610f63565b610813565b34801561028457600080fd5b50610163610860565b34801561029957600080fd5b506101636102a8366004611103565b610874565b3480156102b957600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546040516001600160a01b03909116815260200161013a565b34801561030057600080fd5b50610325604051806040016040528060058152602001640352e302e360dc1b81525081565b60405161013a919061111e565b34801561033e57600080fd5b5061012e61034d366004610f63565b60026020526000908152604090205460ff1681565b34801561036e57600080fd5b5061016361037d366004610f63565b6108c5565b34801561038e57600080fd5b50610163610918565b3480156103a357600080fd5b506101636103b2366004611131565b610957565b60006303c0f23360e31b6001600160e01b0319831614806103e85750638fd3752760e01b6001600160e01b03198316145b8061040357506301ffc9a760e01b6001600160e01b03198316145b92915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561044f5750825b905060008267ffffffffffffffff16600114801561046c5750303b155b90508115801561047a575080155b156104985760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156104c257845460ff60401b1916600160401b1785555b6001600160a01b038a166105155760405162461bcd60e51b8152602060048201526015602482015274696e76616c6964206f776e6572206164647265737360581b60448201526064015b60405180910390fd5b6001805461ffff19168a151561ff001916176101008a151502179055861561058b5760008781526002602052604090819020805460ff19166001179055517f67fc71ab96fe3fa3c6f78e9a00e635d591b7333ce611c0380bc577aac702243b906105829089815260200190565b60405180910390a15b85156105e55760008681526020819052604090819020805460ff19166001179055517ffecb34306dd9d8b785b54d65489d06afc8822a0893ddacedff40c50a4942d0af906105dc9088815260200190565b60405180910390a15b6105ee8a610995565b6105f66109a6565b6105fe6109a6565b831561064457845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b6106586109ae565b60008181526002602052604090819020805460ff19169055517fe0862975ac517b0478d308012afabc4bc37c23874a18144d7f2dfb852ff95c2c906106a09083815260200190565b60405180910390a150565b602080820135600090815290819052604081205460609060ff1661070757505060408051808201909152601881527f436f6d706f73652068617368206e6f7420616c6c6f77656400000000000000006020820152600092909150565b600154610100900460ff161580156107335750606083013560009081526002602052604090205460ff16155b1561076b57505060408051808201909152601281527111195d9a58d9481b9bdd08185b1b1bddd95960721b6020820152600092909150565b5050604080516020810190915260008152600192909150565b61078c6109ae565b60008181526002602052604090819020805460ff19166001179055517f67fc71ab96fe3fa3c6f78e9a00e635d591b7333ce611c0380bc577aac702243b906106a09083815260200190565b6107df610a09565b6107e882610aae565b6107f28282610b13565b5050565b6000610800610bd5565b5060008051602061118283398151915290565b61081b6109ae565b60008181526020818152604091829020805460ff1916905590518281527f755b79bd4b0eeab344d032284a99003b2ddc018b646752ac72d681593a6e894791016106a0565b6108686109ae565b6108726000610c1e565b565b61087c6109ae565b600180548215156101000261ff00199091161790556040517fbb2cdb6c7b362202d40373f87bc4788301cca658f91711ac1662e1ad2cba4a20906106a090831515815260200190565b6108cd6109ae565b60008181526020819052604090819020805460ff19166001179055517ffecb34306dd9d8b785b54d65489d06afc8822a0893ddacedff40c50a4942d0af906106a09083815260200190565b6109206109ae565b6001805460ff1916811790556040517f0e5daa943fcd7e7182d0e893d180695c2ea9f6f1b4a1c5432faf14cf17b774e890600090a1565b61095f6109ae565b6001600160a01b03811661098957604051631e4fbdf760e01b81526000600482015260240161050c565b61099281610c1e565b50565b61099d610c8f565b61099281610cd8565b610872610c8f565b336109e07f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146108725760405163118cdaa760e01b815233600482015260240161050c565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480610a9057507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610a84600080516020611182833981519152546001600160a01b031690565b6001600160a01b031614155b156108725760405163703e46dd60e11b815260040160405180910390fd5b610ab66109ae565b60015460ff16156109925760405162461bcd60e51b815260206004820152602160248201527f557067726164657320617265207065726d616e656e746c792064697361626c656044820152601960fa1b606482015260840161050c565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610b6d575060408051601f3d908101601f19168201909252610b6a9181019061114c565b60015b610b9557604051634c9c8ce360e01b81526001600160a01b038316600482015260240161050c565b6000805160206111828339815191528114610bc657604051632a87526960e21b81526004810182905260240161050c565b610bd08383610ce0565b505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146108725760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661087257604051631afcd79f60e31b815260040160405180910390fd5b61095f610c8f565b610ce982610d36565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610d2e57610bd08282610d9b565b6107f2610e11565b806001600160a01b03163b600003610d6c57604051634c9c8ce360e01b81526001600160a01b038216600482015260240161050c565b60008051602061118283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051610db89190611165565b600060405180830381855af49150503d8060008114610df3576040519150601f19603f3d011682016040523d82523d6000602084013e610df8565b606091505b5091509150610e08858383610e30565b95945050505050565b34156108725760405163b398979f60e01b815260040160405180910390fd5b606082610e4557610e4082610e8f565b610e88565b8151158015610e5c57506001600160a01b0384163b155b15610e8557604051639996b31560e01b81526001600160a01b038516600482015260240161050c565b50805b9392505050565b805115610e9f5780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b600060208284031215610eca57600080fd5b81356001600160e01b031981168114610e8857600080fd5b80356001600160a01b0381168114610ef957600080fd5b919050565b80358015158114610ef957600080fd5b600080600080600060a08688031215610f2657600080fd5b610f2f86610ee2565b9450610f3d60208701610efe565b9350610f4b60408701610efe565b94979396509394606081013594506080013592915050565b600060208284031215610f7557600080fd5b5035919050565b600060208284031215610f8e57600080fd5b813567ffffffffffffffff811115610fa557600080fd5b82016101208185031215610e8857600080fd5b60005b83811015610fd3578181015183820152602001610fbb565b50506000910152565b60008151808452610ff4816020860160208601610fb8565b601f01601f19169290920160200192915050565b82151581526040602082015260006110236040830184610fdc565b949350505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561105457600080fd5b61105d83610ee2565b9150602083013567ffffffffffffffff8082111561107a57600080fd5b818501915085601f83011261108e57600080fd5b8135818111156110a0576110a061102b565b604051601f8201601f19908116603f011681019083821181831017156110c8576110c861102b565b816040528281528860208487010111156110e157600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b60006020828403121561111557600080fd5b610e8882610efe565b602081526000610e886020830184610fdc565b60006020828403121561114357600080fd5b610e8882610ee2565b60006020828403121561115e57600080fd5b5051919050565b60008251611177818460208701610fb8565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca2646970667358221220666b559e07439df16b5185c7222fbe5fd868fdfe715620d5958a419bad3f7f7264736f6c63430008160033"; + "0x60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516115726100fd60003960008181610cd201528181610cfb0152610e9e01526115726000f3fe6080604052600436106101355760003560e01c806367b3f22c116100ab5780639ed281931161006f5780639ed281931461036e578063ad3cb1cc1461038e578063bf8b211b146103cc578063dfc77223146103fc578063ec6690361461041c578063f2fde38b1461043157600080fd5b806367b3f22c146102b25780636e4c7422146102d2578063715018a6146102f25780637c4beeb8146103075780638da5cb5b1461032757600080fd5b80632a819728116100fd5780632a819728146101f95780632f6622e5146102195780633440a16a146102495780634f1ef2861461026857806352d1902d1461027b57806354fd4d501461029e57600080fd5b806301ffc9a71461013a5780630aa58c831461016f578063187515ca146101895780631d266200146101ab5780631e079198146101cb575b600080fd5b34801561014657600080fd5b5061015a61015536600461118f565b610451565b60405190151581526020015b60405180910390f35b34801561017b57600080fd5b5060035461015a9060ff1681565b34801561019557600080fd5b506101a96101a43660046111e5565b6104a3565b005b3480156101b757600080fd5b506101a96101c636600461123a565b6105bb565b3480156101d757600080fd5b506101eb6101e6366004611253565b610616565b6040516101669291906112df565b34801561020557600080fd5b506101a961021436600461123a565b6107a8565b34801561022557600080fd5b5061015a61023436600461123a565b60006020819052908152604090205460ff1681565b34801561025557600080fd5b5060015461015a90610100900460ff1681565b6101a9610276366004611318565b6107fb565b34801561028757600080fd5b5061029061081a565b604051908152602001610166565b3480156102aa57600080fd5b506002610290565b3480156102be57600080fd5b506101a96102cd36600461123a565b610837565b3480156102de57600080fd5b506101a96102ed3660046113da565b610884565b3480156102fe57600080fd5b506101a96108cd565b34801561031357600080fd5b506101a96103223660046113da565b6108e1565b34801561033357600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546040516001600160a01b039091168152602001610166565b34801561037a57600080fd5b506101a96103893660046113f5565b610932565b34801561039a57600080fd5b506103bf604051806040016040528060058152602001640352e302e360dc1b81525081565b604051610166919061145b565b3480156103d857600080fd5b5061015a6103e736600461123a565b60026020526000908152604090205460ff1681565b34801561040857600080fd5b506101a961041736600461123a565b610a59565b34801561042857600080fd5b506101a9610aac565b34801561043d57600080fd5b506101a961044c36600461146e565b610aeb565b60006303c0f23360e31b6001600160e01b0319831614806104825750638fd3752760e01b6001600160e01b03198316145b8061049d57506301ffc9a760e01b6001600160e01b03198316145b92915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156104e95750825b905060008267ffffffffffffffff1660011480156105065750303b155b905081158015610514575080155b156105325760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561055c57845460ff60401b1916600160401b1785555b6105698a8a8a8a8a610b2e565b83156105af57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050505050565b6105c3610c6c565b60008181526002602052604090819020805460ff19169055517fe0862975ac517b0478d308012afabc4bc37c23874a18144d7f2dfb852ff95c2c9061060b9083815260200190565b60405180910390a150565b60035460009060609060ff16801561068f5750604051675570546f4461746560c01b602082015260280160408051601f19818403018152919052805160209091012061066560e0850185611489565b6040516020016106769291906114d7565b6040516020818303038152906040528051906020012014155b156106d257505060408051808201909152601c81527f54434220737461747573206973206e6f7420757020746f2064617465000000006020820152600092909150565b602080840135600090815290819052604090205460ff1661072b57505060408051808201909152601881527f436f6d706f73652068617368206e6f7420616c6c6f77656400000000000000006020820152600092909150565b600154610100900460ff161580156107575750606083013560009081526002602052604090205460ff16155b1561078f57505060408051808201909152601281527111195d9a58d9481b9bdd08185b1b1bddd95960721b6020820152600092909150565b5050604080516020810190915260008152600192909150565b6107b0610c6c565b60008181526002602052604090819020805460ff19166001179055517f67fc71ab96fe3fa3c6f78e9a00e635d591b7333ce611c0380bc577aac702243b9061060b9083815260200190565b610803610cc7565b61080c82610d6c565b6108168282610dd1565b5050565b6000610824610e93565b5060008051602061151d83398151915290565b61083f610c6c565b60008181526020818152604091829020805460ff1916905590518281527f755b79bd4b0eeab344d032284a99003b2ddc018b646752ac72d681593a6e8947910161060b565b61088c610c6c565b6003805460ff19168215159081179091556040519081527fafae60561b2481a349b45b3a47357f70eef6ae67e5b6e1749d74de7f19a25aa19060200161060b565b6108d5610c6c565b6108df6000610edc565b565b6108e9610c6c565b600180548215156101000261ff00199091161790556040517fbb2cdb6c7b362202d40373f87bc4788301cca658f91711ac1662e1ad2cba4a209061060b90831515815260200190565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff166000811580156109785750825b905060008267ffffffffffffffff1660011480156109955750303b155b9050811580156109a3575080155b156109c15760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff1916600117855583156109eb57845460ff60401b1916600160401b1785555b6003805460ff19168a1515179055610a068b8b8a8a8a610b2e565b8315610a4c57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b610a61610c6c565b60008181526020819052604090819020805460ff19166001179055517ffecb34306dd9d8b785b54d65489d06afc8822a0893ddacedff40c50a4942d0af9061060b9083815260200190565b610ab4610c6c565b6001805460ff1916811790556040517f0e5daa943fcd7e7182d0e893d180695c2ea9f6f1b4a1c5432faf14cf17b774e890600090a1565b610af3610c6c565b6001600160a01b038116610b2257604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610b2b81610edc565b50565b6001600160a01b038516610b7c5760405162461bcd60e51b8152602060048201526015602482015274696e76616c6964206f776e6572206164647265737360581b6044820152606401610b19565b6001805461ffff191685151561ff00191617610100851515021790558115610bf25760008281526002602052604090819020805460ff19166001179055517f67fc71ab96fe3fa3c6f78e9a00e635d591b7333ce611c0380bc577aac702243b90610be99084815260200190565b60405180910390a15b8015610c4c5760008181526020819052604090819020805460ff19166001179055517ffecb34306dd9d8b785b54d65489d06afc8822a0893ddacedff40c50a4942d0af90610c439083815260200190565b60405180910390a15b610c5585610f4d565b610c5d610f5e565b610c65610f5e565b5050505050565b33610c9e7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b0316146108df5760405163118cdaa760e01b8152336004820152602401610b19565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480610d4e57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610d4260008051602061151d833981519152546001600160a01b031690565b6001600160a01b031614155b156108df5760405163703e46dd60e11b815260040160405180910390fd5b610d74610c6c565b60015460ff1615610b2b5760405162461bcd60e51b815260206004820152602160248201527f557067726164657320617265207065726d616e656e746c792064697361626c656044820152601960fa1b6064820152608401610b19565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015610e2b575060408051601f3d908101601f19168201909252610e28918101906114e7565b60015b610e5357604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610b19565b60008051602061151d8339815191528114610e8457604051632a87526960e21b815260048101829052602401610b19565b610e8e8383610f66565b505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146108df5760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b610f55610fbc565b610b2b81611005565b6108df610fbc565b610f6f8261100d565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115610fb457610e8e8282611072565b6108166110e8565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166108df57604051631afcd79f60e31b815260040160405180910390fd5b610af3610fbc565b806001600160a01b03163b60000361104357604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610b19565b60008051602061151d83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161108f9190611500565b600060405180830381855af49150503d80600081146110ca576040519150601f19603f3d011682016040523d82523d6000602084013e6110cf565b606091505b50915091506110df858383611107565b95945050505050565b34156108df5760405163b398979f60e01b815260040160405180910390fd5b60608261111c5761111782611166565b61115f565b815115801561113357506001600160a01b0384163b155b1561115c57604051639996b31560e01b81526001600160a01b0385166004820152602401610b19565b50805b9392505050565b8051156111765780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b6000602082840312156111a157600080fd5b81356001600160e01b03198116811461115f57600080fd5b80356001600160a01b03811681146111d057600080fd5b919050565b803580151581146111d057600080fd5b600080600080600060a086880312156111fd57600080fd5b611206866111b9565b9450611214602087016111d5565b9350611222604087016111d5565b94979396509394606081013594506080013592915050565b60006020828403121561124c57600080fd5b5035919050565b60006020828403121561126557600080fd5b813567ffffffffffffffff81111561127c57600080fd5b8201610120818503121561115f57600080fd5b60005b838110156112aa578181015183820152602001611292565b50506000910152565b600081518084526112cb81602086016020860161128f565b601f01601f19169290920160200192915050565b82151581526040602082015260006112fa60408301846112b3565b949350505050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561132b57600080fd5b611334836111b9565b9150602083013567ffffffffffffffff8082111561135157600080fd5b818501915085601f83011261136557600080fd5b81358181111561137757611377611302565b604051601f8201601f19908116603f0116810190838211818310171561139f5761139f611302565b816040528281528860208487010111156113b857600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000602082840312156113ec57600080fd5b61115f826111d5565b60008060008060008060c0878903121561140e57600080fd5b611417876111b9565b9550611425602088016111d5565b9450611433604088016111d5565b9350611441606088016111d5565b92506080870135915060a087013590509295509295509295565b60208152600061115f60208301846112b3565b60006020828403121561148057600080fd5b61115f826111b9565b6000808335601e198436030181126114a057600080fd5b83018035915067ffffffffffffffff8211156114bb57600080fd5b6020019150368190038213156114d057600080fd5b9250929050565b8183823760009101908152919050565b6000602082840312156114f957600080fd5b5051919050565b6000825161151281846020870161128f565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca26469706673582212205464f37d97333559a06ab180eb5e18bf039bf87860789f152c7b06256e2cce2564736f6c63430008160033"; type DstackAppConstructorParams = | [signer?: Signer] diff --git a/kms/auth-eth/typechain-types/factories/contracts/DstackKms__factory.ts b/kms/auth-eth/typechain-types/factories/contracts/DstackKms__factory.ts index ca0648947..ea36e2b0b 100644 --- a/kms/auth-eth/typechain-types/factories/contracts/DstackKms__factory.ts +++ b/kms/auth-eth/typechain-types/factories/contracts/DstackKms__factory.ts @@ -414,6 +414,50 @@ const _abi = [ stateMutability: "nonpayable", type: "function", }, + { + inputs: [ + { + internalType: "address", + name: "initialOwner", + type: "address", + }, + { + internalType: "bool", + name: "disableUpgrades", + type: "bool", + }, + { + internalType: "bool", + name: "requireTcbUpToDate", + type: "bool", + }, + { + internalType: "bool", + name: "allowAnyDevice", + type: "bool", + }, + { + internalType: "bytes32", + name: "initialDeviceId", + type: "bytes32", + }, + { + internalType: "bytes32", + name: "initialComposeHash", + type: "bytes32", + }, + ], + name: "deployAndRegisterApp", + outputs: [ + { + internalType: "address", + name: "appId", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, { inputs: [], name: "gatewayAppId", @@ -897,7 +941,7 @@ const _abi = [ ] as const; const _bytecode = - "0x60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516128ff620000fe6000396000818161161701528181611641015261179601526128ff6000f3fe608060405260043610620001f35760003560e01c806352d1902d116200010b57806395f5193111620000a1578063ad3cb1cc116200006c578063ad3cb1cc146200062c578063e067ec9d146200065f578063f2fde38b1462000684578063f6fe4f4014620006a957600080fd5b806395f5193114620005785780639a4e1d18146200059f5780639e6f311414620005d3578063a6c4cce914620005f857600080fd5b80637d02535211620000e25780637d02535214620004ca5780638618169d14620004ef5780638da5cb5b14620005145780639425bac6146200055357600080fd5b806352d1902d1462000466578063715018a6146200048d578063736ede7a14620004a557600080fd5b806325a992da116200018d5780633e32d34611620001585780633e32d34614620003e0578063485cc95514620004055780634d5922a1146200042a5780634f1ef286146200044f57600080fd5b806325a992da14620003365780632adee48d14620003715780633971db2714620003965780633ceaaa1114620003bb57600080fd5b806313eb977011620001ce57806313eb9770146200028357806317a1d80f14620002b757806318c1ecb214620002dc5780631e079198146200030157600080fd5b806301ffc9a714620001f857806306a3ae961462000232578063091770631462000259575b600080fd5b3480156200020557600080fd5b506200021d6200021736600462001a99565b620006dd565b60405190151581526020015b60405180910390f35b3480156200023f57600080fd5b50620002576200025136600462001ac5565b62000715565b005b3480156200026657600080fd5b506200027162000776565b60405162000229949392919062001b33565b3480156200029057600080fd5b506200021d620002a236600462001ac5565b60076020526000908152604090205460ff1681565b348015620002c457600080fd5b5062000257620002d636600462001bb0565b620009d2565b348015620002e957600080fd5b5062000257620002fb36600462001cd2565b62000a74565b3480156200030e57600080fd5b50620003266200032036600462001d12565b62000a90565b6040516200022992919062001d50565b3480156200034357600080fd5b5060095462000358906001600160a01b031681565b6040516001600160a01b03909116815260200162000229565b3480156200037e57600080fd5b50620002576200039036600462001ac5565b62000c25565b348015620003a357600080fd5b5062000257620003b536600462001d6d565b62000c78565b348015620003c857600080fd5b5062000257620003da36600462001bb0565b62000cc2565b348015620003ed57600080fd5b5062000257620003ff36600462001ac5565b62000d73565b3480156200041257600080fd5b50620002576200042436600462001dba565b62000dc9565b3480156200043757600080fd5b50620002576200044936600462001ac5565b62000f56565b620002576200046036600462001df2565b62000fac565b3480156200047357600080fd5b506200047e62000fcd565b60405190815260200162000229565b3480156200049a57600080fd5b506200025762000fed565b348015620004b257600080fd5b5062000257620004c436600462001cd2565b62001005565b348015620004d757600080fd5b5062000257620004e936600462001e45565b6200101d565b348015620004fc57600080fd5b50620003586200050e36600462001f3d565b620010b7565b3480156200052157600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031662000358565b3480156200056057600080fd5b50620002576200057236600462001ac5565b62001250565b3480156200058557600080fd5b5062000590620012a3565b60405162000229919062001f9d565b348015620005ac57600080fd5b506200021d620005be36600462001ac5565b60086020526000908152604090205460ff1681565b348015620005e057600080fd5b5062000257620005f236600462001ac5565b62001339565b3480156200060557600080fd5b506200021d6200061736600462001bb0565b60056020526000908152604090205460ff1681565b3480156200063957600080fd5b5062000590604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156200066c57600080fd5b50620003266200067e36600462001d12565b6200138c565b3480156200069157600080fd5b5062000257620006a336600462001bb0565b6200154b565b348015620006b657600080fd5b506200021d620006c836600462001ac5565b60066020526000908152604090205460ff1681565b60006303c0f23360e31b6001600160e01b0319831614806200070f57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6200071f6200158f565b60008181526008602052604090819020805460ff19166001179055517f4911843506849c85a5ca6e6e2c01eed2d3ab86baba619517a2aad9d5ab2aeff2906200076b9083815260200190565b60405180910390a150565b600080548190620007879062001fb2565b80601f0160208091040260200160405190810160405280929190818152602001828054620007b59062001fb2565b8015620008065780601f10620007da5761010080835404028352916020019162000806565b820191906000526020600020905b815481529060010190602001808311620007e857829003601f168201915b5050505050908060010180546200081d9062001fb2565b80601f01602080910402602001604051908101604052809291908181526020018280546200084b9062001fb2565b80156200089c5780601f1062000870576101008083540402835291602001916200089c565b820191906000526020600020905b8154815290600101906020018083116200087e57829003601f168201915b505050505090806002018054620008b39062001fb2565b80601f0160208091040260200160405190810160405280929190818152602001828054620008e19062001fb2565b8015620009325780601f10620009065761010080835404028352916020019162000932565b820191906000526020600020905b8154815290600101906020018083116200091457829003601f168201915b505050505090806003018054620009499062001fb2565b80601f0160208091040260200160405190810160405280929190818152602001828054620009779062001fb2565b8015620009c85780601f106200099c57610100808354040283529160200191620009c8565b820191906000526020600020905b815481529060010190602001808311620009aa57829003601f168201915b5050505050905084565b6001600160a01b03811662000a1f5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185c1c08125160921b60448201526064015b60405180910390fd5b6001600160a01b038116600081815260056020908152604091829020805460ff1916600117905590519182527f0d540ad8f39e07d19909687352b9fa017405d93c91a6760981fbae9cf28bfef791016200076b565b62000a7e6200158f565b600262000a8c828262002042565b5050565b6000606060058262000aa6602086018662001bb0565b6001600160a01b0316815260208101919091526040016000205460ff1662000afb575050604080518082019091526012815271105c1c081b9bdd081c9959da5cdd195c995960721b6020820152600092909150565b60c083013560009081526008602052604090205460ff1662000b4f57505060408051808201909152601781527613d4c81a5b5859d9481a5cc81b9bdd08185b1b1bddd959604a1b6020820152600092909150565b62000b6e62000b62602085018562001bb0565b3b63ffffffff16151590565b62000b98576000604051806060016040528060238152602001620028a76023913991509150915091565b62000ba7602084018462001bb0565b6001600160a01b0316631e079198846040518263ffffffff1660e01b815260040162000bd4919062002238565b600060405180830381865afa15801562000bf2573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262000c1c919081019062002305565b91509150915091565b62000c2f6200158f565b60008181526006602052604090819020805460ff19169055517f54cd662e41eec7ddf0f32f034b2533e481b471dd3ea978222d609ec8fffb1bb0906200076b9083815260200190565b62000c826200158f565b600462000c90828262002042565b507f5b2b64f770ea5266055ebd3ebf205ef06cbfa738e62684edf0e28356e34acf06816040516200076b919062001f9d565b62000ccc6200158f565b6001600160a01b03811662000d245760405162461bcd60e51b815260206004820152601e60248201527f496e76616c696420696d706c656d656e746174696f6e20616464726573730000604482015260640162000a16565b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527f08bb433f12b5fd81d2d5e0deeb3b4d28371781ddbd80e9d053e7468d2b1aa82d906020016200076b565b62000d7d6200158f565b60008181526006602052604090819020805460ff19166001179055517f68615a0b92795750b3d180ff73429e1291d225e449eee954a567b91104fd9837906200076b9083815260200190565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b031660008115801562000e0f5750825b90506000826001600160401b0316600114801562000e2c5750303b155b90508115801562000e3b575080155b1562000e5a5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831562000e8557845460ff60401b1916600160401b1785555b62000e9087620015ed565b62000e9a62001602565b62000ea462001602565b6001600160a01b0386161562000f0657600980546001600160a01b0319166001600160a01b0388169081179091556040519081527f08bb433f12b5fd81d2d5e0deeb3b4d28371781ddbd80e9d053e7468d2b1aa82d9060200160405180910390a15b831562000f4d57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b62000f606200158f565b60008181526007602052604090819020805460ff19166001179055517ff2b290637b1193e12eb38ab32b986303639b1687cc2cd1e25f993e6eae2f4041906200076b9083815260200190565b62000fb66200160c565b62000fc182620016b5565b62000a8c8282620016bf565b600062000fd96200178b565b506000805160206200288783398151915290565b62000ff76200158f565b620010036000620017d5565b565b6200100f6200158f565b600362000a8c828262002042565b620010276200158f565b8051819060009081906200103c908262002042565b506020820151600182019062001053908262002042565b50604082015160028201906200106a908262002042565b506060820151600382019062001081908262002042565b505081516040517f77cdad119a452bbd96c45635758fc4af8a6bde3deaccf3fada634ddf9a16270692506200076b919062001f9d565b6009546000906001600160a01b0316620011145760405162461bcd60e51b815260206004820181905260248201527f44737461636b41707020696d706c656d656e746174696f6e206e6f7420736574604482015260640162000a16565b6001600160a01b038616620011645760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206f776e6572206164647265737360581b604482015260640162000a16565b604080516001600160a01b038881166024830152871515604483015286151560648301526084820186905260a48083018690528351808403909101815260c490920183526020820180516001600160e01b0316630c3a8ae560e11b1790526009549251919216908290620011d89062001a8b565b620011e59291906200239c565b604051809103906000f08015801562001202573d6000803e3d6000fd5b5091506200121082620009d2565b60405133906001600160a01b038416907ffd86d7f6962eba3b7a3bf9129c06c0b2f885e1c61ef2c9f0dbb856be0deefdee90600090a35095945050505050565b6200125a6200158f565b60008181526008602052604090819020805460ff19169055517f99b3cee95daf3138d0c982299cd0264f5b7a61aa629b42b92f3ec8966aa7f6fe906200076b9083815260200190565b60048054620012b29062001fb2565b80601f0160208091040260200160405190810160405280929190818152602001828054620012e09062001fb2565b8015620013315780601f10620013055761010080835404028352916020019162001331565b820191906000526020600020905b8154815290600101906020018083116200131357829003601f168201915b505050505081565b620013436200158f565b60008181526007602052604090819020805460ff19169055517f1a9888a45e3df8b7e6bb3090747d598d2a0d78e61388161a90799f54df8f4434906200076b9083815260200190565b60006060604051602001620013af90675570546f4461746560c01b815260080190565b60408051601f198184030181529190528051602090910120620013d660e0850185620023c2565b604051602001620013e99291906200240b565b60405160208183030381529060405280519060200120146200144357505060408051808201909152601c81527f54434220737461747573206973206e6f7420757020746f2064617465000000006020820152600092909150565b60c083013560009081526008602052604090205460ff166200149757505060408051808201909152601781527613d4c81a5b5859d9481a5cc81b9bdd08185b1b1bddd959604a1b6020820152600092909150565b608083013560009081526006602052604090205460ff16620014f157505060408051808201909152601981527f41676772656761746564204d52206e6f7420616c6c6f776564000000000000006020820152600092909150565b606083013560009081526007602052604090205460ff16620015325760006040518060600160405280602981526020016200285e6029913991509150915091565b5050604080516020810190915260008152600192909150565b620015556200158f565b6001600160a01b0381166200158157604051631e4fbdf760e01b81526000600482015260240162000a16565b6200158c81620017d5565b50565b33620015c27f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614620010035760405163118cdaa760e01b815233600482015260240162000a16565b620015f762001846565b6200158c8162001890565b6200100362001846565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614806200169657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166200168a60008051602062002887833981519152546001600160a01b031690565b6001600160a01b031614155b15620010035760405163703e46dd60e11b815260040160405180910390fd5b6200158c6200158f565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156200171c575060408051601f3d908101601f1916820190925262001719918101906200241b565b60015b6200174657604051634c9c8ce360e01b81526001600160a01b038316600482015260240162000a16565b6000805160206200288783398151915281146200177a57604051632a87526960e21b81526004810182905260240162000a16565b6200178683836200189a565b505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614620010035760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166200100357604051631afcd79f60e31b815260040160405180910390fd5b6200155562001846565b620018a582620018f7565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115620018ed576200178682826200195f565b62000a8c620019db565b806001600160a01b03163b6000036200192f57604051634c9c8ce360e01b81526001600160a01b038216600482015260240162000a16565b6000805160206200288783398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b0316846040516200197e919062002435565b600060405180830381855af49150503d8060008114620019bb576040519150601f19603f3d011682016040523d82523d6000602084013e620019c0565b606091505b5091509150620019d2858383620019fb565b95945050505050565b3415620010035760405163b398979f60e01b815260040160405180910390fd5b60608262001a145762001a0e8262001a61565b62001a5a565b815115801562001a2c57506001600160a01b0384163b155b1562001a5757604051639996b31560e01b81526001600160a01b038516600482015260240162000a16565b50805b9392505050565b80511562001a725780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b61040a806200245483390190565b60006020828403121562001aac57600080fd5b81356001600160e01b03198116811462001a5a57600080fd5b60006020828403121562001ad857600080fd5b5035919050565b60005b8381101562001afc57818101518382015260200162001ae2565b50506000910152565b6000815180845262001b1f81602086016020860162001adf565b601f01601f19169290920160200192915050565b60808152600062001b48608083018762001b05565b828103602084015262001b5c818762001b05565b9050828103604084015262001b72818662001b05565b9050828103606084015262001b88818562001b05565b979650505050505050565b80356001600160a01b038116811462001bab57600080fd5b919050565b60006020828403121562001bc357600080fd5b62001a5a8262001b93565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171562001c095762001c0962001bce565b60405290565b604051601f8201601f191681016001600160401b038111828210171562001c3a5762001c3a62001bce565b604052919050565b60006001600160401b0382111562001c5e5762001c5e62001bce565b50601f01601f191660200190565b600062001c8362001c7d8462001c42565b62001c0f565b905082815283838301111562001c9857600080fd5b828260208301376000602084830101529392505050565b600082601f83011262001cc157600080fd5b62001a5a8383356020850162001c6c565b60006020828403121562001ce557600080fd5b81356001600160401b0381111562001cfc57600080fd5b62001d0a8482850162001caf565b949350505050565b60006020828403121562001d2557600080fd5b81356001600160401b0381111562001d3c57600080fd5b8201610120818503121562001a5a57600080fd5b821515815260406020820152600062001d0a604083018462001b05565b60006020828403121562001d8057600080fd5b81356001600160401b0381111562001d9757600080fd5b8201601f8101841362001da957600080fd5b62001d0a8482356020840162001c6c565b6000806040838503121562001dce57600080fd5b62001dd98362001b93565b915062001de96020840162001b93565b90509250929050565b6000806040838503121562001e0657600080fd5b62001e118362001b93565b915060208301356001600160401b0381111562001e2d57600080fd5b62001e3b8582860162001caf565b9150509250929050565b60006020828403121562001e5857600080fd5b81356001600160401b038082111562001e7057600080fd5b908301906080828603121562001e8557600080fd5b62001e8f62001be4565b82358281111562001e9f57600080fd5b62001ead8782860162001caf565b82525060208301358281111562001ec357600080fd5b62001ed18782860162001caf565b60208301525060408301358281111562001eea57600080fd5b62001ef88782860162001caf565b60408301525060608301358281111562001f1157600080fd5b62001f1f8782860162001caf565b60608301525095945050505050565b80151581146200158c57600080fd5b600080600080600060a0868803121562001f5657600080fd5b62001f618662001b93565b9450602086013562001f738162001f2e565b9350604086013562001f858162001f2e565b94979396509394606081013594506080013592915050565b60208152600062001a5a602083018462001b05565b600181811c9082168062001fc757607f821691505b60208210810362001fe857634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111562001786576000816000526020600020601f850160051c81016020861015620020195750805b601f850160051c820191505b818110156200203a5782815560010162002025565b505050505050565b81516001600160401b038111156200205e576200205e62001bce565b62002076816200206f845462001fb2565b8462001fee565b602080601f831160018114620020ae5760008415620020955750858301515b600019600386901b1c1916600185901b1785556200203a565b600085815260208120601f198616915b82811015620020df57888601518255948401946001909101908401620020be565b5085821015620020fe5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000808335601e198436030181126200212657600080fd5b83016020810192503590506001600160401b038111156200214657600080fd5b8036038213156200215657600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6000808335601e198436030181126200219e57600080fd5b83016020810192503590506001600160401b03811115620021be57600080fd5b8060051b36038213156200215657600080fd5b6000838385526020808601955060208560051b8301018460005b878110156200222b57848303601f190189526200220982886200210e565b620022168582846200215d565b9a86019a9450505090830190600101620021eb565b5090979650505050505050565b602081526200225c602082016200224f8462001b93565b6001600160a01b03169052565b602082013560408201526000620022766040840162001b93565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e0830152620022bd60e08401846200210e565b6101206101008181870152620022d9610140870184866200215d565b9350620022e98188018862002186565b878603601f1901848901529350905062001b88848483620021d1565b600080604083850312156200231957600080fd5b8251620023268162001f2e565b60208401519092506001600160401b038111156200234357600080fd5b8301601f810185136200235557600080fd5b80516200236662001c7d8262001c42565b8181528660208385010111156200237c57600080fd5b6200238f82602083016020860162001adf565b8093505050509250929050565b6001600160a01b038316815260406020820181905260009062001d0a9083018462001b05565b6000808335601e19843603018112620023da57600080fd5b8301803591506001600160401b03821115620023f557600080fd5b6020019150368190038213156200215657600080fd5b8183823760009101908152919050565b6000602082840312156200242e57600080fd5b5051919050565b600082516200244981846020870162001adf565b919091019291505056fe608060405260405161040a38038061040a83398101604081905261002291610268565b61002c8282610033565b5050610352565b61003c82610092565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561008657610081828261010e565b505050565b61008e610185565b5050565b806001600160a01b03163b6000036100cd57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161012b9190610336565b600060405180830381855af49150503d8060008114610166576040519150601f19603f3d011682016040523d82523d6000602084013e61016b565b606091505b50909250905061017c8583836101a6565b95945050505050565b34156101a45760405163b398979f60e01b815260040160405180910390fd5b565b6060826101bb576101b682610205565b6101fe565b81511580156101d257506001600160a01b0384163b155b156101fb57604051639996b31560e01b81526001600160a01b03851660048201526024016100c4565b50805b9392505050565b8051156102155780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025f578181015183820152602001610247565b50506000910152565b6000806040838503121561027b57600080fd5b82516001600160a01b038116811461029257600080fd5b60208401519092506001600160401b03808211156102af57600080fd5b818501915085601f8301126102c357600080fd5b8151818111156102d5576102d561022e565b604051601f8201601f19908116603f011681019083821181831017156102fd576102fd61022e565b8160405282815288602084870101111561031657600080fd5b610327836020830160208801610244565b80955050505050509250929050565b60008251610348818460208701610244565b9190910192915050565b60aa806103606000396000f3fe6080604052600a600c565b005b60186014601a565b6051565b565b6000604c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e808015606f573d6000f35b3d6000fdfea26469706673582212201d1e675cd71e57bb3f08113f3040612bee9b14a06a3515aeb6fc806b55a6323764736f6c634300081600334b4d53206973206e6f7420616c6c6f77656420746f20626f6f74206f6e207468697320646576696365360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc417070206e6f74206465706c6f796564206f7220696e76616c69642061646472657373a26469706673582212200dd82aa817b5e4dda681b69c3f612fec30caad1e59ba2a366019ceb84bb796d964736f6c63430008160033"; + "0x60a0604052306080523480156200001557600080fd5b506200002062000026565b620000da565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000775760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d75780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516129cb620001046000396000818161166e0152818161169801526117ed01526129cb6000f3fe608060405260043610620001ff5760003560e01c806352d1902d11620001175780639a4e1d1811620000a1578063ad3cb1cc116200006c578063ad3cb1cc146200065d578063e067ec9d1462000690578063f2fde38b14620006b5578063f6fe4f4014620006da57600080fd5b80639a4e1d1814620005ab5780639cb9c31f14620005df5780639e6f31141462000604578063a6c4cce9146200062957600080fd5b80638618169d11620000e25780638618169d14620004fb5780638da5cb5b14620005205780639425bac6146200055f57806395f51931146200058457600080fd5b806352d1902d1462000472578063715018a61462000499578063736ede7a14620004b15780637d02535214620004d657600080fd5b806325a992da11620001995780633e32d34611620001645780633e32d34614620003ec578063485cc95514620004115780634d5922a114620004365780634f1ef286146200045b57600080fd5b806325a992da14620003425780632adee48d146200037d5780633971db2714620003a25780633ceaaa1114620003c757600080fd5b806313eb977011620001da57806313eb9770146200028f57806317a1d80f14620002c357806318c1ecb214620002e85780631e079198146200030d57600080fd5b806301ffc9a7146200020457806306a3ae96146200023e578063091770631462000265575b600080fd5b3480156200021157600080fd5b50620002296200022336600462001af0565b6200070e565b60405190151581526020015b60405180910390f35b3480156200024b57600080fd5b50620002636200025d36600462001b1c565b62000746565b005b3480156200027257600080fd5b506200027d620007a7565b60405162000235949392919062001b8a565b3480156200029c57600080fd5b5062000229620002ae36600462001b1c565b60076020526000908152604090205460ff1681565b348015620002d057600080fd5b5062000263620002e236600462001c07565b62000a03565b348015620002f557600080fd5b50620002636200030736600462001d29565b62000aa5565b3480156200031a57600080fd5b50620003326200032c36600462001d69565b62000ac1565b6040516200023592919062001da7565b3480156200034f57600080fd5b5060095462000364906001600160a01b031681565b6040516001600160a01b03909116815260200162000235565b3480156200038a57600080fd5b50620002636200039c36600462001b1c565b62000c56565b348015620003af57600080fd5b5062000263620003c136600462001dc4565b62000ca9565b348015620003d457600080fd5b5062000263620003e636600462001c07565b62000cf3565b348015620003f957600080fd5b50620002636200040b36600462001b1c565b62000da4565b3480156200041e57600080fd5b50620002636200043036600462001e11565b62000dfa565b3480156200044357600080fd5b50620002636200045536600462001b1c565b62000f87565b620002636200046c36600462001e49565b62000fdd565b3480156200047f57600080fd5b506200048a62000ffe565b60405190815260200162000235565b348015620004a657600080fd5b50620002636200101e565b348015620004be57600080fd5b5062000263620004d036600462001d29565b62001036565b348015620004e357600080fd5b5062000263620004f536600462001e9c565b6200104e565b3480156200050857600080fd5b50620003646200051a36600462001f94565b620010e8565b3480156200052d57600080fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031662000364565b3480156200056c57600080fd5b50620002636200057e36600462001b1c565b62001105565b3480156200059157600080fd5b506200059c62001158565b60405162000235919062001ff4565b348015620005b857600080fd5b5062000229620005ca36600462001b1c565b60086020526000908152604090205460ff1681565b348015620005ec57600080fd5b5062000364620005fe36600462002009565b620011ee565b3480156200061157600080fd5b50620002636200062336600462001b1c565b62001390565b3480156200063657600080fd5b50620002296200064836600462001c07565b60056020526000908152604090205460ff1681565b3480156200066a57600080fd5b506200059c604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156200069d57600080fd5b5062000332620006af36600462001d69565b620013e3565b348015620006c257600080fd5b5062000263620006d436600462001c07565b620015a2565b348015620006e757600080fd5b5062000229620006f936600462001b1c565b60066020526000908152604090205460ff1681565b60006303c0f23360e31b6001600160e01b0319831614806200074057506301ffc9a760e01b6001600160e01b03198316145b92915050565b62000750620015e6565b60008181526008602052604090819020805460ff19166001179055517f4911843506849c85a5ca6e6e2c01eed2d3ab86baba619517a2aad9d5ab2aeff2906200079c9083815260200190565b60405180910390a150565b600080548190620007b8906200207e565b80601f0160208091040260200160405190810160405280929190818152602001828054620007e6906200207e565b8015620008375780601f106200080b5761010080835404028352916020019162000837565b820191906000526020600020905b8154815290600101906020018083116200081957829003601f168201915b5050505050908060010180546200084e906200207e565b80601f01602080910402602001604051908101604052809291908181526020018280546200087c906200207e565b8015620008cd5780601f10620008a157610100808354040283529160200191620008cd565b820191906000526020600020905b815481529060010190602001808311620008af57829003601f168201915b505050505090806002018054620008e4906200207e565b80601f016020809104026020016040519081016040528092919081815260200182805462000912906200207e565b8015620009635780601f10620009375761010080835404028352916020019162000963565b820191906000526020600020905b8154815290600101906020018083116200094557829003601f168201915b5050505050908060030180546200097a906200207e565b80601f0160208091040260200160405190810160405280929190818152602001828054620009a8906200207e565b8015620009f95780601f10620009cd57610100808354040283529160200191620009f9565b820191906000526020600020905b815481529060010190602001808311620009db57829003601f168201915b5050505050905084565b6001600160a01b03811662000a505760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185c1c08125160921b60448201526064015b60405180910390fd5b6001600160a01b038116600081815260056020908152604091829020805460ff1916600117905590519182527f0d540ad8f39e07d19909687352b9fa017405d93c91a6760981fbae9cf28bfef791016200079c565b62000aaf620015e6565b600262000abd82826200210e565b5050565b6000606060058262000ad7602086018662001c07565b6001600160a01b0316815260208101919091526040016000205460ff1662000b2c575050604080518082019091526012815271105c1c081b9bdd081c9959da5cdd195c995960721b6020820152600092909150565b60c083013560009081526008602052604090205460ff1662000b8057505060408051808201909152601781527613d4c81a5b5859d9481a5cc81b9bdd08185b1b1bddd959604a1b6020820152600092909150565b62000b9f62000b93602085018562001c07565b3b63ffffffff16151590565b62000bc9576000604051806060016040528060238152602001620029736023913991509150915091565b62000bd8602084018462001c07565b6001600160a01b0316631e079198846040518263ffffffff1660e01b815260040162000c05919062002304565b600060405180830381865afa15801562000c23573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262000c4d9190810190620023d1565b91509150915091565b62000c60620015e6565b60008181526006602052604090819020805460ff19169055517f54cd662e41eec7ddf0f32f034b2533e481b471dd3ea978222d609ec8fffb1bb0906200079c9083815260200190565b62000cb3620015e6565b600462000cc182826200210e565b507f5b2b64f770ea5266055ebd3ebf205ef06cbfa738e62684edf0e28356e34acf06816040516200079c919062001ff4565b62000cfd620015e6565b6001600160a01b03811662000d555760405162461bcd60e51b815260206004820152601e60248201527f496e76616c696420696d706c656d656e746174696f6e20616464726573730000604482015260640162000a47565b600980546001600160a01b0319166001600160a01b0383169081179091556040519081527f08bb433f12b5fd81d2d5e0deeb3b4d28371781ddbd80e9d053e7468d2b1aa82d906020016200079c565b62000dae620015e6565b60008181526006602052604090819020805460ff19166001179055517f68615a0b92795750b3d180ff73429e1291d225e449eee954a567b91104fd9837906200079c9083815260200190565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b031660008115801562000e405750825b90506000826001600160401b0316600114801562000e5d5750303b155b90508115801562000e6c575080155b1562000e8b5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831562000eb657845460ff60401b1916600160401b1785555b62000ec18762001644565b62000ecb62001659565b62000ed562001659565b6001600160a01b0386161562000f3757600980546001600160a01b0319166001600160a01b0388169081179091556040519081527f08bb433f12b5fd81d2d5e0deeb3b4d28371781ddbd80e9d053e7468d2b1aa82d9060200160405180910390a15b831562000f7e57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50505050505050565b62000f91620015e6565b60008181526007602052604090819020805460ff19166001179055517ff2b290637b1193e12eb38ab32b986303639b1687cc2cd1e25f993e6eae2f4041906200079c9083815260200190565b62000fe762001663565b62000ff2826200170c565b62000abd828262001716565b60006200100a620017e2565b506000805160206200295383398151915290565b62001028620015e6565b6200103460006200182c565b565b62001040620015e6565b600362000abd82826200210e565b62001058620015e6565b8051819060009081906200106d90826200210e565b50602082015160018201906200108490826200210e565b50604082015160028201906200109b90826200210e565b5060608201516003820190620010b290826200210e565b505081516040517f77cdad119a452bbd96c45635758fc4af8a6bde3deaccf3fada634ddf9a16270692506200079c919062001ff4565b6000620010fb86866000878787620011ee565b9695505050505050565b6200110f620015e6565b60008181526008602052604090819020805460ff19169055517f99b3cee95daf3138d0c982299cd0264f5b7a61aa629b42b92f3ec8966aa7f6fe906200079c9083815260200190565b6004805462001167906200207e565b80601f016020809104026020016040519081016040528092919081815260200182805462001195906200207e565b8015620011e65780601f10620011ba57610100808354040283529160200191620011e6565b820191906000526020600020905b815481529060010190602001808311620011c857829003601f168201915b505050505081565b6009546000906001600160a01b03166200124b5760405162461bcd60e51b815260206004820181905260248201527f44737461636b41707020696d706c656d656e746174696f6e206e6f7420736574604482015260640162000a47565b6001600160a01b0387166200129b5760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206f776e6572206164647265737360581b604482015260640162000a47565b604080516001600160a01b03898116602483015288151560448301528715156064830152861515608483015260a4820186905260c48083018690528351808403909101815260e490920183526020820180516001600160e01b0316639ed2819360e01b1790526009549251919216908290620013179062001ae2565b6200132492919062002468565b604051809103906000f08015801562001341573d6000803e3d6000fd5b5091506200134f8262000a03565b60405133906001600160a01b038416907ffd86d7f6962eba3b7a3bf9129c06c0b2f885e1c61ef2c9f0dbb856be0deefdee90600090a3509695505050505050565b6200139a620015e6565b60008181526007602052604090819020805460ff19169055517f1a9888a45e3df8b7e6bb3090747d598d2a0d78e61388161a90799f54df8f4434906200079c9083815260200190565b600060606040516020016200140690675570546f4461746560c01b815260080190565b60408051601f1981840301815291905280516020909101206200142d60e08501856200248e565b60405160200162001440929190620024d7565b60405160208183030381529060405280519060200120146200149a57505060408051808201909152601c81527f54434220737461747573206973206e6f7420757020746f2064617465000000006020820152600092909150565b60c083013560009081526008602052604090205460ff16620014ee57505060408051808201909152601781527613d4c81a5b5859d9481a5cc81b9bdd08185b1b1bddd959604a1b6020820152600092909150565b608083013560009081526006602052604090205460ff166200154857505060408051808201909152601981527f41676772656761746564204d52206e6f7420616c6c6f776564000000000000006020820152600092909150565b606083013560009081526007602052604090205460ff16620015895760006040518060600160405280602981526020016200292a6029913991509150915091565b5050604080516020810190915260008152600192909150565b620015ac620015e6565b6001600160a01b038116620015d857604051631e4fbdf760e01b81526000600482015260240162000a47565b620015e3816200182c565b50565b33620016197f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614620010345760405163118cdaa760e01b815233600482015260240162000a47565b6200164e6200189d565b620015e381620018e7565b620010346200189d565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480620016ed57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316620016e160008051602062002953833981519152546001600160a01b031690565b6001600160a01b031614155b15620010345760405163703e46dd60e11b815260040160405180910390fd5b620015e3620015e6565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562001773575060408051601f3d908101601f191682019092526200177091810190620024e7565b60015b6200179d57604051634c9c8ce360e01b81526001600160a01b038316600482015260240162000a47565b600080516020620029538339815191528114620017d157604051632a87526960e21b81526004810182905260240162000a47565b620017dd8383620018f1565b505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614620010345760405163703e46dd60e11b815260040160405180910390fd5b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff166200103457604051631afcd79f60e31b815260040160405180910390fd5b620015ac6200189d565b620018fc826200194e565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a28051156200194457620017dd8282620019b6565b62000abd62001a32565b806001600160a01b03163b6000036200198657604051634c9c8ce360e01b81526001600160a01b038216600482015260240162000a47565b6000805160206200295383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051620019d5919062002501565b600060405180830381855af49150503d806000811462001a12576040519150601f19603f3d011682016040523d82523d6000602084013e62001a17565b606091505b509150915062001a2985838362001a52565b95945050505050565b3415620010345760405163b398979f60e01b815260040160405180910390fd5b60608262001a6b5762001a658262001ab8565b62001ab1565b815115801562001a8357506001600160a01b0384163b155b1562001aae57604051639996b31560e01b81526001600160a01b038516600482015260240162000a47565b50805b9392505050565b80511562001ac95780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b61040a806200252083390190565b60006020828403121562001b0357600080fd5b81356001600160e01b03198116811462001ab157600080fd5b60006020828403121562001b2f57600080fd5b5035919050565b60005b8381101562001b5357818101518382015260200162001b39565b50506000910152565b6000815180845262001b7681602086016020860162001b36565b601f01601f19169290920160200192915050565b60808152600062001b9f608083018762001b5c565b828103602084015262001bb3818762001b5c565b9050828103604084015262001bc9818662001b5c565b9050828103606084015262001bdf818562001b5c565b979650505050505050565b80356001600160a01b038116811462001c0257600080fd5b919050565b60006020828403121562001c1a57600080fd5b62001ab18262001bea565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171562001c605762001c6062001c25565b60405290565b604051601f8201601f191681016001600160401b038111828210171562001c915762001c9162001c25565b604052919050565b60006001600160401b0382111562001cb55762001cb562001c25565b50601f01601f191660200190565b600062001cda62001cd48462001c99565b62001c66565b905082815283838301111562001cef57600080fd5b828260208301376000602084830101529392505050565b600082601f83011262001d1857600080fd5b62001ab18383356020850162001cc3565b60006020828403121562001d3c57600080fd5b81356001600160401b0381111562001d5357600080fd5b62001d618482850162001d06565b949350505050565b60006020828403121562001d7c57600080fd5b81356001600160401b0381111562001d9357600080fd5b8201610120818503121562001ab157600080fd5b821515815260406020820152600062001d61604083018462001b5c565b60006020828403121562001dd757600080fd5b81356001600160401b0381111562001dee57600080fd5b8201601f8101841362001e0057600080fd5b62001d618482356020840162001cc3565b6000806040838503121562001e2557600080fd5b62001e308362001bea565b915062001e406020840162001bea565b90509250929050565b6000806040838503121562001e5d57600080fd5b62001e688362001bea565b915060208301356001600160401b0381111562001e8457600080fd5b62001e928582860162001d06565b9150509250929050565b60006020828403121562001eaf57600080fd5b81356001600160401b038082111562001ec757600080fd5b908301906080828603121562001edc57600080fd5b62001ee662001c3b565b82358281111562001ef657600080fd5b62001f048782860162001d06565b82525060208301358281111562001f1a57600080fd5b62001f288782860162001d06565b60208301525060408301358281111562001f4157600080fd5b62001f4f8782860162001d06565b60408301525060608301358281111562001f6857600080fd5b62001f768782860162001d06565b60608301525095945050505050565b8015158114620015e357600080fd5b600080600080600060a0868803121562001fad57600080fd5b62001fb88662001bea565b9450602086013562001fca8162001f85565b9350604086013562001fdc8162001f85565b94979396509394606081013594506080013592915050565b60208152600062001ab1602083018462001b5c565b60008060008060008060c087890312156200202357600080fd5b6200202e8762001bea565b95506020870135620020408162001f85565b94506040870135620020528162001f85565b93506060870135620020648162001f85565b9598949750929560808101359460a0909101359350915050565b600181811c908216806200209357607f821691505b602082108103620020b457634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620017dd576000816000526020600020601f850160051c81016020861015620020e55750805b601f850160051c820191505b818110156200210657828155600101620020f1565b505050505050565b81516001600160401b038111156200212a576200212a62001c25565b62002142816200213b84546200207e565b84620020ba565b602080601f8311600181146200217a5760008415620021615750858301515b600019600386901b1c1916600185901b17855562002106565b600085815260208120601f198616915b82811015620021ab578886015182559484019460019091019084016200218a565b5085821015620021ca5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6000808335601e19843603018112620021f257600080fd5b83016020810192503590506001600160401b038111156200221257600080fd5b8036038213156200222257600080fd5b9250929050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b6000808335601e198436030181126200226a57600080fd5b83016020810192503590506001600160401b038111156200228a57600080fd5b8060051b36038213156200222257600080fd5b6000838385526020808601955060208560051b8301018460005b87811015620022f757848303601f19018952620022d58288620021da565b620022e285828462002229565b9a86019a9450505090830190600101620022b7565b5090979650505050505050565b6020815262002328602082016200231b8462001bea565b6001600160a01b03169052565b602082013560408201526000620023426040840162001bea565b6001600160a01b03811660608401525060608301356080830152608083013560a083015260a083013560c083015260c083013560e08301526200238960e0840184620021da565b6101206101008181870152620023a56101408701848662002229565b9350620023b58188018862002252565b878603601f1901848901529350905062001bdf8484836200229d565b60008060408385031215620023e557600080fd5b8251620023f28162001f85565b60208401519092506001600160401b038111156200240f57600080fd5b8301601f810185136200242157600080fd5b80516200243262001cd48262001c99565b8181528660208385010111156200244857600080fd5b6200245b82602083016020860162001b36565b8093505050509250929050565b6001600160a01b038316815260406020820181905260009062001d619083018462001b5c565b6000808335601e19843603018112620024a657600080fd5b8301803591506001600160401b03821115620024c157600080fd5b6020019150368190038213156200222257600080fd5b8183823760009101908152919050565b600060208284031215620024fa57600080fd5b5051919050565b600082516200251581846020870162001b36565b919091019291505056fe608060405260405161040a38038061040a83398101604081905261002291610268565b61002c8282610033565b5050610352565b61003c82610092565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a280511561008657610081828261010e565b505050565b61008e610185565b5050565b806001600160a01b03163b6000036100cd57604051634c9c8ce360e01b81526001600160a01b03821660048201526024015b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0392909216919091179055565b6060600080846001600160a01b03168460405161012b9190610336565b600060405180830381855af49150503d8060008114610166576040519150601f19603f3d011682016040523d82523d6000602084013e61016b565b606091505b50909250905061017c8583836101a6565b95945050505050565b34156101a45760405163b398979f60e01b815260040160405180910390fd5b565b6060826101bb576101b682610205565b6101fe565b81511580156101d257506001600160a01b0384163b155b156101fb57604051639996b31560e01b81526001600160a01b03851660048201526024016100c4565b50805b9392505050565b8051156102155780518082602001fd5b60405163d6bda27560e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b60005b8381101561025f578181015183820152602001610247565b50506000910152565b6000806040838503121561027b57600080fd5b82516001600160a01b038116811461029257600080fd5b60208401519092506001600160401b03808211156102af57600080fd5b818501915085601f8301126102c357600080fd5b8151818111156102d5576102d561022e565b604051601f8201601f19908116603f011681019083821181831017156102fd576102fd61022e565b8160405282815288602084870101111561031657600080fd5b610327836020830160208801610244565b80955050505050509250929050565b60008251610348818460208701610244565b9190910192915050565b60aa806103606000396000f3fe6080604052600a600c565b005b60186014601a565b6051565b565b6000604c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b905090565b3660008037600080366000845af43d6000803e808015606f573d6000f35b3d6000fdfea26469706673582212201d1e675cd71e57bb3f08113f3040612bee9b14a06a3515aeb6fc806b55a6323764736f6c634300081600334b4d53206973206e6f7420616c6c6f77656420746f20626f6f74206f6e207468697320646576696365360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc417070206e6f74206465706c6f796564206f7220696e76616c69642061646472657373a2646970667358221220f0a1e21028f9e7b1e139c6dad62f28396f41b8100e331e87d0584465d0d7c84664736f6c63430008160033"; type DstackKmsConstructorParams = | [signer?: Signer]