Merge branch 'develop' into feature/mnemonic
This commit is contained in:
commit
335dc9e687
@ -169,6 +169,8 @@ func (bc *BlockChain) ResetTillBlockHash(hash []byte) error {
|
|||||||
bc.LastBlockHash = bc.genesisBlock.Hash()
|
bc.LastBlockHash = bc.genesisBlock.Hash()
|
||||||
bc.LastBlockNumber = 1
|
bc.LastBlockNumber = 1
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: Somehow this doesn't really give the right numbers, double check.
|
||||||
|
// TODO: Change logs into debug lines
|
||||||
returnTo = bc.GetBlock(hash)
|
returnTo = bc.GetBlock(hash)
|
||||||
bc.CurrentBlock = returnTo
|
bc.CurrentBlock = returnTo
|
||||||
bc.LastBlockHash = returnTo.Hash()
|
bc.LastBlockHash = returnTo.Hash()
|
||||||
|
@ -112,16 +112,21 @@ func (sm *StateManager) ApplyTransactions(block *Block, txs []*Transaction) {
|
|||||||
// Figure out if the address this transaction was sent to is a
|
// Figure out if the address this transaction was sent to is a
|
||||||
// contract or an actual account. In case of a contract, we process that
|
// contract or an actual account. In case of a contract, we process that
|
||||||
// contract instead of moving funds between accounts.
|
// contract instead of moving funds between accounts.
|
||||||
|
var err error
|
||||||
if contract := sm.procState.GetContract(tx.Recipient); contract != nil {
|
if contract := sm.procState.GetContract(tx.Recipient); contract != nil {
|
||||||
|
err = sm.Ethereum.TxPool().ProcessTransaction(tx, block, true)
|
||||||
|
if err == nil {
|
||||||
sm.ProcessContract(contract, tx, block)
|
sm.ProcessContract(contract, tx, block)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
err := sm.Ethereum.TxPool().ProcessTransaction(tx, block)
|
err = sm.Ethereum.TxPool().ProcessTransaction(tx, block, false)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ethutil.Config.Log.Infoln("[STATE]", err)
|
ethutil.Config.Log.Infoln("[STATE]", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The prepare function, prepares the state manager for the next
|
// The prepare function, prepares the state manager for the next
|
||||||
@ -283,7 +288,7 @@ func (sm *StateManager) AccumelateRewards(block *Block) error {
|
|||||||
// Reward amount of ether to the coinbase address
|
// Reward amount of ether to the coinbase address
|
||||||
addr.AddFee(CalculateBlockReward(block, len(block.Uncles)))
|
addr.AddFee(CalculateBlockReward(block, len(block.Uncles)))
|
||||||
|
|
||||||
var acc []byte
|
acc := make([]byte, len(block.Coinbase))
|
||||||
copy(acc, block.Coinbase)
|
copy(acc, block.Coinbase)
|
||||||
sm.procState.UpdateAccount(acc, addr)
|
sm.procState.UpdateAccount(acc, addr)
|
||||||
|
|
||||||
@ -323,4 +328,7 @@ func (sm *StateManager) ProcessContract(contract *Contract, tx *Transaction, blo
|
|||||||
txData: nil,
|
txData: nil,
|
||||||
})
|
})
|
||||||
closure.Call(vm, nil)
|
closure.Call(vm, nil)
|
||||||
|
|
||||||
|
// Update the account (refunds)
|
||||||
|
sm.procState.UpdateAccount(tx.Sender(), caller)
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func (pool *TxPool) addTransaction(tx *Transaction) {
|
|||||||
|
|
||||||
// Process transaction validates the Tx and processes funds from the
|
// Process transaction validates the Tx and processes funds from the
|
||||||
// sender to the recipient.
|
// sender to the recipient.
|
||||||
func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error) {
|
func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract bool) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
log.Println(r)
|
log.Println(r)
|
||||||
@ -108,7 +108,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
|
|||||||
}
|
}
|
||||||
|
|
||||||
if sender.Nonce != tx.Nonce {
|
if sender.Nonce != tx.Nonce {
|
||||||
return fmt.Errorf("[TXPL] Invalid account nonce, state nonce is %d transactoin nonce is %d instead", sender.Nonce, tx.Nonce)
|
return fmt.Errorf("[TXPL] Invalid account nonce, state nonce is %d transaction nonce is %d instead", sender.Nonce, tx.Nonce)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the receiver
|
// Get the receiver
|
||||||
@ -119,6 +119,8 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block) (err error
|
|||||||
if bytes.Compare(tx.Recipient, tx.Sender()) == 0 {
|
if bytes.Compare(tx.Recipient, tx.Sender()) == 0 {
|
||||||
// Subtract the fee
|
// Subtract the fee
|
||||||
sender.Amount.Sub(sender.Amount, new(big.Int).Mul(TxFee, TxFeeRat))
|
sender.Amount.Sub(sender.Amount, new(big.Int).Mul(TxFee, TxFeeRat))
|
||||||
|
} else if toContract {
|
||||||
|
sender.Amount.Sub(sender.Amount, new(big.Int).Mul(TxFee, TxFeeRat))
|
||||||
} else {
|
} else {
|
||||||
// Subtract the amount from the senders account
|
// Subtract the amount from the senders account
|
||||||
sender.Amount.Sub(sender.Amount, totAmount)
|
sender.Amount.Sub(sender.Amount, totAmount)
|
||||||
|
@ -83,18 +83,23 @@ func TestRun4(t *testing.T) {
|
|||||||
state := NewState(ethutil.NewTrie(db, ""))
|
state := NewState(ethutil.NewTrie(db, ""))
|
||||||
|
|
||||||
asm, err := mutan.Compile(strings.NewReader(`
|
asm, err := mutan.Compile(strings.NewReader(`
|
||||||
a = 10
|
int32 a = 10
|
||||||
b = 10
|
int32 b = 10
|
||||||
if a == b {
|
if a == b {
|
||||||
c = 10
|
int32 c = 10
|
||||||
if c == 10 {
|
if c == 10 {
|
||||||
d = 1000
|
int32 d = 1000
|
||||||
e = 10
|
int32 e = 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store[0] = 20
|
store[0] = 20
|
||||||
store[a] = 20
|
store[a] = 20
|
||||||
|
store[b] = this.caller()
|
||||||
|
|
||||||
|
int8[10] ret
|
||||||
|
int8[10] arg
|
||||||
|
call(1234, 0, 100000000, arg, ret)
|
||||||
`), false)
|
`), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -105,6 +105,7 @@ func (miner *Miner) listener() {
|
|||||||
if found == false {
|
if found == false {
|
||||||
log.Println("[MINER] We did not know about this transaction, adding")
|
log.Println("[MINER] We did not know about this transaction, adding")
|
||||||
miner.txs = append(miner.txs, tx)
|
miner.txs = append(miner.txs, tx)
|
||||||
|
miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs)
|
||||||
miner.block.SetTransactions(miner.txs)
|
miner.block.SetTransactions(miner.txs)
|
||||||
} else {
|
} else {
|
||||||
log.Println("[MINER] We already had this transaction, ignoring")
|
log.Println("[MINER] We already had this transaction, ignoring")
|
||||||
|
Loading…
Reference in New Issue
Block a user