Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
7b189d6f
Unverified
Commit
7b189d6f
authored
Nov 27, 2019
by
Guillaume Ballet
Committed by
GitHub
Nov 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix staticcheck warnings (#20384)
* core: fix staticcheck warnings * fix goimports
parent
c4844e9e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
14 deletions
+32
-14
database.go
core/rawdb/database.go
+5
-6
contracts.go
core/vm/contracts.go
+2
-0
contracts_test.go
core/vm/contracts_test.go
+25
-1
stack.go
core/vm/stack.go
+0
-7
No files found.
core/rawdb/database.go
View file @
7b189d6f
...
...
@@ -150,11 +150,10 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, freezer string, namespace st
}
// Database contains only older data than the freezer, this happens if the
// state was wiped and reinited from an existing freezer.
}
else
{
// Key-value store continues where the freezer left off, all is fine. We might
// have duplicate blocks (crash after freezer write but before kay-value store
// deletion, but that's fine).
}
// Otherwise, key-value store continues where the freezer left off, all is fine.
// We might have duplicate blocks (crash after freezer write but before key-value
// store deletion, but that's fine).
}
else
{
// If the freezer is empty, ensure nothing was moved yet from the key-value
// store, otherwise we'll end up missing data. We check block #1 to decide
...
...
@@ -167,9 +166,9 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, freezer string, namespace st
return
nil
,
errors
.
New
(
"ancient chain segments already extracted, please set --datadir.ancient to the correct path"
)
}
// Block #1 is still in the database, we're allowed to init a new feezer
}
else
{
// The head header is still the genesis, we're allowed to init a new feezer
}
// Otherwise, the head header is still the genesis, we're allowed to init a new
// feezer.
}
}
// Freezer is consistent with the key-value database, permit combining the two
...
...
core/vm/contracts.go
View file @
7b189d6f
...
...
@@ -28,6 +28,8 @@ import (
"github.com/ethereum/go-ethereum/crypto/blake2b"
"github.com/ethereum/go-ethereum/crypto/bn256"
"github.com/ethereum/go-ethereum/params"
//lint:ignore SA1019 Needed for precompile
"golang.org/x/crypto/ripemd160"
)
...
...
core/vm/contracts_test.go
View file @
7b189d6f
...
...
@@ -29,7 +29,6 @@ import (
// precompiledTest defines the input/output pairs for precompiled contract tests.
type
precompiledTest
struct
{
input
,
expected
string
gas
uint64
name
string
noBenchmark
bool
// Benchmark primarily the worst-cases
}
...
...
@@ -418,6 +417,24 @@ func testPrecompiled(addr string, test precompiledTest, t *testing.T) {
})
}
func
testPrecompiledOOG
(
addr
string
,
test
precompiledTest
,
t
*
testing
.
T
)
{
p
:=
PrecompiledContractsIstanbul
[
common
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
input
)
contract
:=
NewContract
(
AccountRef
(
common
.
HexToAddress
(
"1337"
)),
nil
,
new
(
big
.
Int
),
p
.
RequiredGas
(
in
)
-
1
)
t
.
Run
(
fmt
.
Sprintf
(
"%s-Gas=%d"
,
test
.
name
,
contract
.
Gas
),
func
(
t
*
testing
.
T
)
{
_
,
err
:=
RunPrecompiledContract
(
p
,
in
,
contract
)
if
err
.
Error
()
!=
"out of gas"
{
t
.
Errorf
(
"Expected error [out of gas], got [%v]"
,
err
)
}
// Verify that the precompile did not touch the input buffer
exp
:=
common
.
Hex2Bytes
(
test
.
input
)
if
!
bytes
.
Equal
(
in
,
exp
)
{
t
.
Errorf
(
"Precompiled %v modified input data"
,
addr
)
}
})
}
func
testPrecompiledFailure
(
addr
string
,
test
precompiledFailureTest
,
t
*
testing
.
T
)
{
p
:=
PrecompiledContractsIstanbul
[
common
.
HexToAddress
(
addr
)]
in
:=
common
.
Hex2Bytes
(
test
.
input
)
...
...
@@ -541,6 +558,13 @@ func BenchmarkPrecompiledBn256Add(bench *testing.B) {
}
}
// Tests OOG
func
TestPrecompiledModExpOOG
(
t
*
testing
.
T
)
{
for
_
,
test
:=
range
modexpTests
{
testPrecompiledOOG
(
"05"
,
test
,
t
)
}
}
// Tests the sample inputs from the elliptic curve scalar multiplication EIP 213.
func
TestPrecompiledBn256ScalarMul
(
t
*
testing
.
T
)
{
for
_
,
test
:=
range
bn256ScalarMulTests
{
...
...
core/vm/stack.go
View file @
7b189d6f
...
...
@@ -74,13 +74,6 @@ func (st *Stack) Back(n int) *big.Int {
return
st
.
data
[
st
.
len
()
-
n
-
1
]
}
func
(
st
*
Stack
)
require
(
n
int
)
error
{
if
st
.
len
()
<
n
{
return
fmt
.
Errorf
(
"stack underflow (%d <=> %d)"
,
len
(
st
.
data
),
n
)
}
return
nil
}
// Print dumps the content of the stack
func
(
st
*
Stack
)
Print
()
{
fmt
.
Println
(
"### stack ###"
)
...
...
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