good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
c74c07ee
Commit
c74c07ee
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Fixed error for invalid transaction
parent
6518da7c
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/error.go
+18
-0
18 additions, 0 deletions
core/error.go
core/state_transition.go
+6
-7
6 additions, 7 deletions
core/state_transition.go
tests/helper/vm.go
+4
-0
4 additions, 0 deletions
tests/helper/vm.go
tests/vm/gh_test.go
+1
-5
1 addition, 5 deletions
tests/vm/gh_test.go
with
29 additions
and
12 deletions
core/error.go
+
18
−
0
View file @
c74c07ee
...
...
@@ -87,6 +87,24 @@ func IsNonceErr(err error) bool {
return
ok
}
type
InvalidTxErr
struct
{
Message
string
}
func
(
err
*
InvalidTxErr
)
Error
()
string
{
return
err
.
Message
}
func
InvalidTxError
(
err
error
)
*
InvalidTxErr
{
return
&
InvalidTxErr
{
fmt
.
Sprintf
(
"%v"
,
err
)}
}
func
IsInvalidTxErr
(
err
error
)
bool
{
_
,
ok
:=
err
.
(
*
InvalidTxErr
)
return
ok
}
type
OutOfGasErr
struct
{
Message
string
}
...
...
This diff is collapsed.
Click to expand it.
core/state_transition.go
+
6
−
7
View file @
c74c07ee
...
...
@@ -3,7 +3,6 @@ package core
import
(
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
...
...
@@ -146,7 +145,7 @@ func (self *StateTransition) preCheck() (err error) {
// Pre-pay gas / Buy gas of the coinbase account
if
err
=
self
.
BuyGas
();
err
!=
nil
{
return
err
return
InvalidTxError
(
err
)
}
return
nil
...
...
@@ -167,15 +166,15 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
defer
self
.
RefundGas
()
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
//sender.Nonce += 1
// Transaction gas
if
err
=
self
.
UseGas
(
vm
.
GasTx
);
err
!=
nil
{
return
return
nil
,
InvalidTxError
(
err
)
}
// Increment the nonce for the next transaction
self
.
state
.
SetNonce
(
sender
.
Address
(),
sender
.
Nonce
()
+
1
)
//sender.Nonce += 1
// Pay data gas
var
dgas
int64
for
_
,
byt
:=
range
self
.
data
{
...
...
This diff is collapsed.
Click to expand it.
tests/helper/vm.go
+
4
−
0
View file @
c74c07ee
...
...
@@ -167,6 +167,7 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
// Set pre compiled contracts
vm
.
Precompiled
=
vm
.
PrecompiledContracts
()
snapshot
:=
statedb
.
Copy
()
coinbase
:=
statedb
.
GetOrNewStateObject
(
caddr
)
coinbase
.
SetGasPool
(
ethutil
.
Big
(
env
[
"currentGasLimit"
]))
...
...
@@ -175,6 +176,9 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
st
:=
core
.
NewStateTransition
(
vmenv
,
message
,
coinbase
)
vmenv
.
origin
=
keyPair
.
Address
()
ret
,
err
:=
st
.
TransitionState
()
if
core
.
IsNonceErr
(
err
)
||
core
.
IsInvalidTxErr
(
err
)
{
statedb
.
Set
(
snapshot
)
}
statedb
.
Update
(
vmenv
.
Gas
)
return
ret
,
vmenv
.
logs
,
vmenv
.
Gas
,
err
...
...
This diff is collapsed.
Click to expand it.
tests/vm/gh_test.go
+
1
−
5
View file @
c74c07ee
...
...
@@ -79,10 +79,6 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
helper
.
Logger
.
SetLogLevel
(
4
)
if
name
!=
"callcodeToNameRegistratorAddresTooBigRight"
{
continue
}
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
nil
,
db
)
for
addr
,
account
:=
range
test
.
Pre
{
...
...
@@ -161,7 +157,7 @@ func RunVmTest(p string, t *testing.T) {
if
!
isVmTest
{
if
!
bytes
.
Equal
(
ethutil
.
Hex2Bytes
(
test
.
PostStateRoot
),
statedb
.
Root
())
{
//
t.Errorf("%s's : Post state root error. Expected %s, got %x", name, test.PostStateRoot, statedb.Root())
t
.
Errorf
(
"%s's : Post state root error. Expected %s, got %x"
,
name
,
test
.
PostStateRoot
,
statedb
.
Root
())
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment