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
c4733987
Commit
c4733987
authored
Sep 22, 2020
by
ben-chain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fixed nuisance gas for ovmCALL
parent
f62b225d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
OVM_ExecutionManager.sol
...ptimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
+3
-2
nuisance-gas.spec.ts
...s/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts
+7
-3
constants.ts
packages/contracts/test/helpers/constants.ts
+1
-0
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
View file @
c4733987
...
@@ -49,6 +49,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
...
@@ -49,6 +49,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
address constant GAS_METADATA_ADDRESS = 0x06a506A506a506A506a506a506A506A506A506A5;
address constant GAS_METADATA_ADDRESS = 0x06a506A506a506A506a506a506A506A506A506A5;
uint256 constant NUISANCE_GAS_SLOAD = 20000;
uint256 constant NUISANCE_GAS_SLOAD = 20000;
uint256 constant NUISANCE_GAS_SSTORE = 20000;
uint256 constant NUISANCE_GAS_SSTORE = 20000;
uint256 constant MIN_NUISANCE_GAS_PER_CONTRACT = 30000;
uint256 constant NUISANCE_GAS_PER_CONTRACT_BYTE = 100;
uint256 constant NUISANCE_GAS_PER_CONTRACT_BYTE = 100;
uint256 constant MIN_GAS_FOR_INVALID_STATE_ACCESS = 30000;
uint256 constant MIN_GAS_FOR_INVALID_STATE_ACCESS = 30000;
...
@@ -1161,7 +1162,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
...
@@ -1161,7 +1162,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
if (_wasAccountAlreadyLoaded == false) {
if (_wasAccountAlreadyLoaded == false) {
console.log("was not already loaded");
console.log("was not already loaded");
_useNuisanceGas(
_useNuisanceGas(
Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE
(Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE) + MIN_NUISANCE_GAS_PER_CONTRACT
);
);
console.log("got code size:");
console.log("got code size:");
console.log(Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)));
console.log(Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)));
...
@@ -1190,7 +1191,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
...
@@ -1190,7 +1191,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager {
if (_wasAccountAlreadyChanged == false) {
if (_wasAccountAlreadyChanged == false) {
ovmStateManager.incrementTotalUncommittedAccounts();
ovmStateManager.incrementTotalUncommittedAccounts();
_useNuisanceGas(
_useNuisanceGas(
Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE
(Lib_EthUtils.getCodeSize(_getAccountEthAddress(_address)) * NUISANCE_GAS_PER_CONTRACT_BYTE) + MIN_NUISANCE_GAS_PER_CONTRACT
);
);
}
}
}
}
...
...
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts
View file @
c4733987
...
@@ -15,7 +15,11 @@ import {
...
@@ -15,7 +15,11 @@ import {
'
0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420
'
'
0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420
'
const
CREATED_CONTRACT_1
=
'
0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb
'
const
CREATED_CONTRACT_1
=
'
0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb
'
const
FRESH_CALL_NUISANCE_GAS_COST
=
Helper_TestRunner_BYTELEN
*
NUISANCE_GAS_COSTS
.
NUISANCE_GAS_PER_CONTRACT_BYTE
+
NUISANCE_GAS_COSTS
.
MIN_NUISANCE_GAS_PER_CONTRACT
console
.
log
(
`first call cost:
${
FRESH_CALL_NUISANCE_GAS_COST
}
`
)
const
test_nuisanceGas
:
TestDefinition
=
{
const
test_nuisanceGas
:
TestDefinition
=
{
name
:
'
Basic tests for nuisance gas
'
,
name
:
'
Basic tests for nuisance gas
'
,
preState
:
{
preState
:
{
...
@@ -54,7 +58,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
...
@@ -54,7 +58,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
postState
:
{
postState
:
{
ExecutionManager
:
{
ExecutionManager
:
{
messageRecord
:
{
messageRecord
:
{
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
-
Helper_TestRunner_BYTELEN
*
NUISANCE_GAS_COSTS
.
NUISANCE_GAS_PER_CONTRACT_BYTE
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
-
FRESH_CALL_NUISANCE_GAS_COST
}
}
}
}
},
},
...
@@ -90,7 +94,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
...
@@ -90,7 +94,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
postState
:
{
postState
:
{
ExecutionManager
:
{
ExecutionManager
:
{
messageRecord
:
{
messageRecord
:
{
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
-
2
*
(
Helper_TestRunner_BYTELEN
*
NUISANCE_GAS_COSTS
.
NUISANCE_GAS_PER_CONTRACT_BYTE
)
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
-
2
*
FRESH_CALL_NUISANCE_GAS_COST
}
}
}
}
},
},
...
@@ -140,7 +144,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
...
@@ -140,7 +144,7 @@ const CREATED_CONTRACT_1 = '0x2bda4a99d5be88609d23b1e4ab5d1d34fb1c2feb'
postState
:
{
postState
:
{
ExecutionManager
:
{
ExecutionManager
:
{
messageRecord
:
{
messageRecord
:
{
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
-
(
Helper_TestRunner_BYTELEN
*
NUISANCE_GAS_COSTS
.
NUISANCE_GAS_PER_CONTRACT_BYTE
)
-
OVM_TX_GAS_LIMIT
/
2
nuisanceGasLeft
:
OVM_TX_GAS_LIMIT
-
FRESH_CALL_NUISANCE_GAS_COST
-
OVM_TX_GAS_LIMIT
/
2
}
}
}
}
},
},
...
...
packages/contracts/test/helpers/constants.ts
View file @
c4733987
...
@@ -27,6 +27,7 @@ export const VERIFIED_EMPTY_CONTRACT_HASH =
...
@@ -27,6 +27,7 @@ export const VERIFIED_EMPTY_CONTRACT_HASH =
export
const
NUISANCE_GAS_COSTS
=
{
export
const
NUISANCE_GAS_COSTS
=
{
NUISANCE_GAS_SLOAD
:
20000
,
NUISANCE_GAS_SLOAD
:
20000
,
NUISANCE_GAS_SSTORE
:
20000
,
NUISANCE_GAS_SSTORE
:
20000
,
MIN_NUISANCE_GAS_PER_CONTRACT
:
30000
,
NUISANCE_GAS_PER_CONTRACT_BYTE
:
100
,
NUISANCE_GAS_PER_CONTRACT_BYTE
:
100
,
MIN_GAS_FOR_INVALID_STATE_ACCESS
:
30000
,
MIN_GAS_FOR_INVALID_STATE_ACCESS
:
30000
,
}
}
...
...
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