|
| 1 | +use alloy_sol_types::{Error, sol}; |
| 2 | +use op_revm::OpHaltReason; |
| 3 | + |
| 4 | +// https://github.com/flashbots/flashtestations/commit/7cc7f68492fe672a823dd2dead649793aac1f216 |
| 5 | +sol!( |
| 6 | + #[sol(rpc, abi)] |
| 7 | + #[derive(Debug)] |
| 8 | + interface IFlashtestationRegistry { |
| 9 | + function registerTEEService(bytes calldata rawQuote, bytes calldata extendedRegistrationData) external; |
| 10 | + |
| 11 | + /// @notice Emitted when a TEE service is registered |
| 12 | + /// @param teeAddress The address of the TEE service |
| 13 | + /// @param rawQuote The raw quote from the TEE device |
| 14 | + /// @param alreadyExists Whether the TEE service is already registered |
| 15 | + event TEEServiceRegistered(address indexed teeAddress, bytes rawQuote, bool alreadyExists); |
| 16 | + |
| 17 | + /// @notice Emitted when the attestation contract is the 0x0 address |
| 18 | + error InvalidAttestationContract(); |
| 19 | + /// @notice Emitted when the signature is expired because the deadline has passed |
| 20 | + error ExpiredSignature(uint256 deadline); |
| 21 | + /// @notice Emitted when the quote is invalid according to the Automata DCAP Attestation contract |
| 22 | + error InvalidQuote(bytes output); |
| 23 | + /// @notice Emitted when the report data length is too short |
| 24 | + error InvalidReportDataLength(uint256 length); |
| 25 | + /// @notice Emitted when the registration data hash does not match the expected hash |
| 26 | + error InvalidRegistrationDataHash(bytes32 expected, bytes32 received); |
| 27 | + /// @notice Emitted when the byte size is exceeded |
| 28 | + error ByteSizeExceeded(uint256 size); |
| 29 | + /// @notice Emitted when the TEE service is already registered when registering |
| 30 | + error TEEServiceAlreadyRegistered(address teeAddress); |
| 31 | + /// @notice Emitted when the signer doesn't match the TEE address |
| 32 | + error SignerMustMatchTEEAddress(address signer, address teeAddress); |
| 33 | + /// @notice Emitted when the TEE service is not registered |
| 34 | + error TEEServiceNotRegistered(address teeAddress); |
| 35 | + /// @notice Emitted when the TEE service is already invalid when trying to invalidate a TEE registration |
| 36 | + error TEEServiceAlreadyInvalid(address teeAddress); |
| 37 | + /// @notice Emitted when the TEE service is still valid when trying to invalidate a TEE registration |
| 38 | + error TEEIsStillValid(address teeAddress); |
| 39 | + /// @notice Emitted when the nonce is invalid when verifying a signature |
| 40 | + error InvalidNonce(uint256 expected, uint256 provided); |
| 41 | + } |
| 42 | + |
| 43 | + #[sol(rpc, abi)] |
| 44 | + #[derive(Debug)] |
| 45 | + interface IBlockBuilderPolicy { |
| 46 | + function verifyBlockBuilderProof(uint8 version, bytes32 blockContentHash) external; |
| 47 | + |
| 48 | + /// @notice Emitted when a block builder proof is successfully verified |
| 49 | + /// @param caller The address that called the verification function (TEE address) |
| 50 | + /// @param workloadId The workload identifier of the TEE |
| 51 | + /// @param version The flashtestation protocol version used |
| 52 | + /// @param blockContentHash The hash of the block content |
| 53 | + /// @param commitHash The git commit hash associated with the workload |
| 54 | + event BlockBuilderProofVerified( |
| 55 | + address caller, bytes32 workloadId, uint8 version, bytes32 blockContentHash, string commitHash |
| 56 | + ); |
| 57 | + |
| 58 | + /// @notice Emitted when the registry is the 0x0 address |
| 59 | + error InvalidRegistry(); |
| 60 | + /// @notice Emitted when a workload to be added is already in the policy |
| 61 | + error WorkloadAlreadyInPolicy(); |
| 62 | + /// @notice Emitted when a workload to be removed is not in the policy |
| 63 | + error WorkloadNotInPolicy(); |
| 64 | + /// @notice Emitted when the address is not in the approvedWorkloads mapping |
| 65 | + error UnauthorizedBlockBuilder(address caller); |
| 66 | + /// @notice Emitted when the nonce is invalid |
| 67 | + error InvalidNonce(uint256 expected, uint256 provided); |
| 68 | + /// @notice Emitted when the commit hash is empty |
| 69 | + error EmptyCommitHash(); |
| 70 | + /// @notice Emitted when the source locators array is empty |
| 71 | + error EmptySourceLocators(); |
| 72 | + } |
| 73 | + |
| 74 | + struct BlockData { |
| 75 | + bytes32 parentHash; |
| 76 | + uint256 blockNumber; |
| 77 | + uint256 timestamp; |
| 78 | + bytes32[] transactionHashes; |
| 79 | + } |
| 80 | + |
| 81 | + type WorkloadId is bytes32; |
| 82 | +); |
| 83 | + |
| 84 | +#[derive(Debug, thiserror::Error)] |
| 85 | +pub enum FlashtestationRevertReason { |
| 86 | + #[error("flashtestation registry error: {0:?}")] |
| 87 | + FlashtestationRegistry(IFlashtestationRegistry::IFlashtestationRegistryErrors), |
| 88 | + #[error("block builder policy error: {0:?}")] |
| 89 | + BlockBuilderPolicy(IBlockBuilderPolicy::IBlockBuilderPolicyErrors), |
| 90 | + #[error("unknown revert: {0} err: {1}")] |
| 91 | + Unknown(String, Error), |
| 92 | + #[error("halt: {0:?}")] |
| 93 | + Halt(OpHaltReason), |
| 94 | +} |
| 95 | + |
1 | 96 | pub mod args;
|
2 | 97 | pub mod attestation;
|
3 | 98 | pub mod service;
|
|
0 commit comments