From 3b712857b5d5ede2a3683d949d1974c8cceeb69a Mon Sep 17 00:00:00 2001 From: Daniel Wang <99078276+dantaik@users.noreply.github.com> Date: Fri, 20 Jan 2023 10:45:04 +0800 Subject: [PATCH] feat(protocol): add special logics for alpha-2 testnet (#12987) --- packages/protocol/contracts/L1/TkoToken.sol | 6 ++-- .../contracts/L1/libs/LibProposing.sol | 11 ++++++ .../protocol/contracts/L1/libs/LibProving.sol | 34 ++++++++++++------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/packages/protocol/contracts/L1/TkoToken.sol b/packages/protocol/contracts/L1/TkoToken.sol index 966ff684d7c..d7fb272a5d3 100644 --- a/packages/protocol/contracts/L1/TkoToken.sol +++ b/packages/protocol/contracts/L1/TkoToken.sol @@ -43,9 +43,9 @@ contract TkoToken is EssentialContract, ERC20Upgradeable, IMintableERC20 { function init(address _addressManager) external initializer { EssentialContract._init(_addressManager); ERC20Upgradeable.__ERC20_init({ - name_: "Taiko Test Token", - symbol_: "tTKO", - decimals_: 18 + name_: "Taiko USD Stablecoin Token", + symbol_: "tkUSD", + decimals_: 6 }); } diff --git a/packages/protocol/contracts/L1/libs/LibProposing.sol b/packages/protocol/contracts/L1/libs/LibProposing.sol index 124d0969310..35cdd86baf1 100644 --- a/packages/protocol/contracts/L1/libs/LibProposing.sol +++ b/packages/protocol/contracts/L1/libs/LibProposing.sol @@ -57,6 +57,17 @@ library LibProposing { AddressResolver resolver, bytes[] calldata inputs ) public { + // For alpha-2 testnet, the network only allows an special address + // to propose but anyone to prove. This is the first step of testing + // the tokenomics. + + // TODO(daniel): remove this special address. + address specialProposer = resolver.resolve("special_proposer", true); + require( + specialProposer == address(0) || specialProposer == msg.sender, + "L1:specialProposer" + ); + assert(!LibUtils.isHalted(state)); require(inputs.length == 2, "L1:inputs:size"); diff --git a/packages/protocol/contracts/L1/libs/LibProving.sol b/packages/protocol/contracts/L1/libs/LibProving.sol index 34cc5962779..3001cf23e3c 100644 --- a/packages/protocol/contracts/L1/libs/LibProving.sol +++ b/packages/protocol/contracts/L1/libs/LibProving.sol @@ -246,19 +246,29 @@ library LibProving { bytes32 blockHash = evidence.header.hashBlockHeader(); + // For alpha-2 testnet, the network allows any address to submit ZKP, + // but a special prover can skip ZKP verification if the ZKP is empty. + + // TODO(daniel): remove this special address. + address specialProver = resolver.resolve("special_prover", true); + for (uint256 i = 0; i < config.zkProofsPerBlock; ++i) { - require( - proofVerifier.verifyZKP({ - verificationKey: ConfigManager( - resolver.resolve("config_manager", false) - ).getValue(string(abi.encodePacked("zk_vkey_", i))), - zkproof: evidence.proofs[i], - blockHash: blockHash, - prover: evidence.prover, - txListHash: evidence.meta.txListHash - }), - "L1:zkp" - ); + if (msg.sender == specialProver && evidence.proofs[i].length == 0) { + // Skip ZKP verification + } else { + require( + proofVerifier.verifyZKP({ + verificationKey: ConfigManager( + resolver.resolve("config_manager", false) + ).getValue(string(abi.encodePacked("zk_vkey_", i))), + zkproof: evidence.proofs[i], + blockHash: blockHash, + prover: evidence.prover, + txListHash: evidence.meta.txListHash + }), + "L1:zkp" + ); + } } _markBlockProven({