Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
a24e2e58
Unverified
Commit
a24e2e58
authored
Aug 08, 2023
by
inphi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ctb): make MIPS oracle addrs immutable
parent
d6dcb1f4
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
13 deletions
+25
-13
evm.go
cannon/mipsevm/evm.go
+10
-2
mips.go
op-bindings/bindings/mips.go
+5
-5
mips_more.go
op-bindings/bindings/mips_more.go
+3
-3
MIPS.sol
packages/contracts-bedrock/src/cannon/MIPS.sol
+7
-3
No files found.
cannon/mipsevm/evm.go
View file @
a24e2e58
...
@@ -112,9 +112,17 @@ func NewEVMEnv(contracts *Contracts, addrs *Addresses) (*vm.EVM, *state.StateDB)
...
@@ -112,9 +112,17 @@ func NewEVMEnv(contracts *Contracts, addrs *Addresses) (*vm.EVM, *state.StateDB)
env
:=
vm
.
NewEVM
(
blockContext
,
vm
.
TxContext
{},
state
,
chainCfg
,
vmCfg
)
env
:=
vm
.
NewEVM
(
blockContext
,
vm
.
TxContext
{},
state
,
chainCfg
,
vmCfg
)
// pre-deploy the contracts
// pre-deploy the contracts
env
.
StateDB
.
SetCode
(
addrs
.
MIPS
,
contracts
.
MIPS
.
DeployedBytecode
.
Object
)
env
.
StateDB
.
SetCode
(
addrs
.
Oracle
,
contracts
.
Oracle
.
DeployedBytecode
.
Object
)
env
.
StateDB
.
SetCode
(
addrs
.
Oracle
,
contracts
.
Oracle
.
DeployedBytecode
.
Object
)
env
.
StateDB
.
SetState
(
addrs
.
MIPS
,
common
.
Hash
{},
addrs
.
Oracle
.
Hash
())
var
mipsCtorArgs
[
32
]
byte
copy
(
mipsCtorArgs
[
12
:
],
addrs
.
Oracle
[
:
])
mipsDeploy
:=
append
(
hexutil
.
MustDecode
(
bindings
.
MIPSMetaData
.
Bin
),
mipsCtorArgs
[
:
]
...
)
startingGas
:=
uint64
(
30
_000_000
)
_
,
deployedMipsAddr
,
leftOverGas
,
err
:=
env
.
Create
(
vm
.
AccountRef
(
addrs
.
Sender
),
mipsDeploy
,
startingGas
,
big
.
NewInt
(
0
))
if
err
!=
nil
{
panic
(
fmt
.
Errorf
(
"failed to deploy MIPS contract: %w. took %d gas"
,
err
,
startingGas
-
leftOverGas
))
}
addrs
.
MIPS
=
deployedMipsAddr
rules
:=
env
.
ChainConfig
()
.
Rules
(
header
.
Number
,
true
,
header
.
Time
)
rules
:=
env
.
ChainConfig
()
.
Rules
(
header
.
Number
,
true
,
header
.
Time
)
env
.
StateDB
.
Prepare
(
rules
,
addrs
.
Sender
,
addrs
.
FeeRecipient
,
&
addrs
.
MIPS
,
vm
.
ActivePrecompiles
(
rules
),
nil
)
env
.
StateDB
.
Prepare
(
rules
,
addrs
.
Sender
,
addrs
.
FeeRecipient
,
&
addrs
.
MIPS
,
vm
.
ActivePrecompiles
(
rules
),
nil
)
...
...
op-bindings/bindings/mips.go
View file @
a24e2e58
This diff is collapsed.
Click to expand it.
op-bindings/bindings/mips_more.go
View file @
a24e2e58
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/src/cannon/MIPS.sol
View file @
a24e2e58
...
@@ -53,11 +53,15 @@ contract MIPS {
...
@@ -53,11 +53,15 @@ contract MIPS {
uint32 constant EINVAL = 0x16;
uint32 constant EINVAL = 0x16;
/// @notice The preimage oracle contract.
/// @notice The preimage oracle contract.
IPreimageOracle
public oracle
;
IPreimageOracle
internal immutable ORACLE
;
/// @param _oracle The address of the preimage oracle contract.
/// @param _oracle The address of the preimage oracle contract.
constructor(IPreimageOracle _oracle) {
constructor(IPreimageOracle _oracle) {
oracle = _oracle;
ORACLE = _oracle;
}
function oracle() external view returns (IPreimageOracle oracle_) {
oracle_ = ORACLE;
}
}
/// @notice Extends the value leftwards with its most significant bit (sign extension).
/// @notice Extends the value leftwards with its most significant bit (sign extension).
...
@@ -179,7 +183,7 @@ contract MIPS {
...
@@ -179,7 +183,7 @@ contract MIPS {
if (uint8(preimageKey[0]) == 1) {
if (uint8(preimageKey[0]) == 1) {
preimageKey = PreimageKeyLib.localize(preimageKey);
preimageKey = PreimageKeyLib.localize(preimageKey);
}
}
(bytes32 dat, uint256 datLen) =
oracle
.readPreimage(preimageKey, state.preimageOffset);
(bytes32 dat, uint256 datLen) =
ORACLE
.readPreimage(preimageKey, state.preimageOffset);
// Transform data for writing to memory
// Transform data for writing to memory
// We use assembly for more precise ops, and no var count limit
// We use assembly for more precise ops, and no var count limit
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment