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
8e116f2a
Commit
8e116f2a
authored
Dec 02, 2020
by
ben-chain
Committed by
GitHub
Dec 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
static refund size for CALL/CREATE
parent
a3bb363d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
8 deletions
+29
-8
OVM_ExecutionManager.sol
...ptimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
+29
-8
No files found.
packages/contracts/contracts/optimistic-ethereum/OVM/execution/OVM_ExecutionManager.sol
View file @
8e116f2a
...
...
@@ -78,9 +78,9 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
**********************/
/**
* Applies
a net gas cost
refund to a transaction to account for the difference in execution
* between L1 and L2.
* @param _cost
G
as cost for the function after the refund.
* Applies
dynamically-sized
refund to a transaction to account for the difference in execution
* between L1 and L2
, so that the overall cost of the ovmOPCODE is fixed
.
* @param _cost
Desired g
as cost for the function after the refund.
*/
modifier netGasCost(
uint256 _cost
...
...
@@ -95,6 +95,27 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
}
}
/**
* Applies a fixed-size gas refund to a transaction to account for the difference in execution
* between L1 and L2, so that the overall cost of an ovmOPCODE can be lowered.
* @param _discount Amount of gas cost to refund for the ovmOPCODE.
*/
modifier fixedGasDiscount(
uint256 _discount
) {
uint256 gasProvided = gasleft();
_;
uint256 gasUsed = gasProvided - gasleft();
// We want to refund the specified _discount, unless this risks underflow.
if (_discount < gasUsed) {
transactionRecord.ovmGasRefund += _discount;
} else {
// refund all we can without risking underflow.
transactionRecord.ovmGasRefund += gasUsed;
}
}
/**
* Makes sure we're not inside a static context.
*/
...
...
@@ -327,7 +348,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
override
public
notStatic
netGasCost(40000 + _bytecode.length * 1
00)
fixedGasDiscount(400
00)
returns (
address _contract
)
...
...
@@ -360,7 +381,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
override
public
notStatic
netGasCost(40000 + _bytecode.length * 1
00)
fixedGasDiscount(400
00)
returns (
address _contract
)
...
...
@@ -499,7 +520,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
)
override
public
netGasCos
t(100000)
fixedGasDiscoun
t(100000)
returns (
bool _success,
bytes memory _returndata
...
...
@@ -535,7 +556,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
)
override
public
netGasCos
t(80000)
fixedGasDiscoun
t(80000)
returns (
bool _success,
bytes memory _returndata
...
...
@@ -572,7 +593,7 @@ contract OVM_ExecutionManager is iOVM_ExecutionManager, Lib_AddressResolver {
)
override
public
netGasCos
t(40000)
fixedGasDiscoun
t(40000)
returns (
bool _success,
bytes memory _returndata
...
...
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