aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Godeps/Godeps.json5
-rwxr-xr-x[-rw-r--r--]Godeps/_workspace/src/github.com/ethereum/ethash/setup.py0
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h4
-rw-r--r--Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h4
-rwxr-xr-x[-rw-r--r--]Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh0
-rwxr-xr-x[-rw-r--r--]Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh0
-rwxr-xr-x[-rw-r--r--]Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh0
-rw-r--r--Godeps/_workspace/src/github.com/mattn/go-isatty/LICENSE9
-rw-r--r--Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go2
-rw-r--r--core/block_processor.go28
-rw-r--r--core/filter.go6
-rw-r--r--core/state_transition.go23
12 files changed, 50 insertions, 31 deletions
diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json
index d5c41227d..c939ae670 100644
--- a/Godeps/Godeps.json
+++ b/Godeps/Godeps.json
@@ -21,8 +21,7 @@
},
{
"ImportPath": "github.com/ethereum/ethash",
- "Comment": "v23.1-227-g8f6ccaa",
- "Rev": "8f6ccaaef9b418553807a73a95cb5f49cd3ea39f"
+ "Rev": "227ec953eae56f4f6c7f5e7dc93b4bbebf0cda2e"
},
{
"ImportPath": "github.com/fatih/color",
@@ -51,7 +50,7 @@
},
{
"ImportPath": "github.com/mattn/go-isatty",
- "Rev": "fdbe02a1b44e75977b2690062b83cf507d70c013"
+ "Rev": "7fcbc72f853b92b5720db4a6b8482be612daef24"
},
{
"ImportPath": "github.com/mattn/go-runewidth",
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py b/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
index 18aa20f6d..18aa20f6d 100644..100755
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/setup.py
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h
index 6ca6cc036..e32b1c539 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/endian.h
@@ -35,6 +35,10 @@
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)
#define ethash_swap_u32(input_) bswap32(input_)
#define ethash_swap_u64(input_) bswap64(input_)
+#elif defined(__OpenBSD__)
+#include <endian.h>
+#define ethash_swap_u32(input_) swap32(input_)
+#define ethash_swap_u64(input_) swap64(input_)
#else // posix
#include <byteswap.h>
#define ethash_swap_u32(input_) __bswap_32(input_)
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h
index d23c4e247..82cd655c4 100644
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/src/libethash/fnv.h
@@ -29,6 +29,10 @@ extern "C" {
#define FNV_PRIME 0x01000193
+/* The FNV-1 spec multiplies the prime with the input one byte (octet) in turn.
+ We instead multiply it with the full 32-bit input.
+ This gives a different result compared to a canonical FNV-1 implementation.
+*/
static inline uint32_t fnv_hash(uint32_t const x, uint32_t const y)
{
return x * FNV_PRIME ^ y;
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh b/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh
index 92b6b8b66..92b6b8b66 100644..100755
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/c/test.sh
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh
index 05c66b550..05c66b550 100644..100755
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/python/test.sh
diff --git a/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh b/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
index aaeaa878c..aaeaa878c 100644..100755
--- a/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
+++ b/Godeps/_workspace/src/github.com/ethereum/ethash/test/test.sh
diff --git a/Godeps/_workspace/src/github.com/mattn/go-isatty/LICENSE b/Godeps/_workspace/src/github.com/mattn/go-isatty/LICENSE
new file mode 100644
index 000000000..65dc692b6
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/mattn/go-isatty/LICENSE
@@ -0,0 +1,9 @@
+Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
+
+MIT License (Expat)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go b/Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go
index 035274751..e6282b529 100644
--- a/Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go
+++ b/Godeps/_workspace/src/github.com/mattn/go-isatty/isatty_bsd.go
@@ -1,4 +1,4 @@
-// +build darwin freebsd
+// +build darwin freebsd openbsd netbsd
package isatty
diff --git a/core/block_processor.go b/core/block_processor.go
index 99d27fa71..1238fda7b 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -56,6 +56,18 @@ type BlockProcessor struct {
eventMux *event.TypeMux
}
+// TODO: type GasPool big.Int
+//
+// GasPool is implemented by state.StateObject. This is a historical
+// coincidence. Gas tracking should move out of StateObject.
+
+// GasPool tracks the amount of gas available during
+// execution of the transactions in a block.
+type GasPool interface {
+ AddGas(gas, price *big.Int)
+ SubGas(gas, price *big.Int) error
+}
+
func NewBlockProcessor(db common.Database, pow pow.PoW, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
sm := &BlockProcessor{
chainDb: db,
@@ -64,16 +76,15 @@ func NewBlockProcessor(db common.Database, pow pow.PoW, chainManager *ChainManag
bc: chainManager,
eventMux: eventMux,
}
-
return sm
}
func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block, transientProcess bool) (receipts types.Receipts, err error) {
- coinbase := statedb.GetOrNewStateObject(block.Coinbase())
- coinbase.SetGasLimit(block.GasLimit())
+ gp := statedb.GetOrNewStateObject(block.Coinbase())
+ gp.SetGasLimit(block.GasLimit())
// Process the transactions on to parent state
- receipts, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess)
+ receipts, err = sm.ApplyTransactions(gp, statedb, block, block.Transactions(), transientProcess)
if err != nil {
return nil, err
}
@@ -81,9 +92,8 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
return receipts, nil
}
-func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, transientProcess bool) (*types.Receipt, *big.Int, error) {
- cb := statedb.GetStateObject(coinbase.Address())
- _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb)
+func (self *BlockProcessor) ApplyTransaction(gp GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *big.Int, transientProcess bool) (*types.Receipt, *big.Int, error) {
+ _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, gp)
if err != nil {
return nil, nil, err
}
@@ -118,7 +128,7 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
return self.bc
}
-func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) {
+func (self *BlockProcessor) ApplyTransactions(gp GasPool, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) {
var (
receipts types.Receipts
totalUsedGas = big.NewInt(0)
@@ -130,7 +140,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state
for i, tx := range txs {
statedb.StartRecord(tx.Hash(), block.Hash(), i)
- receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, header, tx, totalUsedGas, transientProcess)
+ receipt, txGas, err := self.ApplyTransaction(gp, statedb, header, tx, totalUsedGas, transientProcess)
if err != nil {
return nil, err
}
diff --git a/core/filter.go b/core/filter.go
index c34d6ff6c..b328ffff3 100644
--- a/core/filter.go
+++ b/core/filter.go
@@ -131,12 +131,12 @@ done:
func includes(addresses []common.Address, a common.Address) bool {
for _, addr := range addresses {
- if addr != a {
- return false
+ if addr == a {
+ return true
}
}
- return true
+ return false
}
func (self *Filter) FilterLogs(logs state.Logs) state.Logs {
diff --git a/core/state_transition.go b/core/state_transition.go
index a5d4fc19b..6ff7fa1ff 100644
--- a/core/state_transition.go
+++ b/core/state_transition.go
@@ -45,7 +45,7 @@ import (
* 6) Derive new state root
*/
type StateTransition struct {
- coinbase common.Address
+ gp GasPool
msg Message
gas, gasPrice *big.Int
initialGas *big.Int
@@ -53,8 +53,6 @@ type StateTransition struct {
data []byte
state *state.StateDB
- cb, rec, sen *state.StateObject
-
env vm.Environment
}
@@ -96,13 +94,13 @@ func IntrinsicGas(data []byte) *big.Int {
return igas
}
-func ApplyMessage(env vm.Environment, msg Message, coinbase *state.StateObject) ([]byte, *big.Int, error) {
- return NewStateTransition(env, msg, coinbase).transitionState()
+func ApplyMessage(env vm.Environment, msg Message, gp GasPool) ([]byte, *big.Int, error) {
+ return NewStateTransition(env, msg, gp).transitionState()
}
-func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateObject) *StateTransition {
+func NewStateTransition(env vm.Environment, msg Message, gp GasPool) *StateTransition {
return &StateTransition{
- coinbase: coinbase.Address(),
+ gp: gp,
env: env,
msg: msg,
gas: new(big.Int),
@@ -111,13 +109,9 @@ func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateOb
value: msg.Value(),
data: msg.Data(),
state: env.State(),
- cb: coinbase,
}
}
-func (self *StateTransition) Coinbase() *state.StateObject {
- return self.state.GetOrNewStateObject(self.coinbase)
-}
func (self *StateTransition) From() (*state.StateObject, error) {
f, err := self.msg.From()
if err != nil {
@@ -160,7 +154,7 @@ func (self *StateTransition) BuyGas() error {
if sender.Balance().Cmp(mgval) < 0 {
return fmt.Errorf("insufficient ETH for gas (%x). Req %v, has %v", sender.Address().Bytes()[:4], mgval, sender.Balance())
}
- if err = self.Coinbase().SubGas(mgas, self.gasPrice); err != nil {
+ if err = self.gp.SubGas(mgas, self.gasPrice); err != nil {
return err
}
self.AddGas(mgas)
@@ -241,13 +235,12 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
self.refundGas()
- self.state.AddBalance(self.coinbase, new(big.Int).Mul(self.gasUsed(), self.gasPrice))
+ self.state.AddBalance(self.env.Coinbase(), new(big.Int).Mul(self.gasUsed(), self.gasPrice))
return ret, self.gasUsed(), err
}
func (self *StateTransition) refundGas() {
- coinbase := self.Coinbase()
sender, _ := self.From() // err already checked
// Return remaining gas
remaining := new(big.Int).Mul(self.gas, self.gasPrice)
@@ -258,7 +251,7 @@ func (self *StateTransition) refundGas() {
self.gas.Add(self.gas, refund)
self.state.AddBalance(sender.Address(), refund.Mul(refund, self.gasPrice))
- coinbase.AddGas(self.gas, self.gasPrice)
+ self.gp.AddGas(self.gas, self.gasPrice)
}
func (self *StateTransition) gasUsed() *big.Int {