mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-08 03:43:56 -05:00
[Fix] Update smart-contract-errors.yaml with script assistance (#809)
* fix * added more errors to smart-contract-errors.toml * cross-check against bytecode * remove redundant comment
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
[smart-contract-errors]
|
||||
# L1 Linea Rollup
|
||||
# Generated from `npx ts-node contracts/scripts/operational/getSmartContractErrorsFromABI.ts contracts/local-deployments-artifacts/deployed-artifacts/LineaRollupV6-Deployed-2024-12-03.json`
|
||||
"0f06cd15" = "DataAlreadySubmitted"
|
||||
"c01eab56" = "EmptySubmissionData"
|
||||
"36459fa0" = "L1RollingHashDoesNotExistOnL1"
|
||||
@@ -29,15 +30,37 @@
|
||||
"7907d79b" = "ProofIsEmpty"
|
||||
"69ed70ab" = "InvalidProofType"
|
||||
"09bde339" = "InvalidProof"
|
||||
"c0a71b58" = "IsPaused"
|
||||
"18659654" = "IsNotPaused"
|
||||
"ca389c44" = "InvalidProofOrProofVerificationRanOutOfGas"
|
||||
"6e5424c2" = "ParentBlobNotSubmitted"
|
||||
"edeae83c" = "FinalBlobNotSubmitted"
|
||||
"8019aff7" = "BlobSubmissionDataEmpty"
|
||||
"b05e92fa" = "InvalidMerkleProof"
|
||||
"4306cbb1" = "LastFinalizationTimeNotLapsed"
|
||||
"f7ec9097" = "LeafIndexOutOfBounds"
|
||||
"335a4a90" = "MessageAlreadyClaimed"
|
||||
"7f7497e9" = "OnlyNonFallbackOperator"
|
||||
"5e3fd6ad" = "ProofLengthDifferentThanMerkleDepth"
|
||||
"37ed32e8" = "ReentrantCall"
|
||||
"6dfcc650" = "SafeCastOverflowedUintDowncast"
|
||||
|
||||
# L2 Message Service
|
||||
# Generated from `npx ts-node contracts/scripts/operational/getSmartContractErrorsFromABI.ts contracts/local-deployments-artifacts/deployed-artifacts/L2MessageServiceV1-Deployed-2024-12-03.json`
|
||||
"3b174434" = "MessageHashesListLengthHigherThanOneHundred"
|
||||
"6446cc9c" = "MessageHashesListLengthIsZero"
|
||||
"d39e75f9" = "L1MessageNumberSynchronizationWrong"
|
||||
"7557a60a" = "L1RollingHashSynchronizationWrong"
|
||||
"36a4bb94" = "FinalRollingHashIsZero"
|
||||
"732f9413" = "FeeTooLow"
|
||||
|
||||
# Shared Message Service (L1 and L2) Errors
|
||||
"a57c4df4" = "FeePaymentFailed"
|
||||
"18659654" = "IsNotPaused"
|
||||
"c0a71b58" = "IsPaused"
|
||||
"d10d72bb" = "LimitIsZero"
|
||||
"992d87c3" = "MessageDoesNotExistOrHasAlreadyBeenClaimed"
|
||||
"54613443" = "MessageSendingFailed"
|
||||
"b5ed5a3b" = "PeriodIsZero"
|
||||
"a74c1c5f" = "RateLimitExceeded"
|
||||
"b03b6932" = "ValueSentTooLow"
|
||||
"8579befe" = "ZeroAddressNotAllowed"
|
||||
"0742d053" = "ZeroHashNotAllowed"
|
||||
@@ -3,3 +3,9 @@ import { encodeData } from "./encoding";
|
||||
|
||||
export const generateKeccak256 = (types: string[], values: unknown[], opts: { encodePacked?: boolean }) =>
|
||||
ethers.keccak256(encodeData(types, values, opts.encodePacked));
|
||||
|
||||
export const generateKeccak256ForString = (value: string) =>
|
||||
generateKeccak256(["string"], [value], { encodePacked: true });
|
||||
|
||||
export const generateFunctionSelector = (functionSignature: string) =>
|
||||
generateKeccak256ForString(functionSignature).slice(2, 10);
|
||||
|
||||
@@ -8,12 +8,12 @@ import "hardhat-storage-layout";
|
||||
// import "hardhat-tracer"; // This plugin does not work with the latest hardhat version
|
||||
import { HardhatUserConfig } from "hardhat/config";
|
||||
import { getBlockchainNode, getL2BlockchainNode } from "./common";
|
||||
import "./scripts/operational/getCurrentFinalizedBlockNumberTask";
|
||||
import "./scripts/operational/grantContractRolesTask";
|
||||
import "./scripts/operational/renounceContractRolesTask";
|
||||
import "./scripts/operational/setRateLimitTask";
|
||||
import "./scripts/operational/setVerifierAddressTask";
|
||||
import "./scripts/operational/setMessageServiceOnTokenBridgeTask";
|
||||
import "./scripts/operational/tasks/getCurrentFinalizedBlockNumberTask";
|
||||
import "./scripts/operational/tasks/grantContractRolesTask";
|
||||
import "./scripts/operational/tasks/renounceContractRolesTask";
|
||||
import "./scripts/operational/tasks/setRateLimitTask";
|
||||
import "./scripts/operational/tasks/setVerifierAddressTask";
|
||||
import "./scripts/operational/tasks/setMessageServiceOnTokenBridgeTask";
|
||||
|
||||
import "solidity-docgen";
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
// Get smart contract Errors (with code) from smart contract ABI
|
||||
// Usage - `npx ts-node scripts/operational/getSmartContractErrorsFromABI.ts <ABI_JSON_FILE_PATH>`
|
||||
|
||||
import { generateFunctionSelector } from "../../common/helpers/hashing";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
// Input types
|
||||
type ABIElementInput = {
|
||||
internalType: string;
|
||||
name: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
type ABIElement = {
|
||||
type: string;
|
||||
name: string;
|
||||
inputs: ABIElementInput[];
|
||||
};
|
||||
|
||||
type ABI = ABIElement[];
|
||||
|
||||
type HardhatBuildArtifactJson = {
|
||||
abi: ABI;
|
||||
};
|
||||
|
||||
const ERROR_TYPE = "error";
|
||||
|
||||
// Output types
|
||||
type SmartContractErrorOutput = {
|
||||
name: string;
|
||||
functionSignature: string;
|
||||
selector: string;
|
||||
};
|
||||
|
||||
// Function to get smart contract errors from ABI
|
||||
function getSmartContractErrorsFromABI(abiInput: ABI): SmartContractErrorOutput[] {
|
||||
const resp: SmartContractErrorOutput[] = [];
|
||||
|
||||
abiInput.forEach((element: ABIElement) => {
|
||||
if (element.type === ERROR_TYPE) {
|
||||
const functionSignature = getFunctionSignature(element);
|
||||
resp.push({
|
||||
name: element.name,
|
||||
functionSignature: functionSignature,
|
||||
selector: generateFunctionSelector(functionSignature),
|
||||
});
|
||||
}
|
||||
});
|
||||
return resp;
|
||||
}
|
||||
|
||||
function getFunctionSignature(abiElement: ABIElement): string {
|
||||
let functionSignature = abiElement.name;
|
||||
functionSignature += "(";
|
||||
abiElement.inputs.forEach((input: ABIElementInput) => {
|
||||
functionSignature += input.type;
|
||||
functionSignature += ",";
|
||||
});
|
||||
// Remove trailing "," if have error param/s
|
||||
if (abiElement.inputs.length > 0) functionSignature = functionSignature.substring(0, functionSignature.length - 1);
|
||||
functionSignature += ")";
|
||||
return functionSignature;
|
||||
}
|
||||
|
||||
function importABIFromCLIArg(): ABI {
|
||||
const filePath = process.argv[2];
|
||||
if (filePath.length === 0)
|
||||
throw new Error(
|
||||
"No file path provided. Usage: npx ts-node scripts/operational/getSmartContractErrorsFromABI.ts <ABI_JSON_FILE_PATH>",
|
||||
);
|
||||
|
||||
try {
|
||||
const fileContent = readFileSync(filePath, "utf8");
|
||||
const artifactJson: HardhatBuildArtifactJson = JSON.parse(fileContent);
|
||||
return artifactJson.abi;
|
||||
} catch (error: unknown) {
|
||||
throw new Error(`Failed to import ABI from ${filePath}: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const abi = importABIFromCLIArg();
|
||||
const smartContractErrors = getSmartContractErrorsFromABI(abi);
|
||||
console.log(smartContractErrors);
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -1,5 +1,5 @@
|
||||
import { task } from "hardhat/config";
|
||||
import { getTaskCliOrEnvValue } from "../../common/helpers/environmentHelper";
|
||||
import { getTaskCliOrEnvValue } from "../../../common/helpers/environmentHelper";
|
||||
|
||||
/*
|
||||
*******************************************************************************************
|
||||
@@ -1,5 +1,5 @@
|
||||
import { task } from "hardhat/config";
|
||||
import { getTaskCliOrEnvValue } from "../../common/helpers/environmentHelper";
|
||||
import { getTaskCliOrEnvValue } from "../../../common/helpers/environmentHelper";
|
||||
|
||||
/*
|
||||
*******************************************************************************************
|
||||
@@ -1,5 +1,5 @@
|
||||
import { task } from "hardhat/config";
|
||||
import { getTaskCliOrEnvValue } from "../../common/helpers/environmentHelper";
|
||||
import { getTaskCliOrEnvValue } from "../../../common/helpers/environmentHelper";
|
||||
|
||||
/*
|
||||
*******************************************************************************************
|
||||
@@ -1,8 +1,8 @@
|
||||
// import { ethers, network, upgrades } from "hardhat";
|
||||
import { task } from "hardhat/config";
|
||||
import { TokenBridge } from "../../typechain-types";
|
||||
import { getTaskCliOrEnvValue } from "../../common/helpers/environmentHelper";
|
||||
import { getDeployedContractOnNetwork } from "../../common/helpers/readAddress";
|
||||
import { TokenBridge } from "../../../typechain-types";
|
||||
import { getTaskCliOrEnvValue } from "../../../common/helpers/environmentHelper";
|
||||
import { getDeployedContractOnNetwork } from "../../../common/helpers/readAddress";
|
||||
|
||||
/*
|
||||
*******************************************************************************************
|
||||
@@ -1,5 +1,5 @@
|
||||
import { task } from "hardhat/config";
|
||||
import { getTaskCliOrEnvValue } from "../../common/helpers/environmentHelper";
|
||||
import { getTaskCliOrEnvValue } from "../../../common/helpers/environmentHelper";
|
||||
|
||||
/*
|
||||
*******************************************************************************************
|
||||
@@ -1,5 +1,5 @@
|
||||
import { task } from "hardhat/config";
|
||||
import { getTaskCliOrEnvValue } from "../../common/helpers/environmentHelper";
|
||||
import { getTaskCliOrEnvValue } from "../../../common/helpers/environmentHelper";
|
||||
|
||||
/*
|
||||
*******************************************************************************************
|
||||
2
pnpm-lock.yaml
generated
2
pnpm-lock.yaml
generated
@@ -248,6 +248,8 @@ importers:
|
||||
specifier: 17.7.2
|
||||
version: 17.7.2
|
||||
|
||||
contracts/lib/forge-std: {}
|
||||
|
||||
e2e:
|
||||
devDependencies:
|
||||
'@jest/globals':
|
||||
|
||||
Reference in New Issue
Block a user