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
070f68df
Unverified
Commit
070f68df
authored
Aug 20, 2021
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: add support for message passing again
parent
e03dcead
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
136 additions
and
181 deletions
+136
-181
basic-l1-l2-communication.spec.ts
integration-tests/test/basic-l1-l2-communication.spec.ts
+3
-37
fee-payment.spec.ts
integration-tests/test/fee-payment.spec.ts
+1
-1
native-eth-ovm-calls.spec.ts
integration-tests/test/native-eth-ovm-calls.spec.ts
+1
-1
native-eth.spec.ts
integration-tests/test/native-eth.spec.ts
+1
-1
ovmcontext.spec.ts
integration-tests/test/ovmcontext.spec.ts
+1
-2
queue-ingestion.spec.ts
integration-tests/test/queue-ingestion.spec.ts
+1
-2
simulated.go
l2geth/accounts/abi/bind/backends/simulated.go
+2
-1
evm.go
l2geth/core/evm.go
+41
-11
state_processor.go
l2geth/core/state_processor.go
+0
-9
state_transition.go
l2geth/core/state_transition.go
+3
-1
transaction.go
l2geth/core/types/transaction.go
+8
-4
evm.go
l2geth/core/vm/evm.go
+3
-0
instructions.go
l2geth/core/vm/instructions.go
+6
-0
jump_table.go
l2geth/core/vm/jump_table.go
+7
-0
opcodes.go
l2geth/core/vm/opcodes.go
+9
-0
interfaces.go
l2geth/interfaces.go
+2
-1
api.go
l2geth/internal/ethapi/api.go
+3
-8
odr_test.go
l2geth/les/odr_test.go
+2
-2
odr_test.go
l2geth/light/odr_test.go
+1
-1
state_test_util.go
l2geth/tests/state_test_util.go
+1
-1
OVM_L2CrossDomainMessenger.sol
...ereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol
+1
-1
OVM_ExecutionManagerWrapper.sol
...c-ethereum/OVM/predeploys/OVM_ExecutionManagerWrapper.sol
+1
-18
OVM_L1MessageSender.sol
...ptimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol
+19
-23
iOVM_L1MessageSender.sol
...imistic-ethereum/iOVM/predeploys/iOVM_L1MessageSender.sol
+1
-1
contract-data.ts
packages/contracts/src/contract-data.ts
+1
-1
config.ts
packages/contracts/src/contract-deployment/config.ts
+5
-9
make-dump.ts
packages/contracts/src/state-dump/make-dump.ts
+5
-41
OVM_L2CrossDomainMessenger.spec.ts
...tracts/OVM/bridge/base/OVM_L2CrossDomainMessenger.spec.ts
+3
-2
OVM_L1MessageSender.spec.ts
...test/contracts/OVM/predeploys/OVM_L1MessageSender.spec.ts
+2
-1
OVM_L2ToL1MessagePasser.spec.ts
.../contracts/OVM/predeploys/OVM_L2ToL1MessagePasser.spec.ts
+2
-1
No files found.
integration-tests/test/basic-l1-l2-communication.spec.ts
View file @
070f68df
...
@@ -10,8 +10,7 @@ import l2ReverterJson from '../artifacts/contracts/Reverter.sol/Reverter.json'
...
@@ -10,8 +10,7 @@ import l2ReverterJson from '../artifacts/contracts/Reverter.sol/Reverter.json'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
OptimismEnv
,
useDynamicTimeoutForWithdrawals
}
from
'
./shared/env
'
import
{
OptimismEnv
,
useDynamicTimeoutForWithdrawals
}
from
'
./shared/env
'
// SKIP: needs message passing PR
describe
(
'
Basic L1<>L2 Communication
'
,
async
()
=>
{
describe
.
skip
(
'
Basic L1<>L2 Communication
'
,
async
()
=>
{
let
Factory__L1SimpleStorage
:
ContractFactory
let
Factory__L1SimpleStorage
:
ContractFactory
let
Factory__L2SimpleStorage
:
ContractFactory
let
Factory__L2SimpleStorage
:
ContractFactory
let
Factory__L2Reverter
:
ContractFactory
let
Factory__L2Reverter
:
ContractFactory
...
@@ -116,7 +115,8 @@ describe.skip('Basic L1<>L2 Communication', async () => {
...
@@ -116,7 +115,8 @@ describe.skip('Basic L1<>L2 Communication', async () => {
expect
(
remoteReceipt
.
status
).
to
.
equal
(
1
)
expect
(
remoteReceipt
.
status
).
to
.
equal
(
1
)
})
})
it
(
'
should have a receipt with a status of 0 for a failed message
'
,
async
()
=>
{
// SKIP: until we decide what should be done in this case
it
.
skip
(
'
should have a receipt with a status of 0 for a failed message
'
,
async
()
=>
{
// Send L1 -> L2 message.
// Send L1 -> L2 message.
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
L2Reverter
.
address
,
L2Reverter
.
address
,
...
@@ -131,39 +131,5 @@ describe.skip('Basic L1<>L2 Communication', async () => {
...
@@ -131,39 +131,5 @@ describe.skip('Basic L1<>L2 Communication', async () => {
expect
(
remoteReceipt
.
status
).
to
.
equal
(
0
)
expect
(
remoteReceipt
.
status
).
to
.
equal
(
0
)
})
})
it
(
'
should have a receipt with a status of 0 for messages sent to 0x42... addresses
'
,
async
()
=>
{
// This call is fine but will give a status of 0.
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
predeploys
.
Lib_AddressManager
,
getContractInterface
(
'
Lib_AddressManager
'
).
encodeFunctionData
(
'
getAddress
'
,
[
'
whatever
'
]
),
5000000
)
const
{
remoteReceipt
}
=
await
env
.
waitForXDomainTransaction
(
transaction
,
Direction
.
L1ToL2
)
expect
(
remoteReceipt
.
status
).
to
.
equal
(
0
)
})
it
(
'
should have a receipt with a status of 0 for messages sent to 0xdead... addresses
'
,
async
()
=>
{
const
transaction
=
await
env
.
l1Messenger
.
sendMessage
(
'
0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000
'
,
'
0x
'
,
5000000
)
const
{
remoteReceipt
}
=
await
env
.
waitForXDomainTransaction
(
transaction
,
Direction
.
L1ToL2
)
expect
(
remoteReceipt
.
status
).
to
.
equal
(
0
)
})
})
})
})
})
integration-tests/test/fee-payment.spec.ts
View file @
070f68df
...
@@ -12,7 +12,7 @@ import { IS_LIVE_NETWORK } from './shared/utils'
...
@@ -12,7 +12,7 @@ import { IS_LIVE_NETWORK } from './shared/utils'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
// SKIP:
needs message passing
PR
// SKIP:
ETH value
PR
describe
.
skip
(
'
Fee Payment Integration Tests
'
,
async
()
=>
{
describe
.
skip
(
'
Fee Payment Integration Tests
'
,
async
()
=>
{
let
env
:
OptimismEnv
let
env
:
OptimismEnv
before
(
async
()
=>
{
before
(
async
()
=>
{
...
...
integration-tests/test/native-eth-ovm-calls.spec.ts
View file @
070f68df
...
@@ -13,7 +13,7 @@ import { Interface } from 'ethers/lib/utils'
...
@@ -13,7 +13,7 @@ import { Interface } from 'ethers/lib/utils'
chai
.
use
(
solidity
)
chai
.
use
(
solidity
)
// SKIP:
needs message passing
PR
// SKIP:
ETH value
PR
describe
.
skip
(
'
Native ETH value integration tests
'
,
()
=>
{
describe
.
skip
(
'
Native ETH value integration tests
'
,
()
=>
{
let
env
:
OptimismEnv
let
env
:
OptimismEnv
let
wallet
:
Wallet
let
wallet
:
Wallet
...
...
integration-tests/test/native-eth.spec.ts
View file @
070f68df
...
@@ -19,7 +19,7 @@ const DEFAULT_TEST_GAS_L2 = 1_300_000
...
@@ -19,7 +19,7 @@ const DEFAULT_TEST_GAS_L2 = 1_300_000
// TX size enforced by CTC:
// TX size enforced by CTC:
const
MAX_ROLLUP_TX_SIZE
=
50
_000
const
MAX_ROLLUP_TX_SIZE
=
50
_000
// SKIP:
needs message passing
PR
// SKIP:
ETH value
PR
describe
.
skip
(
'
Native ETH Integration Tests
'
,
async
()
=>
{
describe
.
skip
(
'
Native ETH Integration Tests
'
,
async
()
=>
{
let
env
:
OptimismEnv
let
env
:
OptimismEnv
let
l1Bob
:
Wallet
let
l1Bob
:
Wallet
...
...
integration-tests/test/ovmcontext.spec.ts
View file @
070f68df
...
@@ -15,8 +15,7 @@ import { Direction } from './shared/watcher-utils'
...
@@ -15,8 +15,7 @@ import { Direction } from './shared/watcher-utils'
* of a L1 to L2 transaction, both `block.number` and `block.timestamp`
* of a L1 to L2 transaction, both `block.number` and `block.timestamp`
* must be equal to the blocknumber/timestamp of the L1 transaction.
* must be equal to the blocknumber/timestamp of the L1 transaction.
*/
*/
// SKIP: needs message passing PR
describe
(
'
OVM Context: Layer 2 EVM Context
'
,
()
=>
{
describe
.
skip
(
'
OVM Context: Layer 2 EVM Context
'
,
()
=>
{
const
L2Provider
=
injectL2Context
(
l2Provider
)
const
L2Provider
=
injectL2Context
(
l2Provider
)
let
env
:
OptimismEnv
let
env
:
OptimismEnv
before
(
async
()
=>
{
before
(
async
()
=>
{
...
...
integration-tests/test/queue-ingestion.spec.ts
View file @
070f68df
...
@@ -8,8 +8,7 @@ import { injectL2Context } from '@eth-optimism/core-utils'
...
@@ -8,8 +8,7 @@ import { injectL2Context } from '@eth-optimism/core-utils'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
OptimismEnv
}
from
'
./shared/env
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
import
{
Direction
}
from
'
./shared/watcher-utils
'
// SKIP: needs message passing PR
describe
(
'
Queue Ingestion
'
,
()
=>
{
describe
.
skip
(
'
Queue Ingestion
'
,
()
=>
{
let
env
:
OptimismEnv
let
env
:
OptimismEnv
let
l2Provider
:
providers
.
JsonRpcProvider
let
l2Provider
:
providers
.
JsonRpcProvider
before
(
async
()
=>
{
before
(
async
()
=>
{
...
...
l2geth/accounts/abi/bind/backends/simulated.go
View file @
070f68df
...
@@ -603,8 +603,9 @@ func (m callmsg) Data() []byte { return m.CallMsg.Data }
...
@@ -603,8 +603,9 @@ func (m callmsg) Data() []byte { return m.CallMsg.Data }
// UsingOVM
// UsingOVM
// These getters return OVM specific fields
// These getters return OVM specific fields
func
(
m
callmsg
)
L1
MessageSender
()
*
common
.
Address
{
return
m
.
CallMsg
.
L1MessageSender
}
func
(
m
callmsg
)
L1
Timestamp
()
uint64
{
return
m
.
CallMsg
.
L1Timestamp
}
func
(
m
callmsg
)
L1BlockNumber
()
*
big
.
Int
{
return
m
.
CallMsg
.
L1BlockNumber
}
func
(
m
callmsg
)
L1BlockNumber
()
*
big
.
Int
{
return
m
.
CallMsg
.
L1BlockNumber
}
func
(
m
callmsg
)
L1MessageSender
()
*
common
.
Address
{
return
m
.
CallMsg
.
L1MessageSender
}
func
(
m
callmsg
)
QueueOrigin
()
types
.
QueueOrigin
{
return
m
.
CallMsg
.
QueueOrigin
}
func
(
m
callmsg
)
QueueOrigin
()
types
.
QueueOrigin
{
return
m
.
CallMsg
.
QueueOrigin
}
// filterBackend implements filters.Backend to support filtering for logs without
// filterBackend implements filters.Backend to support filtering for logs without
...
...
l2geth/core/evm.go
View file @
070f68df
...
@@ -25,6 +25,10 @@ import (
...
@@ -25,6 +25,10 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm"
)
)
// DefaultL1MessageSender is the default L1MessageSender value attached to a transaction that is
// not an L1 to L2 message.
var
DefaultL1MessageSender
=
common
.
HexToAddress
(
"0x00000000000000000000000000000000000beef"
)
// ChainContext supports retrieving headers and consensus parameters from the
// ChainContext supports retrieving headers and consensus parameters from the
// current blockchain to be used during transaction processing.
// current blockchain to be used during transaction processing.
type
ChainContext
interface
{
type
ChainContext
interface
{
...
@@ -44,17 +48,43 @@ func NewEVMContext(msg Message, header *types.Header, chain ChainContext, author
...
@@ -44,17 +48,43 @@ func NewEVMContext(msg Message, header *types.Header, chain ChainContext, author
}
else
{
}
else
{
beneficiary
=
*
author
beneficiary
=
*
author
}
}
return
vm
.
Context
{
if
vm
.
UsingOVM
{
CanTransfer
:
CanTransfer
,
// When using the OVM, we must:
Transfer
:
Transfer
,
// (1) Attach the L1MessageSender context value and
GetHash
:
GetHashFn
(
header
,
chain
),
// (2) Set the BlockNumber to be the msg.L1BlockNumber
Origin
:
msg
.
From
(),
// (3) Set the Time to be the msg.L1Timestamp
Coinbase
:
beneficiary
,
var
l1MessageSender
common
.
Address
BlockNumber
:
new
(
big
.
Int
)
.
Set
(
header
.
Number
),
if
msg
.
L1MessageSender
()
==
nil
{
Time
:
new
(
big
.
Int
)
.
SetUint64
(
header
.
Time
),
l1MessageSender
=
DefaultL1MessageSender
Difficulty
:
new
(
big
.
Int
)
.
Set
(
header
.
Difficulty
),
}
else
{
GasLimit
:
header
.
GasLimit
,
l1MessageSender
=
*
msg
.
L1MessageSender
()
GasPrice
:
new
(
big
.
Int
)
.
Set
(
msg
.
GasPrice
()),
}
return
vm
.
Context
{
CanTransfer
:
CanTransfer
,
Transfer
:
Transfer
,
GetHash
:
GetHashFn
(
header
,
chain
),
Origin
:
msg
.
From
(),
Coinbase
:
beneficiary
,
BlockNumber
:
msg
.
L1BlockNumber
(),
Time
:
new
(
big
.
Int
)
.
SetUint64
(
msg
.
L1Timestamp
()),
Difficulty
:
new
(
big
.
Int
)
.
Set
(
header
.
Difficulty
),
GasLimit
:
header
.
GasLimit
,
GasPrice
:
new
(
big
.
Int
)
.
Set
(
msg
.
GasPrice
()),
L1MessageSender
:
l1MessageSender
,
}
}
else
{
return
vm
.
Context
{
CanTransfer
:
CanTransfer
,
Transfer
:
Transfer
,
GetHash
:
GetHashFn
(
header
,
chain
),
Origin
:
msg
.
From
(),
Coinbase
:
beneficiary
,
BlockNumber
:
new
(
big
.
Int
)
.
Set
(
header
.
Number
),
Time
:
new
(
big
.
Int
)
.
SetUint64
(
header
.
Time
),
Difficulty
:
new
(
big
.
Int
)
.
Set
(
header
.
Difficulty
),
GasLimit
:
header
.
GasLimit
,
GasPrice
:
new
(
big
.
Int
)
.
Set
(
msg
.
GasPrice
()),
}
}
}
}
}
...
...
l2geth/core/state_processor.go
View file @
070f68df
...
@@ -103,15 +103,6 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
...
@@ -103,15 +103,6 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
}
}
// Create a new context to be used in the EVM environment
// Create a new context to be used in the EVM environment
context
:=
NewEVMContext
(
msg
,
header
,
bc
,
author
)
context
:=
NewEVMContext
(
msg
,
header
,
bc
,
author
)
if
vm
.
UsingOVM
{
// The `NUMBER` opcode returns the L1 blocknumber instead of the L2
// blocknumber, so set that here. In the future, this should be
// implemented by adding a new property to the EVM struct
// `L1BlockNumber` and updating `opNumber` to return that. This
// will help with keeping the difference in behavior maintainable over
// time
context
.
BlockNumber
=
msg
.
L1BlockNumber
()
}
// Create a new environment which holds all relevant information
// Create a new environment which holds all relevant information
// about the transaction and calling mechanisms.
// about the transaction and calling mechanisms.
vmenv
:=
vm
.
NewEVM
(
context
,
statedb
,
config
,
cfg
)
vmenv
:=
vm
.
NewEVM
(
context
,
statedb
,
config
,
cfg
)
...
...
l2geth/core/state_transition.go
View file @
070f68df
...
@@ -75,8 +75,10 @@ type Message interface {
...
@@ -75,8 +75,10 @@ type Message interface {
Nonce
()
uint64
Nonce
()
uint64
CheckNonce
()
bool
CheckNonce
()
bool
Data
()
[]
byte
Data
()
[]
byte
L1MessageSender
()
*
common
.
Address
L1Timestamp
()
uint64
L1BlockNumber
()
*
big
.
Int
L1BlockNumber
()
*
big
.
Int
L1MessageSender
()
*
common
.
Address
QueueOrigin
()
types
.
QueueOrigin
QueueOrigin
()
types
.
QueueOrigin
}
}
...
...
l2geth/core/types/transaction.go
View file @
070f68df
...
@@ -298,8 +298,9 @@ func (tx *Transaction) AsMessage(s Signer) (Message, error) {
...
@@ -298,8 +298,9 @@ func (tx *Transaction) AsMessage(s Signer) (Message, error) {
data
:
tx
.
data
.
Payload
,
data
:
tx
.
data
.
Payload
,
checkNonce
:
true
,
checkNonce
:
true
,
l1
MessageSender
:
tx
.
meta
.
L1MessageSender
,
l1
Timestamp
:
tx
.
meta
.
L1Timestamp
,
l1BlockNumber
:
tx
.
meta
.
L1BlockNumber
,
l1BlockNumber
:
tx
.
meta
.
L1BlockNumber
,
l1MessageSender
:
tx
.
meta
.
L1MessageSender
,
queueOrigin
:
tx
.
meta
.
QueueOrigin
,
queueOrigin
:
tx
.
meta
.
QueueOrigin
,
}
}
...
@@ -481,12 +482,13 @@ type Message struct {
...
@@ -481,12 +482,13 @@ type Message struct {
data
[]
byte
data
[]
byte
checkNonce
bool
checkNonce
bool
l1
MessageSender
*
common
.
Address
l1
Timestamp
uint64
l1BlockNumber
*
big
.
Int
l1BlockNumber
*
big
.
Int
l1MessageSender
*
common
.
Address
queueOrigin
QueueOrigin
queueOrigin
QueueOrigin
}
}
func
NewMessage
(
from
common
.
Address
,
to
*
common
.
Address
,
nonce
uint64
,
amount
*
big
.
Int
,
gasLimit
uint64
,
gasPrice
*
big
.
Int
,
data
[]
byte
,
checkNonce
bool
,
l1MessageSender
*
common
.
Address
,
l1BlockNumber
*
big
.
Int
,
queueOrigin
QueueOrigin
)
Message
{
func
NewMessage
(
from
common
.
Address
,
to
*
common
.
Address
,
nonce
uint64
,
amount
*
big
.
Int
,
gasLimit
uint64
,
gasPrice
*
big
.
Int
,
data
[]
byte
,
checkNonce
bool
,
l1MessageSender
*
common
.
Address
,
l1BlockNumber
*
big
.
Int
,
l1Timestamp
uint64
,
queueOrigin
QueueOrigin
)
Message
{
return
Message
{
return
Message
{
from
:
from
,
from
:
from
,
to
:
to
,
to
:
to
,
...
@@ -497,6 +499,7 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b
...
@@ -497,6 +499,7 @@ func NewMessage(from common.Address, to *common.Address, nonce uint64, amount *b
data
:
data
,
data
:
data
,
checkNonce
:
checkNonce
,
checkNonce
:
checkNonce
,
l1Timestamp
:
l1Timestamp
,
l1BlockNumber
:
l1BlockNumber
,
l1BlockNumber
:
l1BlockNumber
,
l1MessageSender
:
l1MessageSender
,
l1MessageSender
:
l1MessageSender
,
queueOrigin
:
queueOrigin
,
queueOrigin
:
queueOrigin
,
...
@@ -512,6 +515,7 @@ func (m Message) Nonce() uint64 { return m.nonce }
...
@@ -512,6 +515,7 @@ func (m Message) Nonce() uint64 { return m.nonce }
func
(
m
Message
)
Data
()
[]
byte
{
return
m
.
data
}
func
(
m
Message
)
Data
()
[]
byte
{
return
m
.
data
}
func
(
m
Message
)
CheckNonce
()
bool
{
return
m
.
checkNonce
}
func
(
m
Message
)
CheckNonce
()
bool
{
return
m
.
checkNonce
}
func
(
m
Message
)
L1
MessageSender
()
*
common
.
Address
{
return
m
.
l1MessageSender
}
func
(
m
Message
)
L1
Timestamp
()
uint64
{
return
m
.
l1Timestamp
}
func
(
m
Message
)
L1BlockNumber
()
*
big
.
Int
{
return
m
.
l1BlockNumber
}
func
(
m
Message
)
L1BlockNumber
()
*
big
.
Int
{
return
m
.
l1BlockNumber
}
func
(
m
Message
)
L1MessageSender
()
*
common
.
Address
{
return
m
.
l1MessageSender
}
func
(
m
Message
)
QueueOrigin
()
QueueOrigin
{
return
m
.
queueOrigin
}
func
(
m
Message
)
QueueOrigin
()
QueueOrigin
{
return
m
.
queueOrigin
}
l2geth/core/vm/evm.go
View file @
070f68df
...
@@ -112,6 +112,9 @@ type Context struct {
...
@@ -112,6 +112,9 @@ type Context struct {
BlockNumber
*
big
.
Int
// Provides information for NUMBER
BlockNumber
*
big
.
Int
// Provides information for NUMBER
Time
*
big
.
Int
// Provides information for TIME
Time
*
big
.
Int
// Provides information for TIME
Difficulty
*
big
.
Int
// Provides information for DIFFICULTY
Difficulty
*
big
.
Int
// Provides information for DIFFICULTY
// OVM information
L1MessageSender
common
.
Address
// Provides information for L1MESSAGESENDER
}
}
// EVM is the Ethereum Virtual Machine base object and provides
// EVM is the Ethereum Virtual Machine base object and provides
...
...
l2geth/core/vm/instructions.go
View file @
070f68df
...
@@ -967,3 +967,9 @@ func makeSwap(size int64) executionFunc {
...
@@ -967,3 +967,9 @@ func makeSwap(size int64) executionFunc {
return
nil
,
nil
return
nil
,
nil
}
}
}
}
// OVM opcodes
func
opL1MessageSender
(
pc
*
uint64
,
interpreter
*
EVMInterpreter
,
contract
*
Contract
,
memory
*
Memory
,
stack
*
Stack
)
([]
byte
,
error
)
{
stack
.
push
(
interpreter
.
intPool
.
get
()
.
SetBytes
(
interpreter
.
evm
.
L1MessageSender
.
Bytes
()))
return
nil
,
nil
}
l2geth/core/vm/jump_table.go
View file @
070f68df
...
@@ -1155,5 +1155,12 @@ func newFrontierInstructionSet() JumpTable {
...
@@ -1155,5 +1155,12 @@ func newFrontierInstructionSet() JumpTable {
valid
:
true
,
valid
:
true
,
writes
:
true
,
writes
:
true
,
},
},
L1MESSAGESENDER
:
{
execute
:
opL1MessageSender
,
constantGas
:
GasQuickStep
,
minStack
:
minStack
(
0
,
1
),
maxStack
:
maxStack
(
0
,
1
),
valid
:
true
,
},
}
}
}
}
l2geth/core/vm/opcodes.go
View file @
070f68df
...
@@ -103,6 +103,8 @@ const (
...
@@ -103,6 +103,8 @@ const (
GASLIMIT
GASLIMIT
CHAINID
=
0x46
CHAINID
=
0x46
SELFBALANCE
=
0x47
SELFBALANCE
=
0x47
L1MESSAGESENDER
=
0x4A
)
)
// 0x50 range - 'storage' and execution.
// 0x50 range - 'storage' and execution.
...
@@ -282,6 +284,10 @@ var opCodeToString = map[OpCode]string{
...
@@ -282,6 +284,10 @@ var opCodeToString = map[OpCode]string{
CHAINID
:
"CHAINID"
,
CHAINID
:
"CHAINID"
,
SELFBALANCE
:
"SELFBALANCE"
,
SELFBALANCE
:
"SELFBALANCE"
,
// OVM opcodes
// 0x4A
L1MESSAGESENDER
:
"L1MESSAGESENDER"
,
// 0x50 range - 'storage' and execution.
// 0x50 range - 'storage' and execution.
POP
:
"POP"
,
POP
:
"POP"
,
//DUP: "DUP",
//DUP: "DUP",
...
@@ -538,6 +544,9 @@ var stringToOp = map[string]OpCode{
...
@@ -538,6 +544,9 @@ var stringToOp = map[string]OpCode{
"CALLCODE"
:
CALLCODE
,
"CALLCODE"
:
CALLCODE
,
"REVERT"
:
REVERT
,
"REVERT"
:
REVERT
,
"SELFDESTRUCT"
:
SELFDESTRUCT
,
"SELFDESTRUCT"
:
SELFDESTRUCT
,
// OVM opcodes
"L1MESSAGESENDER"
:
L1MESSAGESENDER
,
}
}
// StringToOp finds the opcode whose name is stored in `str`.
// StringToOp finds the opcode whose name is stored in `str`.
...
...
l2geth/interfaces.go
View file @
070f68df
...
@@ -120,8 +120,9 @@ type CallMsg struct {
...
@@ -120,8 +120,9 @@ type CallMsg struct {
Value
*
big
.
Int
// amount of wei sent along with the call
Value
*
big
.
Int
// amount of wei sent along with the call
Data
[]
byte
// input data, usually an ABI-encoded contract method invocation
Data
[]
byte
// input data, usually an ABI-encoded contract method invocation
L1
MessageSender
*
common
.
Address
L1
Timestamp
uint64
L1BlockNumber
*
big
.
Int
L1BlockNumber
*
big
.
Int
L1MessageSender
*
common
.
Address
QueueOrigin
types
.
QueueOrigin
QueueOrigin
types
.
QueueOrigin
}
}
...
...
l2geth/internal/ethapi/api.go
View file @
070f68df
...
@@ -867,7 +867,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
...
@@ -867,7 +867,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
// attached to each transaction. We need to modify the blocknumber and timestamp to reflect this,
// attached to each transaction. We need to modify the blocknumber and timestamp to reflect this,
// or else the result of `eth_call` will not be correct.
// or else the result of `eth_call` will not be correct.
blockNumber
:=
header
.
Number
blockNumber
:=
header
.
Number
timestamp
:=
new
(
big
.
Int
)
.
SetUint64
(
header
.
Time
)
timestamp
:=
header
.
Time
if
vm
.
UsingOVM
{
if
vm
.
UsingOVM
{
block
,
err
:=
b
.
BlockByNumber
(
ctx
,
rpc
.
BlockNumber
(
header
.
Number
.
Uint64
()))
block
,
err
:=
b
.
BlockByNumber
(
ctx
,
rpc
.
BlockNumber
(
header
.
Number
.
Uint64
()))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -881,13 +881,13 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
...
@@ -881,13 +881,13 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
}
}
tx
:=
txs
[
0
]
tx
:=
txs
[
0
]
blockNumber
=
tx
.
L1BlockNumber
()
blockNumber
=
tx
.
L1BlockNumber
()
timestamp
=
new
(
big
.
Int
)
.
SetUint64
(
tx
.
L1Timestamp
()
)
timestamp
=
tx
.
L1Timestamp
(
)
}
}
}
}
}
}
// Create new call message
// Create new call message
msg
:=
types
.
NewMessage
(
addr
,
args
.
To
,
0
,
value
,
gas
,
gasPrice
,
data
,
false
,
&
addr
,
nil
,
types
.
QueueOriginSequencer
)
msg
:=
types
.
NewMessage
(
addr
,
args
.
To
,
0
,
value
,
gas
,
gasPrice
,
data
,
false
,
&
addr
,
blockNumber
,
timestamp
,
types
.
QueueOriginSequencer
)
// Setup context so it may be cancelled the call has completed
// Setup context so it may be cancelled the call has completed
// or, in case of unmetered gas, setup a context with a timeout.
// or, in case of unmetered gas, setup a context with a timeout.
...
@@ -916,11 +916,6 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
...
@@ -916,11 +916,6 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
// Setup the gas pool (also for unmetered requests)
// Setup the gas pool (also for unmetered requests)
// and apply the message.
// and apply the message.
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
// Modify the blocknumber and timestamp based on the L1BlockNumber and L1Timestamp from above.
if
vm
.
UsingOVM
{
evm
.
Context
.
BlockNumber
=
blockNumber
evm
.
Context
.
Time
=
timestamp
}
res
,
gas
,
failed
,
err
:=
core
.
ApplyMessage
(
evm
,
msg
,
gp
)
res
,
gas
,
failed
,
err
:=
core
.
ApplyMessage
(
evm
,
msg
,
gp
)
if
err
:=
vmError
();
err
!=
nil
{
if
err
:=
vmError
();
err
!=
nil
{
return
nil
,
0
,
false
,
err
return
nil
,
0
,
false
,
err
...
...
l2geth/les/odr_test.go
View file @
070f68df
...
@@ -128,7 +128,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
...
@@ -128,7 +128,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
from
:=
statedb
.
GetOrNewStateObject
(
bankAddr
)
from
:=
statedb
.
GetOrNewStateObject
(
bankAddr
)
from
.
SetBalance
(
math
.
MaxBig256
)
from
.
SetBalance
(
math
.
MaxBig256
)
msg
:=
callmsg
{
types
.
NewMessage
(
from
.
Address
(),
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
new
(
big
.
Int
),
data
,
false
,
nil
,
nil
,
types
.
QueueOriginSequencer
)}
msg
:=
callmsg
{
types
.
NewMessage
(
from
.
Address
(),
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
new
(
big
.
Int
),
data
,
false
,
nil
,
nil
,
0
,
types
.
QueueOriginSequencer
)}
context
:=
core
.
NewEVMContext
(
msg
,
header
,
bc
,
nil
)
context
:=
core
.
NewEVMContext
(
msg
,
header
,
bc
,
nil
)
vmenv
:=
vm
.
NewEVM
(
context
,
statedb
,
config
,
vm
.
Config
{})
vmenv
:=
vm
.
NewEVM
(
context
,
statedb
,
config
,
vm
.
Config
{})
...
@@ -142,7 +142,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
...
@@ -142,7 +142,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
header
:=
lc
.
GetHeaderByHash
(
bhash
)
header
:=
lc
.
GetHeaderByHash
(
bhash
)
state
:=
light
.
NewState
(
ctx
,
header
,
lc
.
Odr
())
state
:=
light
.
NewState
(
ctx
,
header
,
lc
.
Odr
())
state
.
SetBalance
(
bankAddr
,
math
.
MaxBig256
)
state
.
SetBalance
(
bankAddr
,
math
.
MaxBig256
)
msg
:=
callmsg
{
types
.
NewMessage
(
bankAddr
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
new
(
big
.
Int
),
data
,
false
,
nil
,
nil
,
types
.
QueueOriginSequencer
)}
msg
:=
callmsg
{
types
.
NewMessage
(
bankAddr
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
100000
,
new
(
big
.
Int
),
data
,
false
,
nil
,
nil
,
0
,
types
.
QueueOriginSequencer
)}
context
:=
core
.
NewEVMContext
(
msg
,
header
,
lc
,
nil
)
context
:=
core
.
NewEVMContext
(
msg
,
header
,
lc
,
nil
)
vmenv
:=
vm
.
NewEVM
(
context
,
state
,
config
,
vm
.
Config
{})
vmenv
:=
vm
.
NewEVM
(
context
,
state
,
config
,
vm
.
Config
{})
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
...
...
l2geth/light/odr_test.go
View file @
070f68df
...
@@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
...
@@ -194,7 +194,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
// Perform read-only call.
// Perform read-only call.
st
.
SetBalance
(
testBankAddress
,
math
.
MaxBig256
)
st
.
SetBalance
(
testBankAddress
,
math
.
MaxBig256
)
msg
:=
callmsg
{
types
.
NewMessage
(
testBankAddress
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
1000000
,
new
(
big
.
Int
),
data
,
false
,
nil
,
nil
,
types
.
QueueOriginSequencer
)}
msg
:=
callmsg
{
types
.
NewMessage
(
testBankAddress
,
&
testContractAddr
,
0
,
new
(
big
.
Int
),
1000000
,
new
(
big
.
Int
),
data
,
false
,
nil
,
nil
,
0
,
types
.
QueueOriginSequencer
)}
context
:=
core
.
NewEVMContext
(
msg
,
header
,
chain
,
nil
)
context
:=
core
.
NewEVMContext
(
msg
,
header
,
chain
,
nil
)
vmenv
:=
vm
.
NewEVM
(
context
,
st
,
config
,
vm
.
Config
{})
vmenv
:=
vm
.
NewEVM
(
context
,
st
,
config
,
vm
.
Config
{})
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
gp
:=
new
(
core
.
GasPool
)
.
AddGas
(
math
.
MaxUint64
)
...
...
l2geth/tests/state_test_util.go
View file @
070f68df
...
@@ -279,7 +279,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
...
@@ -279,7 +279,7 @@ func (tx *stTransaction) toMessage(ps stPostState) (core.Message, error) {
return
nil
,
fmt
.
Errorf
(
"invalid tx data %q"
,
dataHex
)
return
nil
,
fmt
.
Errorf
(
"invalid tx data %q"
,
dataHex
)
}
}
msg
:=
types
.
NewMessage
(
from
,
to
,
tx
.
Nonce
,
value
,
gasLimit
,
tx
.
GasPrice
,
data
,
true
,
nil
,
nil
,
types
.
QueueOriginSequencer
)
msg
:=
types
.
NewMessage
(
from
,
to
,
tx
.
Nonce
,
value
,
gasLimit
,
tx
.
GasPrice
,
data
,
true
,
nil
,
nil
,
0
,
types
.
QueueOriginSequencer
)
return
msg
,
nil
return
msg
,
nil
}
}
...
...
packages/contracts/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol
View file @
070f68df
...
@@ -185,8 +185,8 @@ contract OVM_L2CrossDomainMessenger is
...
@@ -185,8 +185,8 @@ contract OVM_L2CrossDomainMessenger is
* @return _valid Whether or not the message is valid.
* @return _valid Whether or not the message is valid.
*/
*/
function _verifyXDomainMessage()
function _verifyXDomainMessage()
view
internal
internal
view
returns (
returns (
bool _valid
bool _valid
)
)
...
...
packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_ExecutionManagerWrapper.sol
View file @
070f68df
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
// @unsupported: evm
pragma solidity >0.5.0 <0.8.0;
pragma solidity >0.5.0 <0.8.0;
/* Library Imports */
/* Library Imports */
...
@@ -24,22 +23,6 @@ contract OVM_ExecutionManagerWrapper {
...
@@ -24,22 +23,6 @@ contract OVM_ExecutionManagerWrapper {
external
external
payable
payable
{
{
bytes memory data = msg.data;
// DO NOTHING FOR NOW
assembly {
// kall is a custom yul builtin within optimistic-solc that allows us to directly call
// the execution manager (since `call` would be compiled).
kall(add(data, 0x20), mload(data), 0x0, 0x0)
// Standard returndata loading code.
let size := returndatasize()
let returndata := mload(0x40)
mstore(0x40, add(returndata, and(add(add(size, 0x20), 0x1f), not(0x1f))))
mstore(returndata, size)
returndatacopy(add(returndata, 0x20), 0x0, size)
// kall automatically reverts if the underlying call fails, so we only need to handle
// the success case.
return(add(returndata, 0x20), mload(returndata))
}
}
}
}
}
packages/contracts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol
View file @
070f68df
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
// @unsupported: ovm
pragma solidity >0.5.0 <0.8.0;
pragma solidity >0.5.0 <0.8.0;
/* Interface Imports */
import { iOVM_L1MessageSender } from "../../iOVM/predeploys/iOVM_L1MessageSender.sol";
import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol";
/**
/**
* @title OVM_L1MessageSender
* @title OVM_L1MessageSender
* @dev The L1MessageSender is a predeploy contract running on L2. During the execution of cross
* @dev The L1MessageSender is a predeploy contract running on L2. During the execution of cross
...
@@ -20,24 +17,23 @@ import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManage
...
@@ -20,24 +17,23 @@ import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManage
* Compiler used: solc
* Compiler used: solc
* Runtime target: OVM
* Runtime target: OVM
*/
*/
contract OVM_L1MessageSender is iOVM_L1MessageSender {
contract OVM_L1MessageSender {
constructor() {
/********************
// By using the low-level assembly `return` we can dictate the final code of this contract
* Public Functions *
// directly. Any call to this contract will simply return the L1MessageSender address.
********************/
// Code of this contract will be:
// 4A - L1MESSAGESENDER
/**
// 60 - PUSH1
* @return _l1MessageSender L1 message sender address (msg.sender).
// 00
*/
// 52 - MSTORE (store L1MESSAGESENDER at memory location 0x00)
function getL1MessageSender()
// 60 - PUSH1
override
// 20
public
// 60 - PUSH1
view
// 00
returns (
// F3 - RETURN (return memory at 0x00...0x20)
address _l1MessageSender
bytes memory code = hex"4A60005260206000F3";
)
assembly {
{
return(add(code, 0x20), mload(code))
// Note that on L2 msg.sender (ie. evmCALLER) will always be the Execution Manager
}
return iOVM_ExecutionManager(msg.sender).ovmL1TXORIGIN();
}
}
}
}
packages/contracts/contracts/optimistic-ethereum/iOVM/predeploys/iOVM_L1MessageSender.sol
View file @
070f68df
...
@@ -10,5 +10,5 @@ interface iOVM_L1MessageSender {
...
@@ -10,5 +10,5 @@ interface iOVM_L1MessageSender {
* Public Functions *
* Public Functions *
********************/
********************/
function getL1MessageSender() external view returns (address
_l1MessageSender
);
function getL1MessageSender() external view returns (address);
}
}
packages/contracts/src/contract-data.ts
View file @
070f68df
...
@@ -115,7 +115,7 @@ export const getL1ContractData = (network: Network) => {
...
@@ -115,7 +115,7 @@ export const getL1ContractData = (network: Network) => {
const
OVM_ETH
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol/OVM_ETH.json
'
)
const
OVM_ETH
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_ETH.sol/OVM_ETH.json
'
)
const
OVM_L2CrossDomainMessenger
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol/OVM_L2CrossDomainMessenger.json
'
)
const
OVM_L2CrossDomainMessenger
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/bridge/messaging/OVM_L2CrossDomainMessenger.sol/OVM_L2CrossDomainMessenger.json
'
)
const
OVM_L2ToL1MessagePasser
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol/OVM_L2ToL1MessagePasser.json
'
)
const
OVM_L2ToL1MessagePasser
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_L2ToL1MessagePasser.sol/OVM_L2ToL1MessagePasser.json
'
)
const
OVM_L1MessageSender
=
require
(
'
../artifacts
-ovm
/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol/OVM_L1MessageSender.json
'
)
const
OVM_L1MessageSender
=
require
(
'
../artifacts/contracts/optimistic-ethereum/OVM/predeploys/OVM_L1MessageSender.sol/OVM_L1MessageSender.json
'
)
const
OVM_DeployerWhitelist
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol/OVM_DeployerWhitelist.json
'
)
const
OVM_DeployerWhitelist
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_DeployerWhitelist.sol/OVM_DeployerWhitelist.json
'
)
const
OVM_ECDSAContractAccount
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_ECDSAContractAccount.sol/OVM_ECDSAContractAccount.json
'
)
const
OVM_ECDSAContractAccount
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_ECDSAContractAccount.sol/OVM_ECDSAContractAccount.json
'
)
const
OVM_SequencerEntrypoint
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol/OVM_SequencerEntrypoint.json
'
)
const
OVM_SequencerEntrypoint
=
require
(
'
../artifacts-ovm/contracts/optimistic-ethereum/OVM/predeploys/OVM_SequencerEntrypoint.sol/OVM_SequencerEntrypoint.json
'
)
...
...
packages/contracts/src/contract-deployment/config.ts
View file @
070f68df
...
@@ -82,7 +82,7 @@ export const makeContractDeployConfig = async (
...
@@ -82,7 +82,7 @@ export const makeContractDeployConfig = async (
],
],
},
},
OVM_DeployerWhitelist
:
{
OVM_DeployerWhitelist
:
{
factory
:
getContractFactory
(
'
OVM_DeployerWhitelist
'
,
undefined
,
true
),
factory
:
getContractFactory
(
'
OVM_DeployerWhitelist
'
),
params
:
[],
params
:
[],
},
},
OVM_L1MessageSender
:
{
OVM_L1MessageSender
:
{
...
@@ -118,24 +118,20 @@ export const makeContractDeployConfig = async (
...
@@ -118,24 +118,20 @@ export const makeContractDeployConfig = async (
},
},
},
},
OVM_ECDSAContractAccount
:
{
OVM_ECDSAContractAccount
:
{
factory
:
getContractFactory
(
'
OVM_ECDSAContractAccount
'
,
undefined
,
true
),
factory
:
getContractFactory
(
'
OVM_ECDSAContractAccount
'
),
},
},
OVM_SequencerEntrypoint
:
{
OVM_SequencerEntrypoint
:
{
factory
:
getContractFactory
(
'
OVM_SequencerEntrypoint
'
,
undefined
,
true
),
factory
:
getContractFactory
(
'
OVM_SequencerEntrypoint
'
),
},
},
OVM_ETH
:
{
OVM_ETH
:
{
factory
:
getContractFactory
(
'
OVM_ETH
'
),
factory
:
getContractFactory
(
'
OVM_ETH
'
),
params
:
[],
params
:
[],
},
},
OVM_ProxyEOA
:
{
OVM_ProxyEOA
:
{
factory
:
getContractFactory
(
'
OVM_ProxyEOA
'
,
undefined
,
true
),
factory
:
getContractFactory
(
'
OVM_ProxyEOA
'
),
},
},
OVM_ExecutionManagerWrapper
:
{
OVM_ExecutionManagerWrapper
:
{
factory
:
getContractFactory
(
factory
:
getContractFactory
(
'
OVM_ExecutionManagerWrapper
'
),
'
OVM_ExecutionManagerWrapper
'
,
undefined
,
true
),
},
},
OVM_GasPriceOracle
:
{
OVM_GasPriceOracle
:
{
factory
:
getContractFactory
(
'
OVM_GasPriceOracle
'
),
factory
:
getContractFactory
(
'
OVM_GasPriceOracle
'
),
...
...
packages/contracts/src/state-dump/make-dump.ts
View file @
070f68df
...
@@ -152,21 +152,6 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
...
@@ -152,21 +152,6 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
config
=
{
...
config
,
...
cfg
}
config
=
{
...
config
,
...
cfg
}
const
ovmCompiled
=
[
'
OVM_L2ToL1MessagePasser
'
,
'
OVM_L2CrossDomainMessenger
'
,
'
OVM_SequencerEntrypoint
'
,
'
Lib_AddressManager
'
,
'
OVM_DeployerWhitelist
'
,
'
OVM_ETH
'
,
'
OVM_ECDSAContractAccount
'
,
'
OVM_ProxyEOA
'
,
'
OVM_ExecutionManagerWrapper
'
,
'
OVM_GasPriceOracle
'
,
'
OVM_SequencerFeeVault
'
,
'
OVM_L2StandardBridge
'
,
]
const
deploymentResult
=
await
deploy
(
config
)
const
deploymentResult
=
await
deploy
(
config
)
deploymentResult
.
contracts
[
'
Lib_AddressManager
'
]
=
deploymentResult
.
contracts
[
'
Lib_AddressManager
'
]
=
deploymentResult
.
AddressManager
deploymentResult
.
AddressManager
...
@@ -187,37 +172,16 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
...
@@ -187,37 +172,16 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
for
(
let
i
=
0
;
i
<
Object
.
keys
(
deploymentResult
.
contracts
).
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
Object
.
keys
(
deploymentResult
.
contracts
).
length
;
i
++
)
{
const
name
=
Object
.
keys
(
deploymentResult
.
contracts
)[
i
]
const
name
=
Object
.
keys
(
deploymentResult
.
contracts
)[
i
]
const
contract
=
deploymentResult
.
contracts
[
name
]
const
contract
=
deploymentResult
.
contracts
[
name
]
let
code
:
string
const
codeBuf
=
await
pStateManager
.
getContractCode
(
if
(
ovmCompiled
.
includes
(
name
))
{
fromHexString
(
contract
.
address
)
const
ovmDeployedBytecode
=
getContractDefinition
(
)
name
,
const
code
=
toHexString
(
codeBuf
)
true
).
deployedBytecode
// TODO remove: deployedBytecode is missing the find and replace in solidity
code
=
ovmDeployedBytecode
.
split
(
'
336000905af158601d01573d60011458600c01573d6000803e3d621234565260ea61109c52
'
)
.
join
(
'
336000905af158600e01573d6000803e3d6000fd5b3d6001141558600a015760016000f35b
'
)
}
else
{
const
codeBuf
=
await
pStateManager
.
getContractCode
(
fromHexString
(
contract
.
address
)
)
code
=
toHexString
(
codeBuf
)
}
const
deadAddress
=
const
deadAddress
=
predeploys
[
name
]
||
predeploys
[
name
]
||
`0xdeaddeaddeaddeaddeaddeaddeaddeaddead
${
i
.
toString
(
16
).
padStart
(
4
,
'
0
'
)}
`
`0xdeaddeaddeaddeaddeaddeaddeaddeaddead
${
i
.
toString
(
16
).
padStart
(
4
,
'
0
'
)}
`
let
def
:
any
const
def
=
getContractDefinition
(
name
.
replace
(
'
Proxy__
'
,
''
))
try
{
def
=
getContractDefinition
(
name
.
replace
(
'
Proxy__
'
,
''
))
}
catch
(
err
)
{
def
=
getContractDefinition
(
name
.
replace
(
'
Proxy__
'
,
''
),
true
)
}
dump
.
accounts
[
name
]
=
{
dump
.
accounts
[
name
]
=
{
address
:
deadAddress
,
address
:
deadAddress
,
...
...
packages/contracts/test/contracts/OVM/bridge/base/OVM_L2CrossDomainMessenger.spec.ts
View file @
070f68df
...
@@ -4,6 +4,7 @@ import { expect } from '../../../../setup'
...
@@ -4,6 +4,7 @@ import { expect } from '../../../../setup'
import
{
ethers
}
from
'
hardhat
'
import
{
ethers
}
from
'
hardhat
'
import
{
Signer
,
ContractFactory
,
Contract
,
constants
}
from
'
ethers
'
import
{
Signer
,
ContractFactory
,
Contract
,
constants
}
from
'
ethers
'
import
{
smockit
,
MockContract
}
from
'
@eth-optimism/smock
'
import
{
smockit
,
MockContract
}
from
'
@eth-optimism/smock
'
import
{
solidityKeccak256
}
from
'
ethers/lib/utils
'
/* Internal Imports */
/* Internal Imports */
import
{
import
{
...
@@ -14,7 +15,7 @@ import {
...
@@ -14,7 +15,7 @@ import {
encodeXDomainCalldata
,
encodeXDomainCalldata
,
getNextBlockNumber
,
getNextBlockNumber
,
}
from
'
../../../../helpers
'
}
from
'
../../../../helpers
'
import
{
solidityKeccak256
}
from
'
ethers/lib/utils
'
import
{
getContractInterface
}
from
'
../../../../../src
'
describe
(
'
OVM_L2CrossDomainMessenger
'
,
()
=>
{
describe
(
'
OVM_L2CrossDomainMessenger
'
,
()
=>
{
let
signer
:
Signer
let
signer
:
Signer
...
@@ -39,7 +40,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
...
@@ -39,7 +40,7 @@ describe('OVM_L2CrossDomainMessenger', () => {
await
ethers
.
getContractFactory
(
'
OVM_L1CrossDomainMessenger
'
)
await
ethers
.
getContractFactory
(
'
OVM_L1CrossDomainMessenger
'
)
)
)
Mock__OVM_L1MessageSender
=
await
smockit
(
Mock__OVM_L1MessageSender
=
await
smockit
(
await
ethers
.
getContractFactory
(
'
OVM_L1MessageSender
'
)
getContractInterface
(
'
i
OVM_L1MessageSender
'
)
)
)
Mock__OVM_L2ToL1MessagePasser
=
await
smockit
(
Mock__OVM_L2ToL1MessagePasser
=
await
smockit
(
await
ethers
.
getContractFactory
(
'
OVM_L2ToL1MessagePasser
'
)
await
ethers
.
getContractFactory
(
'
OVM_L2ToL1MessagePasser
'
)
...
...
packages/contracts/test/contracts/OVM/predeploys/OVM_L1MessageSender.spec.ts
View file @
070f68df
...
@@ -18,7 +18,8 @@ const callPredeployStatic = async (
...
@@ -18,7 +18,8 @@ const callPredeployStatic = async (
)
)
}
}
describe
(
'
OVM_L1MessageSender
'
,
()
=>
{
// TODO: rewrite this test to bypass the execution manager
describe
.
skip
(
'
OVM_L1MessageSender
'
,
()
=>
{
let
Mock__OVM_ExecutionManager
:
MockContract
let
Mock__OVM_ExecutionManager
:
MockContract
before
(
async
()
=>
{
before
(
async
()
=>
{
Mock__OVM_ExecutionManager
=
await
smockit
(
Mock__OVM_ExecutionManager
=
await
smockit
(
...
...
packages/contracts/test/contracts/OVM/predeploys/OVM_L2ToL1MessagePasser.spec.ts
View file @
070f68df
...
@@ -24,7 +24,8 @@ const callPredeploy = async (
...
@@ -24,7 +24,8 @@ const callPredeploy = async (
)
)
}
}
describe
(
'
OVM_L2ToL1MessagePasser
'
,
()
=>
{
// TODO: rewrite this test to bypass the execution manager
describe
.
skip
(
'
OVM_L2ToL1MessagePasser
'
,
()
=>
{
let
Mock__OVM_ExecutionManager
:
MockContract
let
Mock__OVM_ExecutionManager
:
MockContract
before
(
async
()
=>
{
before
(
async
()
=>
{
Mock__OVM_ExecutionManager
=
await
smockit
(
Mock__OVM_ExecutionManager
=
await
smockit
(
...
...
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