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
88ff13c2
Commit
88ff13c2
authored
10 years ago
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Spec changes.
* All errors during state transition result in an invalid tx
parent
ca1093f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/error.go
+16
-0
16 additions, 0 deletions
core/error.go
core/execution.go
+5
-3
5 additions, 3 deletions
core/execution.go
core/state_transition.go
+10
-3
10 additions, 3 deletions
core/state_transition.go
vm/vm.go
+6
-1
6 additions, 1 deletion
vm/vm.go
with
37 additions
and
7 deletions
core/error.go
+
16
−
0
View file @
88ff13c2
...
...
@@ -146,3 +146,19 @@ func IsKnownBlockErr(e error) bool {
_
,
ok
:=
e
.
(
*
KnownBlockError
)
return
ok
}
type
ValueTransferError
struct
{
message
string
}
func
ValueTransferErr
(
str
string
,
v
...
interface
{})
*
ValueTransferError
{
return
&
ValueTransferError
{
fmt
.
Sprintf
(
str
,
v
...
)}
}
func
(
self
*
ValueTransferError
)
Error
()
string
{
return
self
.
message
}
func
IsValueTransferErr
(
e
error
)
bool
{
_
,
ok
:=
e
.
(
*
ValueTransferError
)
return
ok
}
This diff is collapsed.
Click to expand it.
core/execution.go
+
5
−
3
View file @
88ff13c2
package
core
import
(
"fmt"
"math/big"
"time"
...
...
@@ -26,7 +25,10 @@ func (self *Execution) Addr() []byte {
func
(
self
*
Execution
)
Call
(
codeAddr
[]
byte
,
caller
vm
.
ContextRef
)
([]
byte
,
error
)
{
// Retrieve the executing code
code
:=
self
.
env
.
State
()
.
GetCode
(
codeAddr
)
var
code
[]
byte
if
self
.
env
.
State
()
.
GetStateObject
(
codeAddr
)
!=
nil
{
code
=
self
.
env
.
State
()
.
GetCode
(
codeAddr
)
}
return
self
.
exec
(
code
,
codeAddr
,
caller
)
}
...
...
@@ -55,7 +57,7 @@ func (self *Execution) exec(code, contextAddr []byte, caller vm.ContextRef) (ret
caller
.
ReturnGas
(
self
.
Gas
,
self
.
price
)
return
nil
,
fmt
.
Errorf
(
"insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
from
.
Balance
())
return
nil
,
ValueTransferErr
(
"insufficient funds to transfer value. Req %v, has %v"
,
self
.
value
,
from
.
Balance
())
}
snapshot
:=
env
.
State
()
.
Copy
()
...
...
This diff is collapsed.
Click to expand it.
core/state_transition.go
+
10
−
3
View file @
88ff13c2
...
...
@@ -3,6 +3,7 @@ package core
import
(
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
...
...
@@ -185,7 +186,7 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
}
}
if
err
=
self
.
UseGas
(
big
.
NewInt
(
dgas
));
err
!=
nil
{
return
return
nil
,
InvalidTxError
(
err
)
}
//stateCopy := self.env.State().Copy()
...
...
@@ -231,10 +232,16 @@ func (self *StateTransition) TransitionState() (ret []byte, err error) {
*/
}
if
err
!=
nil
{
self
.
UseGas
(
self
.
gas
)
if
err
!=
nil
&&
IsValueTransferErr
(
err
)
{
return
nil
,
InvalidTxError
(
err
)
}
/*
if err != nil {
self.UseGas(self.gas)
}
*/
return
}
...
...
This diff is collapsed.
Click to expand it.
vm/vm.go
+
6
−
1
View file @
88ff13c2
...
...
@@ -408,7 +408,12 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
case
BALANCE
:
addr
:=
stack
.
Pop
()
.
Bytes
()
balance
:=
statedb
.
GetBalance
(
addr
)
var
balance
*
big
.
Int
if
statedb
.
GetStateObject
(
addr
)
!=
nil
{
balance
=
statedb
.
GetBalance
(
addr
)
}
else
{
balance
=
base
}
stack
.
Push
(
balance
)
...
...
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