Compare commits

..

4 Commits

Author SHA1 Message Date
a0303ff4bd cmd/geth: bumped version 1.0.2 2015-08-20 21:41:39 +02:00
bf2d4e1e1e Merge branch 'release/1.0.1' 2015-08-20 20:58:10 +02:00
82ef26f600 Merge branch 'develop' 2015-08-05 18:41:08 +02:00
ee5728ec03 fake commit for build server :( 2015-08-05 18:41:00 +02:00
3 changed files with 28 additions and 29 deletions

View File

@ -50,11 +50,11 @@ import (
const (
ClientIdentifier = "Geth"
Version = "1.0.3"
Version = "1.0.2"
)
var (
gitCommit string // set via linker flag
gitCommit string // set via linker flagg
nodeNameVersion string
app *cli.App
)

View File

@ -57,18 +57,6 @@ 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, extra common.Database, pow pow.PoW, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
sm := &BlockProcessor{
db: db,
@ -78,15 +66,16 @@ func NewBlockProcessor(db, extra common.Database, pow pow.PoW, chainManager *Cha
bc: chainManager,
eventMux: eventMux,
}
return sm
}
func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block, transientProcess bool) (receipts types.Receipts, err error) {
gp := statedb.GetOrNewStateObject(block.Coinbase())
gp.SetGasLimit(block.GasLimit())
coinbase := statedb.GetOrNewStateObject(block.Coinbase())
coinbase.SetGasLimit(block.GasLimit())
// Process the transactions on to parent state
receipts, err = sm.ApplyTransactions(gp, statedb, block, block.Transactions(), transientProcess)
receipts, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess)
if err != nil {
return nil, err
}
@ -94,8 +83,11 @@ func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block
return receipts, nil
}
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)
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) {
// If we are mining this block and validating we want to set the logs back to 0
cb := statedb.GetStateObject(coinbase.Address())
_, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb)
if err != nil {
return nil, nil, err
}
@ -130,7 +122,7 @@ func (self *BlockProcessor) ChainManager() *ChainManager {
return self.bc
}
func (self *BlockProcessor) ApplyTransactions(gp GasPool, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) {
func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, statedb *state.StateDB, block *types.Block, txs types.Transactions, transientProcess bool) (types.Receipts, error) {
var (
receipts types.Receipts
totalUsedGas = big.NewInt(0)
@ -142,7 +134,7 @@ func (self *BlockProcessor) ApplyTransactions(gp GasPool, statedb *state.StateDB
for i, tx := range txs {
statedb.StartRecord(tx.Hash(), block.Hash(), i)
receipt, txGas, err := self.ApplyTransaction(gp, statedb, header, tx, totalUsedGas, transientProcess)
receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, header, tx, totalUsedGas, transientProcess)
if err != nil {
return nil, err
}

View File

@ -45,7 +45,7 @@ import (
* 6) Derive new state root
*/
type StateTransition struct {
gp GasPool
coinbase common.Address
msg Message
gas, gasPrice *big.Int
initialGas *big.Int
@ -53,6 +53,8 @@ type StateTransition struct {
data []byte
state *state.StateDB
cb, rec, sen *state.StateObject
env vm.Environment
}
@ -94,13 +96,13 @@ func IntrinsicGas(data []byte) *big.Int {
return igas
}
func ApplyMessage(env vm.Environment, msg Message, gp GasPool) ([]byte, *big.Int, error) {
return NewStateTransition(env, msg, gp).transitionState()
func ApplyMessage(env vm.Environment, msg Message, coinbase *state.StateObject) ([]byte, *big.Int, error) {
return NewStateTransition(env, msg, coinbase).transitionState()
}
func NewStateTransition(env vm.Environment, msg Message, gp GasPool) *StateTransition {
func NewStateTransition(env vm.Environment, msg Message, coinbase *state.StateObject) *StateTransition {
return &StateTransition{
gp: gp,
coinbase: coinbase.Address(),
env: env,
msg: msg,
gas: new(big.Int),
@ -109,9 +111,13 @@ func NewStateTransition(env vm.Environment, msg Message, gp GasPool) *StateTrans
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 {
@ -154,7 +160,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.gp.SubGas(mgas, self.gasPrice); err != nil {
if err = self.Coinbase().SubGas(mgas, self.gasPrice); err != nil {
return err
}
self.AddGas(mgas)
@ -235,12 +241,13 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er
}
self.refundGas()
self.state.AddBalance(self.env.Coinbase(), new(big.Int).Mul(self.gasUsed(), self.gasPrice))
self.state.AddBalance(self.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)
@ -251,7 +258,7 @@ func (self *StateTransition) refundGas() {
self.gas.Add(self.gas, refund)
self.state.AddBalance(sender.Address(), refund.Mul(refund, self.gasPrice))
self.gp.AddGas(self.gas, self.gasPrice)
coinbase.AddGas(self.gas, self.gasPrice)
}
func (self *StateTransition) gasUsed() *big.Int {