Skip to content

Commit

Permalink
add LCPClientOwnableUpgradeable contract
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele committed Sep 19, 2024
1 parent 4bdfa76 commit 8530ff0
Show file tree
Hide file tree
Showing 8 changed files with 740 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: forge build --sizes --skip test --use solc:${{ env.SOLC_VERSION }}

- name: Run tests
run: make SOLC_VERSION=${{ env.SOLC_VERSION }} test
run: make SOLC_VERSION=${{ env.SOLC_VERSION }} TEST_UPGRADEABLE=true test

- name: Lint
run: make lint
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SOLC_VERSION ?= 0.8.20
FORGE ?= forge
SOLC_VERSION=0.8.20
FORGE=forge
TEST_UPGRADEABLE=false

.PHONY: proto-sol
proto-sol:
Expand All @@ -9,9 +10,13 @@ else
./solpb.sh
endif

.PHONY: clean
clean:
@$(FORGE) clean

.PHONY: test
test:
@$(FORGE) test -vvvv --gas-report --ffi --use solc:$(SOLC_VERSION)
@TEST_UPGRADEABLE=$(TEST_UPGRADEABLE) $(FORGE) test -vvvv --gas-report --ffi --use solc:$(SOLC_VERSION)

.PHONY: coverage
coverage:
Expand Down
10 changes: 8 additions & 2 deletions contracts/LCPClientBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ abstract contract LCPClientBase is ILightClient, ILCPClientErrors {

// --------------------- Immutable fields ---------------------

/// @dev ibcHandler is the address of the IBC handler contract.
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address internal immutable ibcHandler;
// if developmentMode is true, the client allows the remote attestation of IAS in development.
/// @dev if developmentMode is true, the client allows the remote attestation of IAS in development.
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
bool internal immutable developmentMode;

// --------------------- Storage fields ---------------------
Expand All @@ -63,6 +66,9 @@ abstract contract LCPClientBase is ILightClient, ILCPClientErrors {

// --------------------- Constructor ---------------------

/// @custom:oz-upgrades-unsafe-allow constructor
/// @param ibcHandler_ the address of the IBC handler contract
/// @param developmentMode_ if true, the client allows the enclave debug mode
constructor(address ibcHandler_, bool developmentMode_) {
ibcHandler = ibcHandler_;
developmentMode = developmentMode_;
Expand All @@ -77,7 +83,7 @@ abstract contract LCPClientBase is ILightClient, ILCPClientErrors {

// --------------------- Public methods ---------------------

/// @dev isDevelopmentMode returns true if the client allows the remote attestation of IAS in development.
/// @dev isDevelopmentMode returns true if the client allows the enclave debug mode.
function isDevelopmentMode() public view returns (bool) {
return developmentMode;
}
Expand Down
20 changes: 20 additions & 0 deletions contracts/LCPClientOwnableUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.12;

import {LCPClientBase} from "./LCPClientBase.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

/// @custom:oz-upgrades-unsafe-allow external-library-linking
contract LCPClientOwnableUpgradeable is LCPClientBase, UUPSUpgradeable, OwnableUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address ibcHandler, bool developmentMode) LCPClientBase(ibcHandler, developmentMode) {}

function initialize(bytes memory rootCACert) public initializer {
initializeRootCACert(rootCACert);
__UUPSUpgradeable_init();
__Ownable_init(msg.sender);
}

function _authorizeUpgrade(address newImplementation) internal virtual override onlyOwner {}
}
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ out = 'out'
libs = ['lib', 'node_modules']
optimizer = true
optimizer_runs = 9_999_999
via-ir = false
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]
fs_permissions = [{ access = "read", path = "./"}]
Loading

0 comments on commit 8530ff0

Please sign in to comment.