From 6549383f4b0ad2419bd53e96fe3ec153f3b59d17 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 16 Feb 2023 15:33:53 +0800 Subject: [PATCH 1/3] feat(protocol): make L1 libs custom errors part of the TaikoL1 ABI --- .../contracts/L1/TaikoCustomErrors.sol | 59 +++++++++++++++++++ packages/protocol/contracts/L1/TaikoL1.sol | 8 ++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 packages/protocol/contracts/L1/TaikoCustomErrors.sol diff --git a/packages/protocol/contracts/L1/TaikoCustomErrors.sol b/packages/protocol/contracts/L1/TaikoCustomErrors.sol new file mode 100644 index 00000000000..1f0cb568260 --- /dev/null +++ b/packages/protocol/contracts/L1/TaikoCustomErrors.sol @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: MIT +// _____ _ _ _ _ +// |_ _|_ _(_) |_____ | | __ _| |__ ___ +// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< +// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ + +pragma solidity ^0.8.9; + +/// @author david +abstract contract TaikoCustomErrors { + // The following custom errors must match the definitions in other V1 libraries. + + // LibProposing + error L1_METADATA_FIELD(); + error L1_EXTRA_DATA(); + error L1_ID(); + error L1_TOO_MANY(); + error L1_GAS_LIMIT(); + error L1_COMMITTED(); + error L1_NOT_COMMITTED(); + error L1_SOLO_PROPOSER(); + error L1_INPUT_SIZE(); + error L1_TX_LIST(); + + // LibProving + // error L1_ID(); // Already defined in LibProposing. + error L1_PROVER(); + error L1_TOO_LATE(); + // error L1_INPUT_SIZE(); // Already defined in LibProposing. + error L1_PROOF_LENGTH(); + error L1_CONFLICT_PROOF(); + error L1_CIRCUIT_LENGTH(); + error L1_META_MISMATCH(); + error L1_ZKP(); + error L1_TOO_MANY_PROVERS(); + error L1_DUP_PROVERS(); + error L1_NOT_FIRST_PROVER(); + error L1_CANNOT_BE_FIRST_PROVER(); + error L1_ANCHOR_TYPE(); + error L1_ANCHOR_DEST(); + error L1_ANCHOR_GAS_LIMIT(); + error L1_ANCHOR_CALLDATA(); + error L1_ANCHOR_SIG_R(); + error L1_ANCHOR_SIG_S(); + error L1_ANCHOR_RECEIPT_PROOF(); + error L1_ANCHOR_RECEIPT_STATUS(); + error L1_ANCHOR_RECEIPT_LOGS(); + error L1_ANCHOR_RECEIPT_ADDR(); + error L1_ANCHOR_RECEIPT_TOPICS(); + error L1_ANCHOR_RECEIPT_DATA(); + + // LibUtils + error L1_HALT_CONDITION(); + error L1_BLOCK_NUMBER(); + + // LibVerifying + error L1_HALTED(); + error L1_0_FEE_BASE(); +} diff --git a/packages/protocol/contracts/L1/TaikoL1.sol b/packages/protocol/contracts/L1/TaikoL1.sol index 55255e224a7..878a063f350 100644 --- a/packages/protocol/contracts/L1/TaikoL1.sol +++ b/packages/protocol/contracts/L1/TaikoL1.sol @@ -12,6 +12,7 @@ import "../libs/LibAnchorSignature.sol"; import "../libs/LibSharedConfig.sol"; import "./TaikoData.sol"; import "./TaikoEvents.sol"; +import "./TaikoCustomErrors.sol"; import "./libs/LibProposing.sol"; import "./libs/LibProving.sol"; import "./libs/LibUtils.sol"; @@ -20,7 +21,12 @@ import "./libs/LibVerifying.sol"; /** * @author dantaik */ -contract TaikoL1 is EssentialContract, IHeaderSync, TaikoEvents { +contract TaikoL1 is + EssentialContract, + IHeaderSync, + TaikoEvents, + TaikoCustomErrors +{ using LibUtils for TaikoData.State; TaikoData.State public state; From bfc514fbb41c43c3680cbc5dd890d59cef644936 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 16 Feb 2023 21:00:43 +0800 Subject: [PATCH 2/3] feat: sort errors --- .../contracts/L1/TaikoCustomErrors.sol | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoCustomErrors.sol b/packages/protocol/contracts/L1/TaikoCustomErrors.sol index 1f0cb568260..2609985f7be 100644 --- a/packages/protocol/contracts/L1/TaikoCustomErrors.sol +++ b/packages/protocol/contracts/L1/TaikoCustomErrors.sol @@ -11,49 +11,49 @@ abstract contract TaikoCustomErrors { // The following custom errors must match the definitions in other V1 libraries. // LibProposing - error L1_METADATA_FIELD(); + error L1_COMMITTED(); error L1_EXTRA_DATA(); - error L1_ID(); - error L1_TOO_MANY(); error L1_GAS_LIMIT(); - error L1_COMMITTED(); + error L1_ID(); + error L1_INPUT_SIZE(); + error L1_METADATA_FIELD(); error L1_NOT_COMMITTED(); error L1_SOLO_PROPOSER(); - error L1_INPUT_SIZE(); + error L1_TOO_MANY(); error L1_TX_LIST(); // LibProving - // error L1_ID(); // Already defined in LibProposing. - error L1_PROVER(); - error L1_TOO_LATE(); - // error L1_INPUT_SIZE(); // Already defined in LibProposing. - error L1_PROOF_LENGTH(); - error L1_CONFLICT_PROOF(); - error L1_CIRCUIT_LENGTH(); - error L1_META_MISMATCH(); - error L1_ZKP(); - error L1_TOO_MANY_PROVERS(); - error L1_DUP_PROVERS(); - error L1_NOT_FIRST_PROVER(); - error L1_CANNOT_BE_FIRST_PROVER(); - error L1_ANCHOR_TYPE(); + error L1_ANCHOR_CALLDATA(); error L1_ANCHOR_DEST(); error L1_ANCHOR_GAS_LIMIT(); - error L1_ANCHOR_CALLDATA(); - error L1_ANCHOR_SIG_R(); - error L1_ANCHOR_SIG_S(); + 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_LOGS(); - error L1_ANCHOR_RECEIPT_ADDR(); error L1_ANCHOR_RECEIPT_TOPICS(); - error L1_ANCHOR_RECEIPT_DATA(); + error L1_ANCHOR_SIG_R(); + error L1_ANCHOR_SIG_S(); + error L1_ANCHOR_TYPE(); + error L1_CANNOT_BE_FIRST_PROVER(); + error L1_CIRCUIT_LENGTH(); + error L1_CONFLICT_PROOF(); + error L1_DUP_PROVERS(); + // error L1_ID(); // Already defined in LibProposing. + // error L1_INPUT_SIZE(); // Already defined in LibProposing. + error L1_META_MISMATCH(); + error L1_NOT_FIRST_PROVER(); + error L1_PROOF_LENGTH(); + error L1_PROVER(); + error L1_TOO_LATE(); + error L1_TOO_MANY_PROVERS(); + error L1_ZKP(); // LibUtils - error L1_HALT_CONDITION(); error L1_BLOCK_NUMBER(); + error L1_HALT_CONDITION(); // LibVerifying - error L1_HALTED(); error L1_0_FEE_BASE(); + error L1_HALTED(); } From 9e870cb20d3341aa3f12428382f87174e6c30a66 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 16 Feb 2023 21:03:10 +0800 Subject: [PATCH 3/3] feat: sort errors --- .../contracts/L1/TaikoCustomErrors.sol | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/packages/protocol/contracts/L1/TaikoCustomErrors.sol b/packages/protocol/contracts/L1/TaikoCustomErrors.sol index 2609985f7be..dfc7ebf8ebf 100644 --- a/packages/protocol/contracts/L1/TaikoCustomErrors.sol +++ b/packages/protocol/contracts/L1/TaikoCustomErrors.sol @@ -9,20 +9,7 @@ pragma solidity ^0.8.9; /// @author david abstract contract TaikoCustomErrors { // The following custom errors must match the definitions in other V1 libraries. - - // LibProposing - error L1_COMMITTED(); - error L1_EXTRA_DATA(); - error L1_GAS_LIMIT(); - error L1_ID(); - error L1_INPUT_SIZE(); - error L1_METADATA_FIELD(); - error L1_NOT_COMMITTED(); - error L1_SOLO_PROPOSER(); - error L1_TOO_MANY(); - error L1_TX_LIST(); - - // LibProving + error L1_0_FEE_BASE(); error L1_ANCHOR_CALLDATA(); error L1_ANCHOR_DEST(); error L1_ANCHOR_GAS_LIMIT(); @@ -35,25 +22,28 @@ abstract contract TaikoCustomErrors { error L1_ANCHOR_SIG_R(); error L1_ANCHOR_SIG_S(); 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_ID(); // Already defined in LibProposing. - // error L1_INPUT_SIZE(); // Already defined in LibProposing. + 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(); - - // LibUtils - error L1_BLOCK_NUMBER(); - error L1_HALT_CONDITION(); - - // LibVerifying - error L1_0_FEE_BASE(); - error L1_HALTED(); }