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
ea3785b1
Commit
ea3785b1
authored
Nov 20, 2020
by
ben-chain
Committed by
GitHub
Nov 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first pass (#71)
parent
a72141f4
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
570 additions
and
6 deletions
+570
-6
Helper_GasMeasurer.sol
...s/contracts/contracts/test-helpers/Helper_GasMeasurer.sol
+32
-0
package.json
packages/contracts/package.json
+1
-1
OVM_StateManager.gas-spec.ts
...test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts
+527
-0
OVM_StateManager.spec.ts
...cts/test/contracts/OVM/execution/OVM_StateManager.spec.ts
+2
-5
constants.ts
packages/contracts/test/helpers/constants.ts
+8
-0
No files found.
packages/contracts/contracts/test-helpers/Helper_GasMeasurer.sol
0 → 100644
View file @
ea3785b1
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.0;
contract Helper_GasMeasurer {
function measureCallGas(
address _target,
bytes memory _data
)
public
returns ( uint )
{
uint gasBefore;
uint gasAfter;
uint calldataStart;
uint calldataLength;
assembly {
calldataStart := add(_data,0x20)
calldataLength := mload(_data)
}
bool success;
assembly {
gasBefore := gas()
success := call(gas(), _target, 0, calldataStart, calldataLength, 0, 0)
gasAfter := gas()
}
require(success, "Call failed, but calls we want to measure gas for should succeed!");
return gasBefore - gasAfter;
}
}
packages/contracts/package.json
View file @
ea3785b1
...
...
@@ -19,9 +19,9 @@
"build:typechain"
:
"buidler typechain"
,
"test"
:
"yarn run test:contracts"
,
"test:contracts"
:
"buidler test --show-stack-traces"
,
"test:gas"
:
"buidler test
\"
test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts
\"
--no-compile --show-stack-traces"
,
"lint"
:
"yarn run lint:typescript"
,
"lint:typescript"
:
"tslint --format stylish --project ."
,
"lint:fix"
:
"yarn run lint:fix:typescript"
,
"lint:fix:typescript"
:
"prettier --config prettier-config.json --write
\"
buidler.config.ts
\"
\"
{src,test}/**/*.ts
\"
"
,
"clean"
:
"rm -rf ./artifacts ./build ./cache"
,
"deploy"
:
"./bin/deploy.js"
...
...
packages/contracts/test/contracts/OVM/execution/OVM_StateManager.gas-spec.ts
0 → 100644
View file @
ea3785b1
This diff is collapsed.
Click to expand it.
packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts
View file @
ea3785b1
...
...
@@ -6,12 +6,9 @@ import { Contract, ContractFactory, Signer, BigNumber } from 'ethers'
import
_
from
'
lodash
'
/* Internal Imports */
import
{
DUMMY_ACCOUNTS
,
DUMMY_BYTES32
,
ZERO_ADDRESS
}
from
'
../../../helpers
'
import
{
DUMMY_ACCOUNTS
,
DUMMY_BYTES32
,
ZERO_ADDRESS
,
EMPTY_ACCOUNT_CODE_HASH
,
KECCAK_256_NULL
}
from
'
../../../helpers
'
const
EMPTY_ACCOUNT_CODE_HASH
=
'
0x00004B1DC0DE000000004B1DC0DE000000004B1DC0DE000000004B1DC0DE0000
'
const
KECCAK_256_NULL
=
'
0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
'
describe
(
'
OVM_StateManager
'
,
()
=>
{
let
signer1
:
Signer
...
...
packages/contracts/test/helpers/constants.ts
View file @
ea3785b1
...
...
@@ -26,6 +26,9 @@ export const NON_ZERO_ADDRESS = makeAddress('11')
export
const
VERIFIED_EMPTY_CONTRACT_HASH
=
'
0x00004B1DC0DE000000004B1DC0DE000000004B1DC0DE000000004B1DC0DE0000
'
export
const
STORAGE_XOR_VALUE
=
'
0xFEEDFACECAFEBEEFFEEDFACECAFEBEEFFEEDFACECAFEBEEFFEEDFACECAFEBEEF
'
export
const
NUISANCE_GAS_COSTS
=
{
NUISANCE_GAS_SLOAD
:
20000
,
NUISANCE_GAS_SSTORE
:
20000
,
...
...
@@ -42,3 +45,8 @@ export const STORAGE_XOR =
export
const
getStorageXOR
=
(
key
:
string
):
string
=>
{
return
toHexString
(
xor
(
fromHexString
(
key
),
fromHexString
(
STORAGE_XOR
)))
}
export
const
EMPTY_ACCOUNT_CODE_HASH
=
'
0x00004B1DC0DE000000004B1DC0DE000000004B1DC0DE000000004B1DC0DE0000
'
export
const
KECCAK_256_NULL
=
'
0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470
'
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