Skip to content

Commit

Permalink
Merge branch 'main' into bridge_button
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Feb 23, 2023
2 parents 378baf1 + f39e65d commit 11b0f29
Show file tree
Hide file tree
Showing 118 changed files with 1,985 additions and 1,596 deletions.
21 changes: 14 additions & 7 deletions packages/bridge-ui/src/components/form/BridgeForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,20 @@
<span class="label-text">{$_("bridgeForm.fieldLabel")}</span>

{#if $signer && tokenBalance}
<button class="label-text" on:click={useFullAmount}
>{$_("bridgeForm.maxLabel")}
{tokenBalance.length > 10
? `${truncateString(tokenBalance, 6)}...`
: tokenBalance}
{$token.symbol}
</button>{/if}
<div class="label-text ">
<span>
{$_("bridgeForm.balance")}:
{tokenBalance.length > 10
? `${truncateString(tokenBalance, 6)}...`
: tokenBalance}
{$token.symbol}
</span>

<button class="btn btn-xs rounded-md hover:border-accent text-xs ml-1 h-[20px]" on:click={useFullAmount}>
{$_("bridgeForm.maxLabel")}
</button>
</div>
{/if}
</label>

<label
Expand Down
3 changes: 2 additions & 1 deletion packages/bridge-ui/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function setupI18n({ withLocale: _locale } = { withLocale: "en" }) {
},
bridgeForm: {
fieldLabel: "Amount",
maxLabel: "Max:",
maxLabel: "Max",
balance: "Balance",
processingFeeLabel: "Processing Fee",
bridge: "Bridge",
approve: "Approve",
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"files": ["*.sol", "*.ts"],
"options": {
"tabWidth": 4
"tabWidth": 4,
"compiler": "^0.8.18"
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/.solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"extends": "solhint:recommended",
"rules": {
"avoid-low-level-calls": "off",
"compiler-version": ["error", "^0.8.0"],
"compiler-version": ["error", "^0.8.18"],
"func-visibility": ["warn", { "ignoreConstructors": true }],
"max-line-length": ["warn", 80],
"max-line-length": ["warn", 100],
"no-empty-blocks": "off",
"no-inline-assembly": "off",
"not-rely-on-time": "off",
Expand Down
21 changes: 7 additions & 14 deletions packages/protocol/contracts/L1/ProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.9;
pragma solidity ^0.8.18;

import "../common/EssentialContract.sol";
import "../libs/LibZKP.sol";
import "../thirdparty/LibMerkleTrie.sol";
import {EssentialContract} from "../common/EssentialContract.sol";
import {LibZKP} from "../libs/LibZKP.sol";
import {LibMerkleTrie} from "../thirdparty/LibMerkleTrie.sol";

/// @author dantaik <[email protected]>
interface IProofVerifier {
function verifyZKP(
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
bytes32 instance
) external view returns (bool verified);

function verifyMKP(
Expand All @@ -36,17 +33,13 @@ contract ProofVerifier is IProofVerifier, EssentialContract {
function verifyZKP(
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
bytes32 instance
) external view returns (bool) {
return
LibZKP.verify({
plonkVerifier: resolve(verifierId, false),
zkproof: zkproof,
blockHash: blockHash,
prover: prover,
txListHash: txListHash
instance: instance
});
}

Expand Down
49 changes: 49 additions & 0 deletions packages/protocol/contracts/L1/TaikoCustomErrors.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
// _____ _ _ _ _
// |_ _|_ _(_) |_____ | | __ _| |__ ___
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.18;

abstract contract TaikoCustomErrors {
// The following custom errors must match the definitions in other V1 libraries.
error L1_0_FEE_BASE();
error L1_ANCHOR_CALLDATA();
error L1_ANCHOR_DEST();
error L1_ANCHOR_GAS_LIMIT();
error L1_ANCHOR_RECEIPT_ADDR();
error L1_ANCHOR_RECEIPT_DATA();
error L1_ANCHOR_RECEIPT_LOGS();
error L1_ANCHOR_RECEIPT_PROOF();
error L1_ANCHOR_RECEIPT_STATUS();
error L1_ANCHOR_RECEIPT_TOPICS();
error L1_ANCHOR_SIG_R();
error L1_ANCHOR_SIG_S();
error L1_ANCHOR_TX_PROOF();
error L1_ANCHOR_TYPE();
error L1_BLOCK_NUMBER();
error L1_CANNOT_BE_FIRST_PROVER();
error L1_CIRCUIT_LENGTH();
error L1_COMMITTED();
error L1_CONFLICT_PROOF();
error L1_DUP_PROVERS();
error L1_EXTRA_DATA();
error L1_GAS_LIMIT();
error L1_HALTED();
error L1_HALT_CONDITION();
error L1_ID();
error L1_INPUT_SIZE();
error L1_METADATA_FIELD();
error L1_META_MISMATCH();
error L1_NOT_COMMITTED();
error L1_NOT_FIRST_PROVER();
error L1_PROOF_LENGTH();
error L1_PROVER();
error L1_SOLO_PROPOSER();
error L1_TOO_LATE();
error L1_TOO_MANY();
error L1_TOO_MANY_PROVERS();
error L1_TX_LIST();
error L1_ZKP();
}
23 changes: 11 additions & 12 deletions packages/protocol/contracts/L1/TaikoData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.9;
pragma solidity ^0.8.18;

/// @author dantaik <[email protected]>
library TaikoData {
struct Config {
uint256 chainId;
Expand Down Expand Up @@ -38,9 +37,10 @@ library TaikoData {
uint64 proofTimeCap;
uint64 bootstrapDiscountHalvingPeriod;
uint64 initialUncleDelay;
uint64 proverRewardRandomizedPercentage;
bool enableTokenomics;
bool enablePublicInputsCheck;
bool enableProofValidation;
bool enableAnchorValidation;
bool enableOracleProver;
}

Expand Down Expand Up @@ -75,15 +75,14 @@ library TaikoData {

// This struct takes 9 slots.
struct State {
// block id => block hash (some blocks' hashes won't be persisted,
// only the latest one if verified in a batch)
mapping(uint256 => bytes32) l2Hashes;
// block id => ProposedBlock
mapping(uint256 => ProposedBlock) proposedBlocks;
// block id => parent hash => fork choice
mapping(uint256 => mapping(bytes32 => ForkChoice)) forkChoices;
// proposer => commitSlot => hash(commitHash, commitHeight)
mapping(address => mapping(uint256 => bytes32)) commits;
// some blocks' hashes won't be persisted,
// only the latest one if verified in a batch
mapping(uint256 blockId => bytes32 blockHash) l2Hashes;
mapping(uint256 blockId => ProposedBlock proposedBlock) proposedBlocks;
// solhint-disable-next-line max-line-length
mapping(uint256 blockId => mapping(bytes32 parentHash => ForkChoice forkChoice)) forkChoices;
// solhint-disable-next-line max-line-length
mapping(address proposerAddress => mapping(uint256 commitSlot => bytes32 commitHash)) commits;
// Never or rarely changed
uint64 genesisHeight;
uint64 genesisTimestamp;
Expand Down
11 changes: 3 additions & 8 deletions packages/protocol/contracts/L1/TaikoEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.9;
pragma solidity ^0.8.18;

import "./TaikoData.sol";
import {TaikoData} from "./TaikoData.sol";

/// @author david <[email protected]>
abstract contract TaikoEvents {
// The following events must match the definitions in other V1 libraries.
event BlockVerified(uint256 indexed id, bytes32 blockHash);

event BlockCommitted(
uint64 commitSlot,
uint64 commitHeight,
bytes32 commitHash
);
event BlockCommitted(uint64 commitSlot, bytes32 commitHash);

event BlockProposed(uint256 indexed id, TaikoData.BlockMetadata meta);

Expand Down
44 changes: 27 additions & 17 deletions packages/protocol/contracts/L1/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.9;
pragma solidity ^0.8.18;

import "../common/EssentialContract.sol";
import "../common/IHeaderSync.sol";
import "../libs/LibAnchorSignature.sol";
import "../libs/LibSharedConfig.sol";
import "./TaikoData.sol";
import "./TaikoEvents.sol";
import "./libs/LibProposing.sol";
import "./libs/LibProving.sol";
import "./libs/LibUtils.sol";
import "./libs/LibVerifying.sol";
import {EssentialContract} from "../common/EssentialContract.sol";
import {IHeaderSync} from "../common/IHeaderSync.sol";
import {LibAnchorSignature} from "../libs/LibAnchorSignature.sol";
import {LibSharedConfig} from "../libs/LibSharedConfig.sol";
import {TaikoData} from "./TaikoData.sol";
import {TaikoEvents} from "./TaikoEvents.sol";
import {TaikoCustomErrors} from "./TaikoCustomErrors.sol";
import {LibProposing} from "./libs/LibProposing.sol";
import {LibProving} from "./libs/LibProving.sol";
import {LibUtils} from "./libs/LibUtils.sol";
import {LibVerifying} from "./libs/LibVerifying.sol";
import {AddressResolver} from "../common/AddressResolver.sol";

/**
* @author dantaik <[email protected]>
*/
contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents {
contract TaikoL1 is
EssentialContract,
IHeaderSync,
TaikoEvents,
TaikoCustomErrors
{
using LibUtils for TaikoData.State;

TaikoData.State public state;
Expand Down Expand Up @@ -89,7 +93,7 @@ contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents {
});
LibVerifying.verifyBlocks({
state: state,
config: getConfig(),
config: config,
resolver: AddressResolver(this),
maxBlocks: config.maxVerificationsPerTx,
checkHalt: false
Expand Down Expand Up @@ -192,7 +196,7 @@ contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents {
}

function getBlockFee() public view returns (uint256) {
(, uint fee, uint deposit) = LibProposing.getBlockFee(
(, uint256 fee, uint256 deposit) = LibProposing.getBlockFee(
state,
getConfig()
);
Expand Down Expand Up @@ -281,6 +285,12 @@ contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents {
return LibUtils.getUncleProofDelay(state, getConfig(), blockId);
}

function getProverRewardBips(
uint256 numProvers
) public view returns (uint256[] memory) {
return LibVerifying.getProverRewardBips(getConfig(), numProvers);
}

function getConfig() public pure virtual returns (TaikoData.Config memory) {
return LibSharedConfig.getConfig();
}
Expand Down
18 changes: 11 additions & 7 deletions packages/protocol/contracts/L1/TkoToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-<
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/

pragma solidity ^0.8.9;
pragma solidity ^0.8.18;

import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
import {
SafeCastUpgradeable
} from "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";

import "../common/EssentialContract.sol";
import "../common/IMintableERC20.sol";
import "../libs/LibMath.sol";
import "../thirdparty/ERC20Upgradeable.sol";
import {EssentialContract} from "../common/EssentialContract.sol";
import {IMintableERC20} from "../common/IMintableERC20.sol";
import {LibMath} from "../libs/LibMath.sol";
import {
ERC20Upgradeable,
IERC20Upgradeable
} from "../thirdparty/ERC20Upgradeable.sol";

/// @author dantaik <[email protected]>
/// @dev This is Taiko's governance and fee token.
contract TkoToken is EssentialContract, ERC20Upgradeable, IMintableERC20 {
using LibMath for uint256;
Expand Down
Loading

0 comments on commit 11b0f29

Please sign in to comment.