Commit 20407c5a authored by clabby's avatar clabby Committed by GitHub

feat(ctb): Add `ISemver` to the `PreimageOracle` and `MIPS` (#9743)

* Add semver to MIPS/PreimageOracle

* bindings

semver
parent 33ecaaa2
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -95,6 +95,14 @@ ...@@ -95,6 +95,14 @@
"initCodeHash": "0x0da844fb4dd22f252ff631524f01f45edf43bca7558fe45f71d711b79af01742", "initCodeHash": "0x0da844fb4dd22f252ff631524f01f45edf43bca7558fe45f71d711b79af01742",
"sourceCodeHash": "0x1afb1d392e8f6a58ff86ea7f648e0d1756d4ba8d0d964279d58a390deaa53b7e" "sourceCodeHash": "0x1afb1d392e8f6a58ff86ea7f648e0d1756d4ba8d0d964279d58a390deaa53b7e"
}, },
"src/cannon/MIPS.sol": {
"initCodeHash": "0xaf2ac814f64ccf12e9c6738db7cef865f51f9e39f39105adef9fba11465f6ee1",
"sourceCodeHash": "0x6ab593a4b87007c000c254b2c4ff0507683600f48b60e453148e44bee30030f6"
},
"src/cannon/PreimageOracle.sol": {
"initCodeHash": "0x7998712f9dd5848f33184ede984c0843917cc176562006479e1dbb26b0be0ff6",
"sourceCodeHash": "0x2f5d84ed4a807cb7e7354514f53445995fc2f0836abd1ca7cfa34599d9031d9a"
},
"src/dispute/DisputeGameFactory.sol": { "src/dispute/DisputeGameFactory.sol": {
"initCodeHash": "0x80d749a56c1776930fe0deb5c3c646217716e5875ace99c4d036af0452236476", "initCodeHash": "0x80d749a56c1776930fe0deb5c3c646217716e5875ace99c4d036af0452236476",
"sourceCodeHash": "0x1e5a6deded88804971fc1847c9eac65921771bff353437c0b29ed2f55513b984" "sourceCodeHash": "0x1e5a6deded88804971fc1847c9eac65921771bff353437c0b29ed2f55513b984"
......
...@@ -64,5 +64,18 @@ ...@@ -64,5 +64,18 @@
], ],
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
},
{
"inputs": [],
"name": "version",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
} }
] ]
\ No newline at end of file
...@@ -796,6 +796,19 @@ ...@@ -796,6 +796,19 @@
"stateMutability": "nonpayable", "stateMutability": "nonpayable",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "version",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { ISemver } from "src/universal/ISemver.sol";
import { IPreimageOracle } from "./interfaces/IPreimageOracle.sol"; import { IPreimageOracle } from "./interfaces/IPreimageOracle.sol";
import { PreimageKeyLib } from "./PreimageKeyLib.sol"; import { PreimageKeyLib } from "./PreimageKeyLib.sol";
...@@ -19,7 +20,7 @@ import { PreimageKeyLib } from "./PreimageKeyLib.sol"; ...@@ -19,7 +20,7 @@ import { PreimageKeyLib } from "./PreimageKeyLib.sol";
/// @dev https://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats /// @dev https://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats
/// @dev https://github.com/golang/go/blob/master/src/syscall/zerrors_linux_mips.go /// @dev https://github.com/golang/go/blob/master/src/syscall/zerrors_linux_mips.go
/// MIPS linux kernel errors used by Go runtime /// MIPS linux kernel errors used by Go runtime
contract MIPS { contract MIPS is ISemver {
/// @notice Stores the VM state. /// @notice Stores the VM state.
/// Total state size: 32 + 32 + 6 * 4 + 1 + 1 + 8 + 32 * 4 = 226 bytes /// Total state size: 32 + 32 + 6 * 4 + 1 + 1 + 8 + 32 * 4 = 226 bytes
/// If nextPC != pc + 4, then the VM is executing a branch/jump delay slot. /// If nextPC != pc + 4, then the VM is executing a branch/jump delay slot.
...@@ -41,16 +42,20 @@ contract MIPS { ...@@ -41,16 +42,20 @@ contract MIPS {
/// @notice Start of the data segment. /// @notice Start of the data segment.
uint32 public constant BRK_START = 0x40000000; uint32 public constant BRK_START = 0x40000000;
uint32 constant FD_STDIN = 0; /// @notice The semantic version of the MIPS contract.
uint32 constant FD_STDOUT = 1; /// @custom:semver 0.1.0
uint32 constant FD_STDERR = 2; string public constant version = "0.1.0";
uint32 constant FD_HINT_READ = 3;
uint32 constant FD_HINT_WRITE = 4;
uint32 constant FD_PREIMAGE_READ = 5;
uint32 constant FD_PREIMAGE_WRITE = 6;
uint32 constant EBADF = 0x9; uint32 internal constant FD_STDIN = 0;
uint32 constant EINVAL = 0x16; uint32 internal constant FD_STDOUT = 1;
uint32 internal constant FD_STDERR = 2;
uint32 internal constant FD_HINT_READ = 3;
uint32 internal constant FD_HINT_WRITE = 4;
uint32 internal constant FD_PREIMAGE_READ = 5;
uint32 internal constant FD_PREIMAGE_WRITE = 6;
uint32 internal constant EBADF = 0x9;
uint32 internal constant EINVAL = 0x16;
/// @notice The preimage oracle contract. /// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE; IPreimageOracle internal immutable ORACLE;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
pragma solidity 0.8.15; pragma solidity 0.8.15;
import { IPreimageOracle } from "./interfaces/IPreimageOracle.sol"; import { IPreimageOracle } from "./interfaces/IPreimageOracle.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { PreimageKeyLib } from "./PreimageKeyLib.sol"; import { PreimageKeyLib } from "./PreimageKeyLib.sol";
import { LibKeccak } from "@lib-keccak/LibKeccak.sol"; import { LibKeccak } from "@lib-keccak/LibKeccak.sol";
import "src/cannon/libraries/CannonErrors.sol"; import "src/cannon/libraries/CannonErrors.sol";
...@@ -11,7 +12,7 @@ import "src/cannon/libraries/CannonTypes.sol"; ...@@ -11,7 +12,7 @@ import "src/cannon/libraries/CannonTypes.sol";
/// @notice A contract for storing permissioned pre-images. /// @notice A contract for storing permissioned pre-images.
/// @custom:attribution Solady <https://github.com/Vectorized/solady/blob/main/src/utils/MerkleProofLib.sol#L13-L43> /// @custom:attribution Solady <https://github.com/Vectorized/solady/blob/main/src/utils/MerkleProofLib.sol#L13-L43>
/// @custom:attribution Beacon Deposit Contract <0x00000000219ab540356cbb839cbe05303d7705fa> /// @custom:attribution Beacon Deposit Contract <0x00000000219ab540356cbb839cbe05303d7705fa>
contract PreimageOracle is IPreimageOracle { contract PreimageOracle is IPreimageOracle, ISemver {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Constants & Immutables // // Constants & Immutables //
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
...@@ -30,6 +31,10 @@ contract PreimageOracle is IPreimageOracle { ...@@ -30,6 +31,10 @@ contract PreimageOracle is IPreimageOracle {
/// @notice The maximum number of keccak blocks that can fit into the merkle tree. /// @notice The maximum number of keccak blocks that can fit into the merkle tree.
uint256 public constant MAX_LEAF_COUNT = 2 ** KECCAK_TREE_DEPTH - 1; uint256 public constant MAX_LEAF_COUNT = 2 ** KECCAK_TREE_DEPTH - 1;
/// @notice The semantic version of the Preimage Oracle contract.
/// @custom:semver 0.1.0
string public constant version = "0.1.0";
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Authorized Preimage Parts // // Authorized Preimage Parts //
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment