From 147a699c6543b1e4ec8c933f8aaff4e0639897b6 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Mon, 1 Jun 2015 22:00:48 +0200 Subject: Add missing err checks on From() (skip RPC for now) --- xeth/types.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'xeth') diff --git a/xeth/types.go b/xeth/types.go index 1be5e109c..3bb1447ca 100644 --- a/xeth/types.go +++ b/xeth/types.go @@ -139,6 +139,10 @@ type Transaction struct { } func NewTx(tx *types.Transaction) *Transaction { + sender, err := tx.From() + if err != nil { + return nil + } hash := tx.Hash().Hex() var receiver string @@ -147,7 +151,6 @@ func NewTx(tx *types.Transaction) *Transaction { } else { receiver = core.AddressFromMessage(tx).Hex() } - sender, _ := tx.From() createsContract := core.MessageCreatesContract(tx) var data string -- cgit v1.2.3 From d09a6e54215bef8b1ac16a99f0b1d75a8a92a6a8 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 3 Jun 2015 22:22:20 +0200 Subject: core, eth, miner: moved nonce management to tx pool. Removed the managed tx state from the chain manager to the transaction pool where it's much easier to keep track of nonces (and manage them). The transaction pool now also uses the queue and pending txs differently where queued txs are now moved over to the pending queue (i.e. txs ready for processing and propagation). --- xeth/xeth.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 157fe76c7..187892a49 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -936,22 +936,22 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS tx = types.NewTransactionMessage(to, value, gas, price, data) } - state := self.backend.ChainManager().TxState() + state := self.backend.TxPool().State() var nonce uint64 if len(nonceStr) != 0 { nonce = common.Big(nonceStr).Uint64() } else { - nonce = state.NewNonce(from) + nonce = state.GetNonce(from) + 1 //state.NewNonce(from) } tx.SetNonce(nonce) if err := self.sign(tx, from, false); err != nil { - state.RemoveNonce(from, tx.Nonce()) + //state.RemoveNonce(from, tx.Nonce()) return "", err } if err := self.backend.TxPool().Add(tx); err != nil { - state.RemoveNonce(from, tx.Nonce()) + //state.RemoveNonce(from, tx.Nonce()) return "", err } -- cgit v1.2.3 From 36c0db2ac9e1505bfcb29a137f67ba31efde4c90 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 4 Jun 2015 11:35:37 +0200 Subject: xeth: use the correct nonce for creating transactions --- xeth/xeth.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 187892a49..d0d51bfe0 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -942,18 +942,17 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS if len(nonceStr) != 0 { nonce = common.Big(nonceStr).Uint64() } else { - nonce = state.GetNonce(from) + 1 //state.NewNonce(from) + nonce = state.GetNonce(from) } tx.SetNonce(nonce) if err := self.sign(tx, from, false); err != nil { - //state.RemoveNonce(from, tx.Nonce()) return "", err } if err := self.backend.TxPool().Add(tx); err != nil { - //state.RemoveNonce(from, tx.Nonce()) return "", err } + state.SetNonce(from, nonce+1) if contractCreation { addr := core.AddressFromMessage(tx) -- cgit v1.2.3 From c8a9a4e76d00483280a51bb6c0f9517d6c531589 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 29 May 2015 14:27:15 -0500 Subject: Differentiate between 0 and unspecified gas/gasprice --- xeth/xeth.go | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index d0d51bfe0..9b49b412c 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -885,12 +885,29 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS from = common.HexToAddress(fromStr) to = common.HexToAddress(toStr) value = common.Big(valueStr) - gas = common.Big(gasStr) - price = common.Big(gasPriceStr) + gas *big.Int + price *big.Int data []byte 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? // TODO if no_private_key then //if _, exists := p.register[args.From]; exists { @@ -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 // 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 if contractCreation { -- cgit v1.2.3 From bc6031e7bb453ec7e1f229b39e11967a8b32175a Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 9 Jun 2015 18:14:46 +0200 Subject: core, xeth: moved nonce management burden from xeth to txpool --- xeth/xeth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 9b49b412c..d2f992084 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -957,7 +957,7 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS if err := self.backend.TxPool().Add(tx); err != nil { return "", err } - state.SetNonce(from, nonce+1) + //state.SetNonce(from, nonce+1) if contractCreation { addr := core.AddressFromMessage(tx) -- cgit v1.2.3