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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
f371e6c8
Commit
f371e6c8
authored
Jun 9, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Plain Diff
Merge pull request #1156 from tgerring/issue1145
Differentiate between 0 and unspecified gas/gasprice
parents
3054fd48
1a967986
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
rpc/api.go
+30
-2
30 additions, 2 deletions
rpc/api.go
rpc/args.go
+12
-12
12 additions, 12 deletions
rpc/args.go
rpc/args_test.go
+12
-8
12 additions, 8 deletions
rpc/args_test.go
xeth/xeth.go
+19
-14
19 additions, 14 deletions
xeth/xeth.go
with
73 additions
and
36 deletions
rpc/api.go
+
30
−
2
View file @
f371e6c8
...
@@ -182,7 +182,21 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -182,7 +182,21 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
nonce
=
args
.
Nonce
.
String
()
nonce
=
args
.
Nonce
.
String
()
}
}
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
,
args
.
To
,
nonce
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
var
gas
string
if
args
.
Gas
==
nil
{
gas
=
""
}
else
{
gas
=
args
.
Gas
.
String
()
}
var
gasprice
string
if
args
.
GasPrice
==
nil
{
gasprice
=
""
}
else
{
gasprice
=
args
.
GasPrice
.
String
()
}
v
,
err
:=
api
.
xeth
()
.
Transact
(
args
.
From
,
args
.
To
,
nonce
,
args
.
Value
.
String
(),
gas
,
gasprice
,
args
.
Data
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -603,5 +617,19 @@ func (api *EthereumApi) doCall(params json.RawMessage) (string, string, error) {
...
@@ -603,5 +617,19 @@ func (api *EthereumApi) doCall(params json.RawMessage) (string, string, error) {
return
""
,
""
,
err
return
""
,
""
,
err
}
}
return
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
args
.
Gas
.
String
(),
args
.
GasPrice
.
String
(),
args
.
Data
)
var
gas
string
if
args
.
Gas
==
nil
{
gas
=
""
}
else
{
gas
=
args
.
Gas
.
String
()
}
var
gasprice
string
if
args
.
GasPrice
==
nil
{
gasprice
=
""
}
else
{
gasprice
=
args
.
GasPrice
.
String
()
}
return
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
Call
(
args
.
From
,
args
.
To
,
args
.
Value
.
String
(),
gas
,
gasprice
,
args
.
Data
)
}
}
This diff is collapsed.
Click to expand it.
rpc/args.go
+
12
−
12
View file @
f371e6c8
...
@@ -261,22 +261,22 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -261,22 +261,22 @@ func (args *NewTxArgs) UnmarshalJSON(b []byte) (err error) {
args
.
Value
=
num
args
.
Value
=
num
num
=
nil
num
=
nil
if
ext
.
Gas
==
nil
{
if
ext
.
Gas
!=
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
num
,
err
=
numString
(
ext
.
Gas
);
err
!=
nil
{
if
num
,
err
=
numString
(
ext
.
Gas
);
err
!=
nil
{
return
err
return
err
}
}
}
else
{
num
=
nil
}
}
args
.
Gas
=
num
args
.
Gas
=
num
num
=
nil
num
=
nil
if
ext
.
GasPrice
==
nil
{
if
ext
.
GasPrice
!=
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
num
,
err
=
numString
(
ext
.
GasPrice
);
err
!=
nil
{
if
num
,
err
=
numString
(
ext
.
GasPrice
);
err
!=
nil
{
return
err
return
err
}
}
}
else
{
num
=
nil
}
}
args
.
GasPrice
=
num
args
.
GasPrice
=
num
...
@@ -346,21 +346,21 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -346,21 +346,21 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
}
}
args
.
Value
=
num
args
.
Value
=
num
if
ext
.
Gas
==
nil
{
if
ext
.
Gas
!=
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
num
,
err
=
numString
(
ext
.
Gas
);
err
!=
nil
{
if
num
,
err
=
numString
(
ext
.
Gas
);
err
!=
nil
{
return
err
return
err
}
}
}
else
{
num
=
nil
}
}
args
.
Gas
=
num
args
.
Gas
=
num
if
ext
.
GasPrice
==
nil
{
if
ext
.
GasPrice
!=
nil
{
num
=
big
.
NewInt
(
0
)
}
else
{
if
num
,
err
=
numString
(
ext
.
GasPrice
);
err
!=
nil
{
if
num
,
err
=
numString
(
ext
.
GasPrice
);
err
!=
nil
{
return
err
return
err
}
}
}
else
{
num
=
nil
}
}
args
.
GasPrice
=
num
args
.
GasPrice
=
num
...
...
This diff is collapsed.
Click to expand it.
rpc/args_test.go
+
12
−
8
View file @
f371e6c8
...
@@ -573,14 +573,15 @@ func TestNewTxArgsGasMissing(t *testing.T) {
...
@@ -573,14 +573,15 @@ func TestNewTxArgsGasMissing(t *testing.T) {
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
}]`
expected
:=
new
(
NewTxArgs
)
expected
:=
new
(
NewTxArgs
)
expected
.
Gas
=
big
.
NewInt
(
0
)
expected
.
Gas
=
nil
args
:=
new
(
NewTxArgs
)
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
if
bytes
.
Compare
(
expected
.
Gas
.
Bytes
(),
args
.
Gas
.
Bytes
())
!=
0
{
if
args
.
Gas
!=
expected
.
Gas
{
// if bytes.Compare(expected.Gas.Bytes(), args.Gas.Bytes()) != 0 {
t
.
Errorf
(
"Gas shoud be %v but is %v"
,
expected
.
Gas
,
args
.
Gas
)
t
.
Errorf
(
"Gas shoud be %v but is %v"
,
expected
.
Gas
,
args
.
Gas
)
}
}
}
}
...
@@ -594,14 +595,15 @@ func TestNewTxArgsBlockGaspriceMissing(t *testing.T) {
...
@@ -594,14 +595,15 @@ func TestNewTxArgsBlockGaspriceMissing(t *testing.T) {
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
}]`
}]`
expected
:=
new
(
NewTxArgs
)
expected
:=
new
(
NewTxArgs
)
expected
.
GasPrice
=
big
.
NewInt
(
0
)
expected
.
GasPrice
=
nil
args
:=
new
(
NewTxArgs
)
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
if
bytes
.
Compare
(
expected
.
GasPrice
.
Bytes
(),
args
.
GasPrice
.
Bytes
())
!=
0
{
if
args
.
GasPrice
!=
expected
.
GasPrice
{
// if bytes.Compare(expected.GasPrice.Bytes(), args.GasPrice.Bytes()) != 0 {
t
.
Errorf
(
"GasPrice shoud be %v but is %v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
t
.
Errorf
(
"GasPrice shoud be %v but is %v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
}
}
...
@@ -829,9 +831,10 @@ func TestCallArgsGasMissing(t *testing.T) {
...
@@ -829,9 +831,10 @@ func TestCallArgsGasMissing(t *testing.T) {
}
}
expected
:=
new
(
CallArgs
)
expected
:=
new
(
CallArgs
)
expected
.
Gas
=
big
.
NewInt
(
0
)
expected
.
Gas
=
nil
if
bytes
.
Compare
(
expected
.
Gas
.
Bytes
(),
args
.
Gas
.
Bytes
())
!=
0
{
if
args
.
Gas
!=
expected
.
Gas
{
// if bytes.Compare(expected.Gas.Bytes(), args.Gas.Bytes()) != 0 {
t
.
Errorf
(
"Gas shoud be %v but is %v"
,
expected
.
Gas
,
args
.
Gas
)
t
.
Errorf
(
"Gas shoud be %v but is %v"
,
expected
.
Gas
,
args
.
Gas
)
}
}
...
@@ -852,9 +855,10 @@ func TestCallArgsBlockGaspriceMissing(t *testing.T) {
...
@@ -852,9 +855,10 @@ func TestCallArgsBlockGaspriceMissing(t *testing.T) {
}
}
expected
:=
new
(
CallArgs
)
expected
:=
new
(
CallArgs
)
expected
.
GasPrice
=
big
.
NewInt
(
0
)
expected
.
GasPrice
=
nil
if
bytes
.
Compare
(
expected
.
GasPrice
.
Bytes
(),
args
.
GasPrice
.
Bytes
())
!=
0
{
if
args
.
GasPrice
!=
expected
.
GasPrice
{
// if bytes.Compare(expected.GasPrice.Bytes(), args.GasPrice.Bytes()) != 0 {
t
.
Errorf
(
"GasPrice shoud be %v but is %v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
t
.
Errorf
(
"GasPrice shoud be %v but is %v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
xeth/xeth.go
+
19
−
14
View file @
f371e6c8
...
@@ -885,12 +885,29 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
...
@@ -885,12 +885,29 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
from
=
common
.
HexToAddress
(
fromStr
)
from
=
common
.
HexToAddress
(
fromStr
)
to
=
common
.
HexToAddress
(
toStr
)
to
=
common
.
HexToAddress
(
toStr
)
value
=
common
.
Big
(
valueStr
)
value
=
common
.
Big
(
valueStr
)
gas
=
common
.
Big
(
gasStr
)
gas
*
big
.
Int
price
=
common
.
Big
(
gasPriceStr
)
price
*
big
.
Int
data
[]
byte
data
[]
byte
contractCreation
bool
contractCreation
bool
)
)
if
len
(
gasStr
)
==
0
{
gas
=
DefaultGas
()
}
else
{
gas
=
common
.
Big
(
gasStr
)
}
if
len
(
gasPriceStr
)
==
0
{
price
=
DefaultGasPrice
()
}
else
{
price
=
common
.
Big
(
gasPriceStr
)
}
data
=
common
.
FromHex
(
codeStr
)
if
len
(
toStr
)
==
0
{
contractCreation
=
true
}
// 2015-05-18 Is this still needed?
// 2015-05-18 Is this still needed?
// TODO if no_private_key then
// TODO if no_private_key then
//if _, exists := p.register[args.From]; exists {
//if _, exists := p.register[args.From]; exists {
...
@@ -916,18 +933,6 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
...
@@ -916,18 +933,6 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
// TODO: align default values to have the same type, e.g. not depend on
// TODO: align default values to have the same type, e.g. not depend on
// common.Value conversions later on
// common.Value conversions later on
if
gas
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
gas
=
DefaultGas
()
}
if
price
.
Cmp
(
big
.
NewInt
(
0
))
==
0
{
price
=
DefaultGasPrice
()
}
data
=
common
.
FromHex
(
codeStr
)
if
len
(
toStr
)
==
0
{
contractCreation
=
true
}
var
tx
*
types
.
Transaction
var
tx
*
types
.
Transaction
if
contractCreation
{
if
contractCreation
{
...
...
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