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
a56125c2
Commit
a56125c2
authored
Sep 22, 2020
by
ben-chain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add context opcode tests
parent
c236b1d4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
75 deletions
+62
-75
OVM_ExecutionManager.sol
...ptimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
+4
-0
iOVM_ExecutionManager.sol
...imistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol
+1
-1
package.json
packages/contracts/package.json
+1
-1
context-opcodes.spec.ts
...VM/execution/OVM_ExecutionManager/context-opcodes.spec.ts
+51
-71
test.types.ts
packages/contracts/test/helpers/test-utils/test.types.ts
+5
-2
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
View file @
a56125c2
...
@@ -487,6 +487,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
...
@@ -487,6 +487,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
bytes memory _returndata
bytes memory _returndata
)
)
{
{
console.log("ovmCALL to");
console.logAddress(_address);
// CALL updates the CALLER and ADDRESS.
// CALL updates the CALLER and ADDRESS.
MessageContext memory nextMessageContext = messageContext;
MessageContext memory nextMessageContext = messageContext;
nextMessageContext.ovmCALLER = nextMessageContext.ovmADDRESS;
nextMessageContext.ovmCALLER = nextMessageContext.ovmADDRESS;
...
@@ -1678,6 +1680,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
...
@@ -1678,6 +1680,8 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
)
)
internal
internal
{
{
console.log("setting number to:");
console.log(_transaction.number);
transactionContext.ovmTIMESTAMP = _transaction.timestamp;
transactionContext.ovmTIMESTAMP = _transaction.timestamp;
transactionContext.ovmNUMBER = _transaction.number;
transactionContext.ovmNUMBER = _transaction.number;
transactionContext.ovmTXGASLIMIT = _transaction.gasLimit;
transactionContext.ovmTXGASLIMIT = _transaction.gasLimit;
...
...
packages/contracts/contracts/optimistic-ethereum/iOVM/execution/iOVM_ExecutionManager.sol
View file @
a56125c2
...
@@ -46,11 +46,11 @@ interface iOVM_ExecutionManager {
...
@@ -46,11 +46,11 @@ interface iOVM_ExecutionManager {
}
}
struct TransactionContext {
struct TransactionContext {
Lib_OVMCodec.QueueOrigin ovmL1QUEUEORIGIN;
uint256 ovmTIMESTAMP;
uint256 ovmTIMESTAMP;
uint256 ovmNUMBER;
uint256 ovmNUMBER;
uint256 ovmGASLIMIT;
uint256 ovmGASLIMIT;
uint256 ovmTXGASLIMIT;
uint256 ovmTXGASLIMIT;
Lib_OVMCodec.QueueOrigin ovmL1QUEUEORIGIN;
address ovmL1TXORIGIN;
address ovmL1TXORIGIN;
}
}
...
...
packages/contracts/package.json
View file @
a56125c2
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
"build"
:
"yarn run build:contracts"
,
"build"
:
"yarn run build:contracts"
,
"build:contracts"
:
"buidler compile"
,
"build:contracts"
:
"buidler compile"
,
"test"
:
"yarn run test:contracts"
,
"test"
:
"yarn run test:contracts"
,
"test:contracts"
:
"buidler test
\"
test/contracts/OVM/execution/OVM_ExecutionManager/
nuisance-ga
s.spec.ts
\"
"
,
"test:contracts"
:
"buidler test
\"
test/contracts/OVM/execution/OVM_ExecutionManager/
context-opcode
s.spec.ts
\"
"
,
"lint"
:
"tslint --format stylish --project ."
,
"lint"
:
"tslint --format stylish --project ."
,
"fix"
:
"prettier --config prettier-config.json --write
\"
buidler.config.ts
\"
\"
{src,test}/**/*.ts
\"
"
"fix"
:
"prettier --config prettier-config.json --write
\"
buidler.config.ts
\"
\"
{src,test}/**/*.ts
\"
"
},
},
...
...
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts
View file @
a56125c2
/* Internal Imports */
/* Internal Imports */
import
{
import
{
runExecutionManagerTest
,
ExecutionManagerTestRunner
,
TestDefinition
,
TestDefinition
,
OVM_TX_GAS_LIMIT
,
NULL_BYTES32
,
NON_NULL_BYTES32
,
NON_NULL_BYTES32
,
REVERT_FLAGS
,
OVM_TX_GAS_LIMIT
DUMMY_BYTECODE
,
}
from
'
../../../../helpers
'
}
from
'
../../../../helpers
'
const
globalContext
=
{
const
globalContext
=
{
...
@@ -15,6 +12,7 @@ import {
...
@@ -15,6 +12,7 @@ import {
const
transactionContext
=
{
const
transactionContext
=
{
ovmTIMESTAMP
:
12341234
,
ovmTIMESTAMP
:
12341234
,
ovmNUMBER
:
13371337
,
ovmGASLIMIT
:
45674567
,
ovmGASLIMIT
:
45674567
,
ovmTXGASLIMIT
:
78907890
,
ovmTXGASLIMIT
:
78907890
,
ovmL1QUEUEORIGIN
:
1
,
ovmL1QUEUEORIGIN
:
1
,
...
@@ -26,123 +24,105 @@ import {
...
@@ -26,123 +24,105 @@ import {
ovmADDRESS
:
'
0x4567456745674567456745674567456745674567
'
ovmADDRESS
:
'
0x4567456745674567456745674567456745674567
'
}
}
const
test_
ovmC
ontextOpcodes
:
TestDefinition
=
{
const
test_
c
ontextOpcodes
:
TestDefinition
=
{
name
:
'
unit tests for basic getter opcodes
'
,
name
:
'
unit tests for basic getter opcodes
'
,
preState
:
{
preState
:
{
ExecutionManager
:
{
ExecutionManager
:
{
ovmStateManager
:
'
$OVM_STATE_MANAGER
'
,
ovmSafetyChecker
:
'
$OVM_SAFETY_CHECKER
'
,
messageRecord
:
{
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
,
},
globalContext
,
globalContext
,
transactionContext
,
transactionContext
,
messageContext
messageContext
},
StateManager
:
{
owner
:
'
$OVM_EXECUTION_MANAGER
'
,
accounts
:
{
$DUMMY_OVM_ADDRESS_1
:
{
codeHash
:
NON_NULL_BYTES32
,
ethAddress
:
'
$OVM_CALL_HELPER
'
,
},
},
},
},
},
},
parameters
:
[
parameters
:
[
// TODO: re-enable when we can unwrap tests' ovmCALL
// {
// name: 'gets ovmCALLER',
// steps: [
// {
// functionName: 'ovmCALLER',
// expectedReturnValue: messageContext.ovmCALLER
// }
// ],
// },
// {
// name: 'gets ovmADDRESS',
// steps: [
// {
// functionName: 'ovmADDRESS',
// expectedReturnValue: messageContext.ovmADDRESS
// }
// ],
// },
{
{
name
:
'
gets ovmCALLER
'
,
name
:
'
gets ovmTIMESTAMP
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmCALLER
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
messageContext
.
ovmCALLER
]
}
],
},
],
},
{
name
:
'
gets ovmADDRESS
'
,
parameters
:
[
{
steps
:
[
steps
:
[
{
{
functionName
:
'
ovmADDRESS
'
,
functionName
:
'
ovmTIMESTAMP
'
,
functionParams
:
[],
expectedReturnValue
:
transactionContext
.
ovmTIMESTAMP
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
messageContext
.
ovmADDRESS
]
}
}
],
],
},
],
},
},
{
{
name
:
'
gets ovmTIMESTAMP
'
,
name
:
'
gets ovmNUMBER
'
,
parameters
:
[
{
steps
:
[
steps
:
[
{
{
functionName
:
'
ovmTIMESTAMP
'
,
functionName
:
'
ovmNUMBER
'
,
functionParams
:
[],
expectedReturnValue
:
transactionContext
.
ovmNUMBER
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmTIMESTAMP
]
}
}
],
],
},
],
},
},
{
{
name
:
'
gets ovmGASLIMIT
'
,
name
:
'
gets ovmGASLIMIT
'
,
parameters
:
[
{
steps
:
[
steps
:
[
{
{
functionName
:
'
ovmGASLIMIT
'
,
functionName
:
'
ovmGASLIMIT
'
,
functionParams
:
[],
expectedReturnValue
:
transactionContext
.
ovmGASLIMIT
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmGASLIMIT
]
}
}
],
],
},
],
},
},
{
{
name
:
'
gets ovmQUEUEORIGIN
'
,
name
:
'
gets ovmL1QUEUEORIGIN
'
,
parameters
:
[
{
steps
:
[
steps
:
[
{
{
functionName
:
'
ovmL1QUEUEORIGIN
'
,
functionName
:
'
ovmL1QUEUEORIGIN
'
,
functionParams
:
[],
expectedReturnValue
:
transactionContext
.
ovmL1QUEUEORIGIN
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmL1QUEUEORIGIN
]
}
}
],
],
},
],
},
},
{
{
name
:
'
gets ovmL1TXORIGIN
'
,
name
:
'
gets ovmL1TXORIGIN
'
,
parameters
:
[
{
steps
:
[
steps
:
[
{
{
functionName
:
'
ovmL1TXORIGIN
'
,
functionName
:
'
ovmL1TXORIGIN
'
,
functionParams
:
[],
expectedReturnValue
:
transactionContext
.
ovmL1TXORIGIN
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmL1TXORIGIN
]
}
}
],
],
},
],
},
},
{
{
name
:
'
gets ovmCHAINID
'
,
name
:
'
gets ovmCHAINID
'
,
parameter
s
:
[
step
s
:
[
{
{
steps
:
[
{
functionName
:
'
ovmCHAINID
'
,
functionName
:
'
ovmCHAINID
'
,
functionParams
:
[],
expectedReturnValue
:
globalContext
.
ovmCHAINID
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
globalContext
.
ovmCHAINID
]
}
}
],
],
},
},
],
},
],
],
}
}
runExecutionManagerTest
(
test_ovmContextOpcodes
)
const
runner
=
new
ExecutionManagerTestRunner
()
runner
.
run
(
test_contextOpcodes
)
\ No newline at end of file
\ No newline at end of file
packages/contracts/test/helpers/test-utils/test.types.ts
View file @
a56125c2
...
@@ -3,8 +3,10 @@ import { BigNumber } from 'ethers'
...
@@ -3,8 +3,10 @@ import { BigNumber } from 'ethers'
export
type
ContextOpcode
=
export
type
ContextOpcode
=
|
'
ovmCALLER
'
|
'
ovmCALLER
'
|
'
ovmNUMBER
'
|
'
ovmADDRESS
'
|
'
ovmADDRESS
'
|
'
ovmORIGIN
'
|
'
ovmL1TXORIGIN
'
|
'
ovmL1QUEUEORIGIN
'
|
'
ovmTIMESTAMP
'
|
'
ovmTIMESTAMP
'
|
'
ovmGASLIMIT
'
|
'
ovmGASLIMIT
'
|
'
ovmCHAINID
'
|
'
ovmCHAINID
'
...
@@ -170,10 +172,11 @@ export const isTestStep_Context = (
...
@@ -170,10 +172,11 @@ export const isTestStep_Context = (
return
[
return
[
'
ovmCALLER
'
,
'
ovmCALLER
'
,
'
ovmADDRESS
'
,
'
ovmADDRESS
'
,
'
ovmORIGIN
'
,
'
ovm
L1TX
ORIGIN
'
,
'
ovmTIMESTAMP
'
,
'
ovmTIMESTAMP
'
,
'
ovmGASLIMIT
'
,
'
ovmGASLIMIT
'
,
'
ovmCHAINID
'
,
'
ovmCHAINID
'
,
'
ovmL1QUEUEORIGIN
'
].
includes
(
step
.
functionName
)
].
includes
(
step
.
functionName
)
}
}
...
...
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