Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to go-ethereum 1.8.1 #702

Merged
merged 9 commits into from
Feb 27, 2018
Prev Previous commit
Address comments in PR #702. Part of #638
  • Loading branch information
Pedro Pombeiro committed Feb 26, 2018
commit 53fac7f8a73a96885e3f61bc0cdf7feb4bc17cc8
6 changes: 3 additions & 3 deletions geth/common/rpccall.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ func (r RPCCall) ParseGas() *hexutil.Uint64 {
return nil
}

_v := hexutil.Uint64(parsedValue)
return &_v
v := hexutil.Uint64(parsedValue)
return &v
}

// ParseGasPrice returns the hex big associated with the call.
Expand Down Expand Up @@ -155,7 +155,7 @@ func (r RPCCall) ToSendTxArgs() SendTxArgs {
To: &toAddr,
From: fromAddr,
Value: r.ParseValue(),
Input: &input,
Input: input,
Gas: r.ParseGas(),
GasPrice: r.ParseGasPrice(),
}
Expand Down
7 changes: 3 additions & 4 deletions geth/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,16 @@ type QueuedTx struct {
}

// SendTxArgs represents the arguments to submit a new transaction into the transaction pool.
// This struct is based on go-ethereum's type in internal/ethapi/api.go, but we have freedom
// over the exact layout of this struct.
type SendTxArgs struct {
From common.Address `json:"from"`
To *common.Address `json:"to"`
Gas *hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice"`
Value *hexutil.Big `json:"value"`
Nonce *hexutil.Uint64 `json:"nonce"`
// We accept "data" and "input" for backwards-compatibility reasons. "input" is the
// newer name and should be preferred by clients.
Data *hexutil.Bytes `json:"data"`
Input *hexutil.Bytes `json:"input"`
Input hexutil.Bytes `json:"input"`
}

// JailCell represents single jail cell, which is basically a JavaScript VM.
Expand Down
6 changes: 0 additions & 6 deletions geth/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/pborman/uuid"
"github.com/status-im/status-go/geth/log"
"github.com/status-im/status-go/static"
Expand Down Expand Up @@ -144,11 +143,6 @@ func Fatalf(reason interface{}, args ...interface{}) {

// CreateTransaction returns a transaction object.
func CreateTransaction(ctx context.Context, args SendTxArgs) *QueuedTx {
if args.Input == nil && args.Data == nil {
// If neither Input nor Data were initialized, let's pass an empty slice in Input
emptyByteArray := hexutil.Bytes(make([]byte, 0))
args.Input = &emptyByteArray
}
return &QueuedTx{
ID: QueuedTxID(uuid.New()),
Context: ctx,
Expand Down
13 changes: 2 additions & 11 deletions geth/transactions/txqueue_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package transactions

import (
"context"
"errors"
"math/big"
"sync"
"time"
Expand Down Expand Up @@ -208,14 +207,6 @@ func (m *Manager) completeTransaction(config *params.NodeConfig, selectedAccount
}

chainID := big.NewInt(int64(config.NetworkID))
input := args.Input
if input == nil {
input = args.Data
}
if input == nil {
return hash, errors.New("Missing Input/Data byte array")
}
data := []byte(*input)
value := (*big.Int)(args.Value)
toAddr := gethcommon.Address{}
if args.To != nil {
Expand All @@ -231,7 +222,7 @@ func (m *Manager) completeTransaction(config *params.NodeConfig, selectedAccount
To: args.To,
GasPrice: gasPrice,
Value: value,
Data: data,
Data: args.Input,
})
if err != nil {
return hash, err
Expand All @@ -252,7 +243,7 @@ func (m *Manager) completeTransaction(config *params.NodeConfig, selectedAccount
"gasPrice", gasPrice,
"value", value,
)
tx := types.NewTransaction(nonce, toAddr, value, gas, gasPrice, data)
tx := types.NewTransaction(nonce, toAddr, value, gas, gasPrice, args.Input)
signedTx, err := types.SignTx(tx, types.NewEIP155Signer(chainID), selectedAccount.AccountKey.PrivateKey)
if err != nil {
return hash, err
Expand Down
19 changes: 1 addition & 18 deletions geth/transactions/txqueue_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,13 @@ func (s *TxQueueTestSuite) setupTransactionPoolAPI(tx *common.QueuedTx, returnNo
}

func (s *TxQueueTestSuite) rlpEncodeTx(tx *common.QueuedTx, config *params.NodeConfig, account *common.SelectedExtKey, nonce *hexutil.Uint64, gas hexutil.Uint64, gasPrice *big.Int) hexutil.Bytes {
input := tx.Args.Input
if input == nil {
input = tx.Args.Data
}
newTx := types.NewTransaction(
uint64(*nonce),
gethcommon.Address(*tx.Args.To),
tx.Args.Value.ToInt(),
uint64(gas),
gasPrice,
[]byte(*input),
[]byte(tx.Args.Input),
)
chainID := big.NewInt(int64(config.NetworkID))
signedTx, err := types.SignTx(newTx, types.NewEIP155Signer(chainID), account.AccountKey.PrivateKey)
Expand All @@ -142,41 +138,30 @@ func (s *TxQueueTestSuite) TestCompleteTransaction() {
Address: common.FromAddress(TestConfig.Account1.Address),
AccountKey: &keystore.Key{PrivateKey: key},
}
input := hexutil.Bytes(make([]byte, 0))
testCases := []struct {
name string
gas *hexutil.Uint64
gasPrice *hexutil.Big
data *hexutil.Bytes
input *hexutil.Bytes
}{
{
"noGasDef",
nil,
nil,
nil,
&input,
},
{
"gasDefined",
&testGas,
nil,
nil,
&input,
},
{
"gasPriceDefined",
nil,
testGasPrice,
nil,
&input,
},
{
"inputPassedInLegacyDataField",
nil,
testGasPrice,
&input,
nil,
},
}

Expand All @@ -189,8 +174,6 @@ func (s *TxQueueTestSuite) TestCompleteTransaction() {
To: common.ToAddress(TestConfig.Account2.Address),
Gas: testCase.gas,
GasPrice: testCase.gasPrice,
Data: testCase.data,
Input: testCase.input,
})
s.setupTransactionPoolAPI(tx, testNonce, testNonce, account, nil)

Expand Down
2 changes: 1 addition & 1 deletion t/e2e/transactions/transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (s *TransactionsTestSuite) TestSendContractTx() {
To: nil, // marker, contract creation is expected
//Value: (*hexutil.Big)(new(big.Int).Mul(big.NewInt(1), gethcommon.Ether)),
Gas: (*hexutil.Uint64)(&gas),
Input: (*hexutil.Bytes)(&byteCode),
Input: (hexutil.Bytes)(byteCode),
})
s.NoError(err, "cannot send transaction")

Expand Down