Skip to content

Commit

Permalink
feat(protocol): add special logics for alpha-2 testnet (#12987)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Jan 20, 2023
1 parent 7a007f3 commit 3b71285
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
6 changes: 3 additions & 3 deletions packages/protocol/contracts/L1/TkoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down
11 changes: 11 additions & 0 deletions packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
34 changes: 22 additions & 12 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 3b71285

Please sign in to comment.