Skip to content

Commit

Permalink
style: add small cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocao committed Dec 9, 2024
1 parent f9f0a01 commit f0ec1fa
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
10 changes: 5 additions & 5 deletions contracts/core/SedaCoreV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import {SedaDataTypes} from "../libraries/SedaDataTypes.sol";
contract SedaCoreV1 is ISedaCore, RequestHandlerBase, ResultHandlerBase, UUPSUpgradeable, OwnableUpgradeable {
using EnumerableSet for EnumerableSet.Bytes32Set;

// ============ Errors ============

// Error thrown when a result is posted with a timestamp before the corresponding request
error InvalidResultTimestamp(bytes32 drId, uint256 resultTimestamp, uint256 requestTimestamp);

// ============ Constants ============

// Constant storage slot for the state following the ERC-7201 standard
bytes32 private constant CORE_V1_STORAGE_SLOT =
keccak256(abi.encode(uint256(keccak256("sedacore.storage.v1")) - 1)) & ~bytes32(uint256(0xff));

// ============ Errors ============

// Error thrown when a result is posted with a timestamp before the corresponding request
error InvalidResultTimestamp(bytes32 drId, uint256 resultTimestamp, uint256 requestTimestamp);

// ============ Storage ============

/// @custom:storage-location erc7201:sedacore.storage.v1
Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/MockSecp256k1ProverV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {Secp256k1ProverV1} from "../provers/Secp256k1ProverV1.sol";
/// @notice Mock version of Secp256k1Prover for testing purposes
/// @dev This contract is a mock and should not be used in production
contract MockSecp256k1ProverV2 is Secp256k1ProverV1 {
// ============ Errors ============
error ContractNotUpgradeable();

// ============ Constants ============
bytes32 private constant PROVER_V2_STORAGE_SLOT =
keccak256(abi.encode(uint256(keccak256("secp256k1prover.storage.v2")) - 1)) & ~bytes32(uint256(0xff));

// ============ Errors ============
error ContractNotUpgradeable();

// ============ Storage ============
/// @custom:storage-location secp256k1prover.storage.v2
struct V2Storage {
Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/MockSedaCoreV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {SedaCoreV1} from "../core/SedaCoreV1.sol";
/// @notice Mock version of SedaCore for testing purposes
/// @dev This contract is a mock and should not be used in production
contract MockSedaCoreV2 is SedaCoreV1 {
// ============ Errors ============
error ContractNotUpgradeable();

// ============ Constants ============
bytes32 private constant CORE_V2_STORAGE_SLOT =
keccak256(abi.encode(uint256(keccak256("sedacore.storage.v2")) - 1)) & ~bytes32(uint256(0xff));

// ============ Errors ============
error ContractNotUpgradeable();

// ============ Storage ============
/// @custom:storage-location sedacore.storage.v2
struct V2Storage {
Expand Down
7 changes: 3 additions & 4 deletions contracts/provers/Secp256k1ProverV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import {SedaDataTypes} from "../libraries/SedaDataTypes.sol";
/// - Valid validator proofs and signatures
/// - Sufficient voting power to meet the consensus threshold
contract Secp256k1ProverV1 is ProverBase, Initializable, UUPSUpgradeable, OwnableUpgradeable {
// ============ Errors ============
// Error thrown when consensus is not reached
error ConsensusNotReached();

// ============ Constants ============

// The percentage of voting power required for consensus (66.666666%, represented as parts per 100,000,000)
Expand All @@ -32,6 +28,9 @@ contract Secp256k1ProverV1 is ProverBase, Initializable, UUPSUpgradeable, Ownabl
bytes32 private constant PROVER_V1_STORAGE_SLOT =
keccak256(abi.encode(uint256(keccak256("secp256k1prover.storage.v1")) - 1)) & ~bytes32(uint256(0xff));

// ============ Errors ============
error ConsensusNotReached();

// ============ Storage ============

/// @custom:storage-location secp256k1prover.storage.v1
Expand Down
10 changes: 8 additions & 2 deletions contracts/provers/abstract/ProverBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ import {SedaDataTypes} from "../../libraries/SedaDataTypes.sol";
/// @notice Base contract for implementing proof verification logic
/// @dev This abstract contract defines the basic structure and error handling for proof verification
abstract contract ProverBase is IProver {
// ============ Constants ============

/// @notice Domain separator used to prevent cross-domain replay attacks when hashing result IDs
bytes1 internal constant RESULT_DOMAIN_SEPARATOR = 0x00;

// ============ Errors ============

error InvalidBatchHeight();
error InvalidSignature();
error InvalidValidatorProof();
error MismatchedSignaturesAndProofs();

// Domain separator used to prevent cross-domain replay attacks when hashing result IDs
bytes1 internal constant RESULT_DOMAIN_SEPARATOR = 0x00;
// ============ External Functions ============

/// @inheritdoc IProver
function postBatch(
Expand Down

0 comments on commit f0ec1fa

Please sign in to comment.