aboutsummaryrefslogtreecommitdiffstats
path: root/chain
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-11-29 04:44:34 +0800
committerobscuren <geffobscura@gmail.com>2014-11-29 04:44:34 +0800
commit1bce02eff70db43b98d68fcd094fd2e15745b021 (patch)
treea69acb327b4f71d59b297ca778450c128dce85f8 /chain
parent8cf9ed0ea588e97f2baf0f834248727e8fbca18f (diff)
parenta3559c5e1b469890bb8d71e9992175febaae31c7 (diff)
downloaddexon-1bce02eff70db43b98d68fcd094fd2e15745b021.tar
dexon-1bce02eff70db43b98d68fcd094fd2e15745b021.tar.gz
dexon-1bce02eff70db43b98d68fcd094fd2e15745b021.tar.bz2
dexon-1bce02eff70db43b98d68fcd094fd2e15745b021.tar.lz
dexon-1bce02eff70db43b98d68fcd094fd2e15745b021.tar.xz
dexon-1bce02eff70db43b98d68fcd094fd2e15745b021.tar.zst
dexon-1bce02eff70db43b98d68fcd094fd2e15745b021.zip
Fixed merge
Diffstat (limited to 'chain')
-rw-r--r--chain/block_manager.go7
-rw-r--r--chain/chain_manager.go2
-rw-r--r--chain/genesis.go2
-rw-r--r--chain/state_transition.go18
-rw-r--r--chain/types/block.go36
5 files changed, 33 insertions, 32 deletions
diff --git a/chain/block_manager.go b/chain/block_manager.go
index e652ad10e..4cc43840c 100644
--- a/chain/block_manager.go
+++ b/chain/block_manager.go
@@ -155,10 +155,11 @@ done:
}
}
+ txGas.Sub(txGas, st.gas)
+
// Update the state with pending changes
- state.Update()
+ state.Update(txGas)
- txGas.Sub(txGas, st.gas)
cumulative := new(big.Int).Set(totalUsedGas.Add(totalUsedGas, txGas))
receipt := types.NewReceipt(state.Root(), cumulative)
receipt.SetLogs(state.Logs())
@@ -247,7 +248,7 @@ func (sm *BlockManager) ProcessWithParent(block, parent *types.Block) (td *big.I
return
}
- state.Update()
+ state.Update(nil)
if !block.State().Cmp(state) {
err = fmt.Errorf("invalid merkle root. received=%x got=%x", block.Root(), state.Root())
diff --git a/chain/chain_manager.go b/chain/chain_manager.go
index 11e16fa7d..115acb1c8 100644
--- a/chain/chain_manager.go
+++ b/chain/chain_manager.go
@@ -112,8 +112,6 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *types.Block {
nil,
"")
- block.MinGasPrice = big.NewInt(10000000000000)
-
parent := bc.CurrentBlock
if parent != nil {
block.Difficulty = CalcDifficulty(block, parent)
diff --git a/chain/genesis.go b/chain/genesis.go
index 14117a82c..85e85d1ed 100644
--- a/chain/genesis.go
+++ b/chain/genesis.go
@@ -37,8 +37,6 @@ var GenesisHeader = []interface{}{
big.NewInt(131072),
// Number
ethutil.Big0,
- // Block minimum gas price
- ethutil.Big0,
// Block upper gas bound
big.NewInt(1000000),
// Block gas used
diff --git a/chain/state_transition.go b/chain/state_transition.go
index 789698675..53b1f6e2d 100644
--- a/chain/state_transition.go
+++ b/chain/state_transition.go
@@ -157,12 +157,24 @@ func (self *StateTransition) TransitionState() (err error) {
}
// Pay data gas
- dataPrice := big.NewInt(int64(len(self.data)))
- dataPrice.Mul(dataPrice, vm.GasData)
- if err = self.UseGas(dataPrice); err != nil {
+ var dgas int64
+ for _, byt := range self.data {
+ if byt != 0 {
+ dgas += vm.GasData.Int64()
+ } else {
+ dgas += 1 // This is 1/5. If GasData changes this fails
+ }
+ }
+ if err = self.UseGas(big.NewInt(dgas)); err != nil {
return
}
+ //dataPrice := big.NewInt(int64(len(self.data)))
+ //dataPrice.Mul(dataPrice, vm.GasData)
+ //if err = self.UseGas(dataPrice); err != nil {
+ // return
+ //}
+
if sender.Balance().Cmp(self.value) < 0 {
return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance)
}
diff --git a/chain/types/block.go b/chain/types/block.go
index b311433e3..5c8bb5f6c 100644
--- a/chain/types/block.go
+++ b/chain/types/block.go
@@ -84,8 +84,6 @@ type Block struct {
Time int64
// The block number
Number *big.Int
- // Minimum Gas Price
- MinGasPrice *big.Int
// Gas limit
GasLimit *big.Int
// Gas used
@@ -124,16 +122,15 @@ func CreateBlock(root interface{},
extra string) *Block {
block := &Block{
- PrevHash: prevHash,
- Coinbase: base,
- Difficulty: Difficulty,
- Nonce: Nonce,
- Time: time.Now().Unix(),
- Extra: extra,
- UncleSha: nil,
- GasUsed: new(big.Int),
- MinGasPrice: new(big.Int),
- GasLimit: new(big.Int),
+ PrevHash: prevHash,
+ Coinbase: base,
+ Difficulty: Difficulty,
+ Nonce: Nonce,
+ Time: time.Now().Unix(),
+ Extra: extra,
+ UncleSha: nil,
+ GasUsed: new(big.Int),
+ GasLimit: new(big.Int),
}
block.SetUncles([]*Block{})
@@ -300,12 +297,11 @@ func (self *Block) setHeader(header *ethutil.Value) {
self.LogsBloom = header.Get(6).Bytes()
self.Difficulty = header.Get(7).BigInt()
self.Number = header.Get(8).BigInt()
- self.MinGasPrice = header.Get(9).BigInt()
- self.GasLimit = header.Get(10).BigInt()
- self.GasUsed = header.Get(11).BigInt()
- self.Time = int64(header.Get(12).BigInt().Uint64())
- self.Extra = header.Get(13).Str()
- self.Nonce = header.Get(14).Bytes()
+ self.GasLimit = header.Get(9).BigInt()
+ self.GasUsed = header.Get(10).BigInt()
+ self.Time = int64(header.Get(11).BigInt().Uint64())
+ self.Extra = header.Get(12).Str()
+ self.Nonce = header.Get(13).Bytes()
}
func NewUncleBlockFromValue(header *ethutil.Value) *Block {
@@ -351,8 +347,6 @@ func (block *Block) miningHeader() []interface{} {
block.Difficulty,
// The block number
block.Number,
- // Block minimum gas price
- block.MinGasPrice,
// Block upper gas bound
block.GasLimit,
// Block gas used
@@ -380,7 +374,6 @@ func (block *Block) String() string {
Bloom: %x
Difficulty: %v
Number: %v
- MinGas: %v
MaxLimit: %v
GasUsed: %v
Time: %v
@@ -399,7 +392,6 @@ func (block *Block) String() string {
block.LogsBloom,
block.Difficulty,
block.Number,
- block.MinGasPrice,
block.GasLimit,
block.GasUsed,
block.Time,