Skip to content

Commit

Permalink
fix deployment issues caused by taiko-mon updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Keszey Dániel authored and Keszey Dániel committed Jul 15, 2024
1 parent c35c8e6 commit 8d6c287
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
4 changes: 2 additions & 2 deletions packages/protocol/contracts/L1/VerifierRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ contract VerifierRegistry is EssentialContract {

uint16 public verifierIdGenerator;

function init(address _addressManager) external initializer {
__Essential_init(_addressManager);
function init(address _owner, address _addressManager) external initializer {
__Essential_init(_owner, _addressManager);
verifierIdGenerator = 1;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/contracts/L1/verifiers/MockSgxVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import "../../automata-attestation/lib/QuoteV3Auth/V3Struct.sol";
import "./libs/LibPublicInput.sol";
import "./IVerifier.sol";

/// @title SgxVerifier
/// @title MockSgxVerifier
/// @notice This contract is the implementation of verifying SGX signature proofs
/// onchain.
/// @dev Please see references below:
/// - Reference #1: https://ethresear.ch/t/2fa-zk-rollups-using-sgx/14462
/// - Reference #2: https://github.com/gramineproject/gramine/discussions/1579
/// @custom:security-contact [email protected]
contract SgxVerifier is EssentialContract, IVerifier {
contract MockSgxVerifier is EssentialContract, IVerifier {
/// @dev Each public-private key pair (Ethereum address) is generated within
/// the SGX program when it boots up. The off-chain remote attestation
/// ensures the validity of the program hash and has the capability of
Expand Down
42 changes: 18 additions & 24 deletions packages/protocol/scripts/DeployL1Locally.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "@openzeppelin/contracts/utils/Strings.sol";
import "../contracts/L1/TaikoL1.sol";
import "../contracts/L1/BasedOperator.sol";
import "../contracts/L1/VerifierRegistry.sol";
import "../contracts/L1/TaikoToken.sol";
import "../contracts/tko/TaikoToken.sol";
import "../contracts/L1/provers/GuardianProver.sol";
// import "../contracts/L1/tiers/DevnetTierProvider.sol";
// import "../contracts/L1/tiers/TierProviderV2.sol";
Expand All @@ -21,7 +21,7 @@ import "../contracts/L1/provers/GuardianProver.sol";
// import "../contracts/automata-attestation/AutomataDcapV3Attestation.sol";
// import "../contracts/automata-attestation/utils/SigVerifyLib.sol";
// import "../contracts/automata-attestation/lib/PEMCertChainLib.sol";
import "../contracts/L1/verifiers/SgxVerifier.sol";
//import "../contracts/L1/verifiers/SgxVerifier.sol";
import "../contracts/L1/verifiers/MockSgxVerifier.sol"; // Avoid proof verification for now!
// import "../contracts/team/proving/ProverSet.sol";
// import "../test/common/erc20/FreeMintERC20.sol";
Expand Down Expand Up @@ -141,7 +141,7 @@ contract DeployL1OnAnvil is DeployCapability {
sharedAddressManager = deployProxy({
name: "shared_address_manager",
impl: address(new AddressManager()),
data: abi.encodeCall(AddressManager.init, ())
data: abi.encodeCall(AddressManager.init, (owner))
});
}

Expand All @@ -151,9 +151,8 @@ contract DeployL1OnAnvil is DeployCapability {
taikoToken = deployProxy({
name: "taiko_token",
impl: address(new TaikoToken()),
data: abi.encodeCall(TaikoToken.init, ("TAIKO", "TAIKO", MAINNET_CONTRACT_OWNER)),
registerTo: sharedAddressManager,
owner: MAINNET_CONTRACT_OWNER
data: abi.encodeCall(TaikoToken.init, (MAINNET_CONTRACT_OWNER, MAINNET_CONTRACT_OWNER)),
registerTo: sharedAddressManager
});
}

Expand Down Expand Up @@ -243,7 +242,7 @@ contract DeployL1OnAnvil is DeployCapability {
rollupAddressManager = deployProxy({
name: "rollup_address_manager",
impl: address(new AddressManager()),
data: abi.encodeCall(AddressManager.init, ())
data: abi.encodeCall(AddressManager.init, (owner))
});

// ---------------------------------------------------------------
Expand All @@ -259,53 +258,48 @@ contract DeployL1OnAnvil is DeployCapability {
data: abi.encodeCall(
TaikoL1.init,
(
owner,
rollupAddressManager,
vm.envBytes32("L2_GENESIS_HASH")
)
),
registerTo: rollupAddressManager,
owner: MAINNET_CONTRACT_OWNER
registerTo: rollupAddressManager
});

/* Deploy BasedOperator */
deployProxy({
name: "operator",
impl: address(new BasedOperator()),
data: abi.encodeCall(BasedOperator.init, (address(rollupAddressManager))),
registerTo: rollupAddressManager,
owner: MAINNET_CONTRACT_OWNER
data: abi.encodeCall(BasedOperator.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)),
registerTo: rollupAddressManager
});

/* Deploy MockSGXVerifier 3 times for now, so that we can call verifyProof without modifications of the protocol code. Later obv. shall be replaced with real verifiers. */
address verifier1 = deployProxy({
name: "tier_sgx1",
impl: address(new MockSgxVerifier()),
data: abi.encodeCall(MockSgxVerifier.init, (rollupAddressManager)),
registerTo: rollupAddressManager,
owner: MAINNET_CONTRACT_OWNER
data: abi.encodeCall(MockSgxVerifier.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)),
registerTo: rollupAddressManager
});
address verifier2 = deployProxy({
name: "tier_sgx2",
impl: address(new MockSgxVerifier()),
data: abi.encodeCall(MockSgxVerifier.init, (rollupAddressManager)),
registerTo: rollupAddressManager,
owner: MAINNET_CONTRACT_OWNER
data: abi.encodeCall(MockSgxVerifier.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)),
registerTo: rollupAddressManager
});
address verifier3 = deployProxy({
name: "tier_sgx3",
impl: address(new MockSgxVerifier()),
data: abi.encodeCall(MockSgxVerifier.init, (rollupAddressManager)),
registerTo: rollupAddressManager,
owner: MAINNET_CONTRACT_OWNER
data: abi.encodeCall(MockSgxVerifier.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)),
registerTo: rollupAddressManager
});

/* Deploy VerifierRegistry */
address vieriferRegistry = deployProxy({
name: "verifier_registry",
impl: address(new VerifierRegistry()),
data: abi.encodeCall(VerifierRegistry.init, (rollupAddressManager)),
registerTo: rollupAddressManager,
owner: MAINNET_CONTRACT_OWNER
data: abi.encodeCall(VerifierRegistry.init, (MAINNET_CONTRACT_OWNER, rollupAddressManager)),
registerTo: rollupAddressManager
});

// Add those 3 to verifier registry
Expand Down
22 changes: 11 additions & 11 deletions packages/protocol/test/L1/TaikoL1TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ abstract contract TaikoL1TestBase is TaikoTest {
uint256 internal logCount;
// PseZkVerifier public pv;
/* 3 proof verifiers - to fulfill the requirement in BasedOperator.sol */
SgxVerifier public sv1;
SgxVerifier public sv2;
SgxVerifier public sv3;
MockSgxVerifier public sv1;
MockSgxVerifier public sv2;
MockSgxVerifier public sv3;
VerifierRegistry public vr;
// SgxAndZkVerifier public sgxZkVerifier;
// GuardianVerifier public gv;
Expand Down Expand Up @@ -69,7 +69,7 @@ abstract contract TaikoL1TestBase is TaikoTest {
deployProxy({
name: "verifier_registry",
impl: address(new VerifierRegistry()),
data: abi.encodeCall(VerifierRegistry.init, (address(addressManager)))
data: abi.encodeCall(VerifierRegistry.init, (Alice, address(addressManager)))
})
);

Expand All @@ -94,36 +94,36 @@ abstract contract TaikoL1TestBase is TaikoTest {
// })
// );

address sgxImpl = address(new SgxVerifier());
address sgxImpl = address(new MockSgxVerifier());
//Naming is like: 3, 1, 2, is because we need to have incremental order of addresses in
// BasedOperator, so figured out this is actually the way

sv1 = SgxVerifier(
sv1 = MockSgxVerifier(
deployProxy({
name: "sgx2", //Name does not matter now, since we check validity via
// verifierRegistry
impl: sgxImpl,
data: abi.encodeCall(SgxVerifier.init, (Alice, address(addressManager)))
data: abi.encodeCall(MockSgxVerifier.init, (Alice, address(addressManager)))
})
);

console2.log(address(sv1));

sv2 = SgxVerifier(
sv2 = MockSgxVerifier(
deployProxy({
name: "sgx3", //Name does not matter now, since we check validity via
// verifierRegistry
impl: sgxImpl,
data: abi.encodeCall(SgxVerifier.init, (Alice, address(addressManager)))
data: abi.encodeCall(MockSgxVerifier.init, (Alice, address(addressManager)))
})
);

sv3 = SgxVerifier(
sv3 = MockSgxVerifier(
deployProxy({
name: "sgx1", //Name does not matter now, since we check validity via
// verifierRegistry
impl: sgxImpl,
data: abi.encodeCall(SgxVerifier.init, (Alice, address(addressManager)))
data: abi.encodeCall(MockSgxVerifier.init, (Alice, address(addressManager)))
})
);

Expand Down

0 comments on commit 8d6c287

Please sign in to comment.