From 4c490db6afeb5a48d3e8d1d65ea8ddc9811d0a6d Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Tue, 30 Jun 2015 09:13:16 +0200 Subject: Use uint64 for block header timestamp --- core/block_processor.go | 15 +++++++-------- core/chain_makers.go | 2 +- core/chain_manager.go | 2 +- core/types/block.go | 2 +- core/types/block_test.go | 2 +- core/vm/environment.go | 2 +- core/vm/vm.go | 2 +- core/vm_env.go | 2 +- 8 files changed, 14 insertions(+), 15 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 22d4c7c27..9b77d10eb 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -362,6 +362,13 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check return fmt.Errorf("Block extra data too long (%d)", len(block.Extra)) } + if block.Time > uint64(time.Now().Unix()) { + return BlockFutureErr + } + if block.Time <= parent.Time() { + return BlockEqualTSErr + } + expd := CalcDifficulty(int64(block.Time), int64(parent.Time()), parent.Difficulty()) if expd.Cmp(block.Difficulty) != 0 { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Difficulty, expd) @@ -377,20 +384,12 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b) } - if int64(block.Time) > time.Now().Unix() { - return BlockFutureErr - } - num := parent.Number() num.Sub(block.Number, num) if num.Cmp(big.NewInt(1)) != 0 { return BlockNumberErr } - if block.Time <= uint64(parent.Time()) { - return BlockEqualTSErr //ValidationError("Block timestamp equal or less than previous block (%v - %v)", block.Time, parent.Time) - } - if checkPow { // Verify the nonce of the block. Return an error if it's not valid if !pow.Verify(types.NewBlockWithHeader(block)) { diff --git a/core/chain_makers.go b/core/chain_makers.go index 72ae7970e..013251d74 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -155,7 +155,7 @@ func makeHeader(parent *types.Block, state *state.StateDB) *types.Header { Root: state.Root(), ParentHash: parent.Hash(), Coinbase: parent.Coinbase(), - Difficulty: CalcDifficulty(time, parent.Time(), parent.Difficulty()), + Difficulty: CalcDifficulty(int64(time), int64(parent.Time()), parent.Difficulty()), GasLimit: CalcGasLimit(parent), GasUsed: new(big.Int), Number: new(big.Int).Add(parent.Number(), common.Big1), diff --git a/core/chain_manager.go b/core/chain_manager.go index c89aae3f0..cdbdeb5ae 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -658,7 +658,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { // Allow up to MaxFuture second in the future blocks. If this limit // is exceeded the chain is discarded and processed at a later time // if given. - if max := time.Now().Unix() + maxTimeFutureBlocks; block.Time() > max { + if max := time.Now().Unix() + maxTimeFutureBlocks; int64(block.Time()) > max { return i, fmt.Errorf("%v: BlockFutureErr, %v > %v", BlockFutureErr, block.Time(), max) } diff --git a/core/types/block.go b/core/types/block.go index b7eb700ca..e8919e9a0 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -290,7 +290,7 @@ func (b *Block) MixDigest() common.Hash { return b.header.MixDigest } func (b *Block) Nonce() uint64 { return binary.BigEndian.Uint64(b.header.Nonce[:]) } func (b *Block) Bloom() Bloom { return b.header.Bloom } func (b *Block) Coinbase() common.Address { return b.header.Coinbase } -func (b *Block) Time() int64 { return int64(b.header.Time) } +func (b *Block) Time() uint64 { return b.header.Time } func (b *Block) Root() common.Hash { return b.header.Root } func (b *Block) ParentHash() common.Hash { return b.header.ParentHash } func (b *Block) TxHash() common.Hash { return b.header.TxHash } diff --git a/core/types/block_test.go b/core/types/block_test.go index 03e6881be..e0b98cd26 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -31,7 +31,7 @@ func TestBlockEncoding(t *testing.T) { check("Root", block.Root(), common.HexToHash("ef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017")) check("Hash", block.Hash(), common.HexToHash("0a5843ac1cb04865017cb35a57b50b07084e5fcee39b5acadade33149f4fff9e")) check("Nonce", block.Nonce(), uint64(0xa13a5a8c8f2bb1c4)) - check("Time", block.Time(), int64(1426516743)) + check("Time", block.Time(), uint64(1426516743)) check("Size", block.Size(), common.StorageSize(len(blockEnc))) tx1 := NewTransaction(0, common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), big.NewInt(10), big.NewInt(50000), big.NewInt(10), nil) diff --git a/core/vm/environment.go b/core/vm/environment.go index c103049a2..0a5891f5c 100644 --- a/core/vm/environment.go +++ b/core/vm/environment.go @@ -17,7 +17,7 @@ type Environment interface { BlockNumber() *big.Int GetHash(n uint64) common.Hash Coinbase() common.Address - Time() int64 + Time() uint64 Difficulty() *big.Int GasLimit() *big.Int Transfer(from, to Account, amount *big.Int) error diff --git a/core/vm/vm.go b/core/vm/vm.go index 9e092300d..ba803683b 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -444,7 +444,7 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) { case TIMESTAMP: time := self.env.Time() - stack.push(big.NewInt(time)) + stack.push(new(big.Int).SetUint64(time)) case NUMBER: number := self.env.BlockNumber() diff --git a/core/vm_env.go b/core/vm_env.go index 6dd83acde..24a29545f 100644 --- a/core/vm_env.go +++ b/core/vm_env.go @@ -33,7 +33,7 @@ func NewEnv(state *state.StateDB, chain *ChainManager, msg Message, header *type func (self *VMEnv) Origin() common.Address { f, _ := self.msg.From(); return f } func (self *VMEnv) BlockNumber() *big.Int { return self.header.Number } func (self *VMEnv) Coinbase() common.Address { return self.header.Coinbase } -func (self *VMEnv) Time() int64 { return int64(self.header.Time) } +func (self *VMEnv) Time() uint64 { return self.header.Time } func (self *VMEnv) Difficulty() *big.Int { return self.header.Difficulty } func (self *VMEnv) GasLimit() *big.Int { return self.header.GasLimit } func (self *VMEnv) Value() *big.Int { return self.msg.Value() } -- cgit v1.2.3 From 61ca780f3ba21ef1e62aab545160de12cbbf45bf Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 30 Jun 2015 11:04:30 +0200 Subject: core: reduce CPU load by reducing calls to checkQueue * Reduced maxQueue count * Added proper deletion past maxQueue limit * Added cheap stats method to txpool queueCheck was called for **every** transaction instead of: 1. add all txs 2. check queue previously 1. add txs[i] 2. check queue 3. if i < len(txs) goto 1. --- core/transaction_pool.go | 75 ++++++++++++++++++++++++++++--------------- core/transaction_pool_test.go | 2 ++ 2 files changed, 51 insertions(+), 26 deletions(-) (limited to 'core') diff --git a/core/transaction_pool.go b/core/transaction_pool.go index bf28647c3..6a7012c65 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -29,7 +29,7 @@ var ( ) const ( - maxQueued = 200 // max limit of queued txs per address + maxQueued = 64 // max limit of queued txs per address ) type stateFn func() *state.StateDB @@ -129,6 +129,17 @@ func (pool *TxPool) State() *state.ManagedState { return pool.pendingState } +func (pool *TxPool) Stats() (pending int, queued int) { + pool.mu.RLock() + defer pool.mu.RUnlock() + + pending = len(pool.pending) + for _, txs := range pool.queue { + queued += len(txs) + } + return +} + // validateTx checks whether a transaction is valid according // to the consensus rules. func (pool *TxPool) validateTx(tx *types.Transaction) error { @@ -214,9 +225,6 @@ func (self *TxPool) add(tx *types.Transaction) error { glog.Infof("(t) %x => %s (%v) %x\n", from, toname, tx.Value, hash) } - // check and validate the queueue - self.checkQueue() - return nil } @@ -245,11 +253,17 @@ func (pool *TxPool) addTx(hash common.Hash, addr common.Address, tx *types.Trans } // Add queues a single transaction in the pool if it is valid. -func (self *TxPool) Add(tx *types.Transaction) error { +func (self *TxPool) Add(tx *types.Transaction) (err error) { self.mu.Lock() defer self.mu.Unlock() - return self.add(tx) + err = self.add(tx) + if err == nil { + // check and validate the queueue + self.checkQueue() + } + + return } // AddTransactions attempts to queue all valid transactions in txs. @@ -265,6 +279,9 @@ func (self *TxPool) AddTransactions(txs []*types.Transaction) { glog.V(logger.Debug).Infof("tx %x\n", h[:4]) } } + + // check and validate the queueue + self.checkQueue() } // GetTransaction returns a transaction if it is contained in the pool @@ -327,6 +344,23 @@ func (self *TxPool) RemoveTransactions(txs types.Transactions) { } } +func (pool *TxPool) removeTx(hash common.Hash) { + // delete from pending pool + delete(pool.pending, hash) + // delete from queue + for address, txs := range pool.queue { + if _, ok := txs[hash]; ok { + if len(txs) == 1 { + // if only one tx, remove entire address entry. + delete(pool.queue, address) + } else { + delete(txs, hash) + } + break + } + } +} + // checkQueue moves transactions that have become processable to main pool. func (pool *TxPool) checkQueue() { state := pool.pendingState @@ -354,13 +388,19 @@ func (pool *TxPool) checkQueue() { for i, e := range addq { // start deleting the transactions from the queue if they exceed the limit if i > maxQueued { - if glog.V(logger.Debug) { - glog.Infof("Queued tx limit exceeded for %s. Tx %s removed\n", common.PP(address[:]), common.PP(e.hash[:])) - } delete(pool.queue[address], e.hash) continue } + if e.Nonce() > guessedNonce { + if len(addq)-i > maxQueued { + if glog.V(logger.Debug) { + glog.Infof("Queued tx limit exceeded for %s. Tx %s removed\n", common.PP(address[:]), common.PP(e.hash[:])) + } + for j := i + maxQueued; j < len(addq); j++ { + delete(txs, addq[j].hash) + } + } break } delete(txs, e.hash) @@ -373,23 +413,6 @@ func (pool *TxPool) checkQueue() { } } -func (pool *TxPool) removeTx(hash common.Hash) { - // delete from pending pool - delete(pool.pending, hash) - // delete from queue - for address, txs := range pool.queue { - if _, ok := txs[hash]; ok { - if len(txs) == 1 { - // if only one tx, remove entire address entry. - delete(pool.queue, address) - } else { - delete(txs, hash) - } - break - } - } -} - // validatePool removes invalid and processed transactions from the main pool. func (pool *TxPool) validatePool() { state := pool.currentState() diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index ff8b9c730..5744ef059 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -181,6 +181,8 @@ func TestTransactionDoubleNonce(t *testing.T) { if err := pool.add(tx2); err != nil { t.Error("didn't expect error", err) } + + pool.checkQueue() if len(pool.pending) != 2 { t.Error("expected 2 pending txs. Got", len(pool.pending)) } -- cgit v1.2.3 From c14f0a44712891286b291761fb2d99bd90646234 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 30 Jun 2015 13:46:37 +0200 Subject: core: added checkpoint for last block * Add a checkpoint every X blocks * Removed queued write --- core/chain_manager.go | 97 ++++++++++++++++++++-------------------------- core/chain_manager_test.go | 3 +- 2 files changed, 42 insertions(+), 58 deletions(-) (limited to 'core') diff --git a/core/chain_manager.go b/core/chain_manager.go index 808ccd201..c89aae3f0 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -11,10 +11,8 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/compression/rle" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" @@ -23,7 +21,6 @@ import ( "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/rlp" "github.com/hashicorp/golang-lru" - "github.com/syndtr/goleveldb/leveldb" ) var ( @@ -40,6 +37,7 @@ const ( blockCacheLimit = 256 maxFutureBlocks = 256 maxTimeFutureBlocks = 30 + checkpointLimit = 200 ) // CalcDifficulty is the difficulty adjustment algorithm. It returns @@ -101,6 +99,7 @@ type ChainManager struct { chainmu sync.RWMutex tsmu sync.RWMutex + checkpoint int // checkpoint counts towards the new checkpoint td *big.Int currentBlock *types.Block lastBlockHash common.Hash @@ -109,9 +108,8 @@ type ChainManager struct { transState *state.StateDB txState *state.ManagedState - cache *lru.Cache // cache is the LRU caching - futureBlocks *lru.Cache // future blocks are blocks added for later processing - pendingBlocks *lru.Cache // pending blocks contain blocks not yet written to the db + cache *lru.Cache // cache is the LRU caching + futureBlocks *lru.Cache // future blocks are blocks added for later processing quit chan struct{} // procInterrupt must be atomically called @@ -240,15 +238,40 @@ func (self *ChainManager) setTransState(statedb *state.StateDB) { self.transState = statedb } +func (bc *ChainManager) recover() bool { + data, _ := bc.blockDb.Get([]byte("checkpoint")) + if len(data) != 0 { + block := bc.GetBlock(common.BytesToHash(data)) + if block != nil { + err := bc.blockDb.Put([]byte("LastBlock"), block.Hash().Bytes()) + if err != nil { + glog.Fatalln("db write err:", err) + } + + bc.currentBlock = block + bc.lastBlockHash = block.Hash() + return true + } + } + return false +} + func (bc *ChainManager) setLastState() { data, _ := bc.blockDb.Get([]byte("LastBlock")) if len(data) != 0 { block := bc.GetBlock(common.BytesToHash(data)) if block != nil { + bc.blockDb.Put([]byte("checkpoint"), block.Hash().Bytes()) + bc.currentBlock = block bc.lastBlockHash = block.Hash() } else { - glog.Fatalf("Fatal. LastBlock not found. Please run removedb and resync") + glog.Infof("LastBlock (%x) not found. Recovering...\n", data) + if bc.recover() { + glog.Infof("Recover successful") + } else { + glog.Fatalf("Recover failed. Please report") + } } } else { bc.Reset() @@ -357,6 +380,16 @@ func (bc *ChainManager) insert(block *types.Block) { glog.Fatal("db write fail:", err) } + bc.checkpoint++ + if bc.checkpoint > checkpointLimit { + err = bc.blockDb.Put([]byte("checkpoint"), block.Hash().Bytes()) + if err != nil { + glog.Fatal("db write fail:", err) + } + + bc.checkpoint = 0 + } + bc.currentBlock = block bc.lastBlockHash = block.Hash() } @@ -387,12 +420,6 @@ func (bc *ChainManager) HasBlock(hash common.Hash) bool { return true } - if bc.pendingBlocks != nil { - if _, exist := bc.pendingBlocks.Get(hash); exist { - return true - } - } - data, _ := bc.blockDb.Get(append(blockHashPre, hash[:]...)) return len(data) != 0 } @@ -423,12 +450,6 @@ func (self *ChainManager) GetBlock(hash common.Hash) *types.Block { return block.(*types.Block) } - if self.pendingBlocks != nil { - if block, _ := self.pendingBlocks.Get(hash); block != nil { - return block.(*types.Block) - } - } - data, _ := self.blockDb.Get(append(blockHashPre, hash[:]...)) if len(data) == 0 { return nil @@ -519,31 +540,6 @@ func (self *ChainManager) procFutureBlocks() { } } -func (self *ChainManager) enqueueForWrite(block *types.Block) { - self.pendingBlocks.Add(block.Hash(), block) -} - -func (self *ChainManager) flushQueuedBlocks() { - db, batchWrite := self.blockDb.(*ethdb.LDBDatabase) - batch := new(leveldb.Batch) - for _, key := range self.pendingBlocks.Keys() { - b, _ := self.pendingBlocks.Get(key) - block := b.(*types.Block) - - enc, _ := rlp.EncodeToBytes((*types.StorageBlock)(block)) - key := append(blockHashPre, block.Hash().Bytes()...) - if batchWrite { - batch.Put(key, rle.Compress(enc)) - } else { - self.blockDb.Put(key, enc) - } - } - - if batchWrite { - db.LDB().Write(batch, nil) - } -} - type writeStatus byte const ( @@ -586,15 +582,7 @@ func (self *ChainManager) WriteBlock(block *types.Block, queued bool) (status wr status = sideStatTy } - if queued { - // Write block to database. Eventually we'll have to improve on this and throw away blocks that are - // not in the canonical chain. - self.mu.Lock() - self.enqueueForWrite(block) - self.mu.Unlock() - } else { - self.write(block) - } + self.write(block) // Delete from future blocks self.futureBlocks.Remove(block.Hash()) @@ -610,8 +598,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { self.chainmu.Lock() defer self.chainmu.Unlock() - self.pendingBlocks, _ = lru.New(len(chain)) - // A queued approach to delivering events. This is generally // faster than direct delivery and requires much less mutex // acquiring. @@ -629,7 +615,6 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { // Start the parallel nonce verifier. go verifyNonces(self.pow, chain, nonceQuit, nonceDone) defer close(nonceQuit) - defer self.flushQueuedBlocks() txcount := 0 for i, block := range chain { diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index 8b3ea9e85..6869bc746 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -109,8 +109,7 @@ func testChain(chainB types.Blocks, bman *BlockProcessor) (*big.Int, error) { bman.bc.mu.Lock() { - bman.bc.enqueueForWrite(block) - //bman.bc.write(block) + bman.bc.write(block) } bman.bc.mu.Unlock() } -- cgit v1.2.3 From a748afce0322af35d6031d76bf38afa1f974296a Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 30 Jun 2015 15:42:20 +0200 Subject: core: txpool listen for ChainHeadEvent instead of ChainEvent Changed the transaction pool to listen for ChainHeadEvent when resetting the state instead of ChainEvent. It makes very little sense to burst through transactions while we are catching up (e.g., have more than one block to process) --- core/transaction_pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/transaction_pool.go b/core/transaction_pool.go index 6a7012c65..ac9027755 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -65,7 +65,7 @@ func NewTxPool(eventMux *event.TypeMux, currentStateFn stateFn, gasLimitFn func( gasLimit: gasLimitFn, minGasPrice: new(big.Int), pendingState: state.ManageState(currentStateFn()), - events: eventMux.Subscribe(ChainEvent{}, GasPriceChanged{}), + events: eventMux.Subscribe(ChainHeadEvent{}, GasPriceChanged{}), } go pool.eventLoop() @@ -80,7 +80,7 @@ func (pool *TxPool) eventLoop() { pool.mu.Lock() switch ev := ev.(type) { - case ChainEvent: + case ChainHeadEvent: pool.resetState() case GasPriceChanged: pool.minGasPrice = ev.Price -- cgit v1.2.3 From 29ab1fa8a50db8aa16c5d707f1cab7dc201a4053 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 1 Jul 2015 00:52:44 +0200 Subject: core, cmd/geth: recover by number --- core/chain_manager.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/chain_manager.go b/core/chain_manager.go index c89aae3f0..247b5fdb3 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -238,6 +238,16 @@ func (self *ChainManager) setTransState(statedb *state.StateDB) { self.transState = statedb } +func (bc *ChainManager) Recover(num uint64) { + block := bc.GetBlockByNumber(num) + if block != nil { + bc.insert(block) + glog.Infof("Recovery succesful. New HEAD %x\n", block.Hash()) + } else { + glog.Fatalln("Recovery failed") + } +} + func (bc *ChainManager) recover() bool { data, _ := bc.blockDb.Get([]byte("checkpoint")) if len(data) != 0 { @@ -261,8 +271,6 @@ func (bc *ChainManager) setLastState() { if len(data) != 0 { block := bc.GetBlock(common.BytesToHash(data)) if block != nil { - bc.blockDb.Put([]byte("checkpoint"), block.Hash().Bytes()) - bc.currentBlock = block bc.lastBlockHash = block.Hash() } else { -- cgit v1.2.3 From 70d5d791cc695cff3b3448a1b4b47816a8bbd83f Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 1 Jul 2015 16:15:02 +0200 Subject: core, cmd/geth: improved recover functionality `geth recover` now accepts both hashes and numbers using "#" and no longer requires the ethereum instance. --- core/chain_manager.go | 86 ++++---------------------------------------- core/chain_util.go | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 80 deletions(-) create mode 100644 core/chain_util.go (limited to 'core') diff --git a/core/chain_manager.go b/core/chain_manager.go index a7b57b26b..70a8b11c6 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -1,7 +1,6 @@ package core import ( - "bytes" "fmt" "io" "math/big" @@ -17,7 +16,6 @@ import ( "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/metrics" - "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" "github.com/ethereum/go-ethereum/rlp" "github.com/hashicorp/golang-lru" @@ -40,53 +38,6 @@ const ( checkpointLimit = 200 ) -// CalcDifficulty is the difficulty adjustment algorithm. It returns -// the difficulty that a new block b should have when created at time -// given the parent block's time and difficulty. -func CalcDifficulty(time int64, parentTime int64, parentDiff *big.Int) *big.Int { - diff := new(big.Int) - adjust := new(big.Int).Div(parentDiff, params.DifficultyBoundDivisor) - if big.NewInt(time-parentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parentDiff, adjust) - } else { - diff.Sub(parentDiff, adjust) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - return params.MinimumDifficulty - } - return diff -} - -// CalcTD computes the total difficulty of block. -func CalcTD(block, parent *types.Block) *big.Int { - if parent == nil { - return block.Difficulty() - } - d := block.Difficulty() - d.Add(d, parent.Td) - return d -} - -// CalcGasLimit computes the gas limit of the next block after parent. -// The result may be modified by the caller. -func CalcGasLimit(parent *types.Block) *big.Int { - decay := new(big.Int).Div(parent.GasLimit(), params.GasLimitBoundDivisor) - contrib := new(big.Int).Mul(parent.GasUsed(), big.NewInt(3)) - contrib = contrib.Div(contrib, big.NewInt(2)) - contrib = contrib.Div(contrib, params.GasLimitBoundDivisor) - - gl := new(big.Int).Sub(parent.GasLimit(), decay) - gl = gl.Add(gl, contrib) - gl = gl.Add(gl, big.NewInt(1)) - gl.Set(common.BigMax(gl, params.MinGasLimit)) - - if gl.Cmp(params.GenesisGasLimit) < 0 { - gl.Add(parent.GasLimit(), decay) - gl.Set(common.BigMin(gl, params.GenesisGasLimit)) - } - return gl -} - type ChainManager struct { //eth EthManager blockDb common.Database @@ -238,16 +189,6 @@ func (self *ChainManager) setTransState(statedb *state.StateDB) { self.transState = statedb } -func (bc *ChainManager) Recover(num uint64) { - block := bc.GetBlockByNumber(num) - if block != nil { - bc.insert(block) - glog.Infof("Recovery succesful. New HEAD %x\n", block.Hash()) - } else { - glog.Fatalln("Recovery failed") - } -} - func (bc *ChainManager) recover() bool { data, _ := bc.blockDb.Get([]byte("checkpoint")) if len(data) != 0 { @@ -378,12 +319,7 @@ func (self *ChainManager) ExportN(w io.Writer, first uint64, last uint64) error // insert injects a block into the current chain block chain. Note, this function // assumes that the `mu` mutex is held! func (bc *ChainManager) insert(block *types.Block) { - key := append(blockNumPre, block.Number().Bytes()...) - err := bc.blockDb.Put(key, block.Hash().Bytes()) - if err != nil { - glog.Fatal("db write fail:", err) - } - err = bc.blockDb.Put([]byte("LastBlock"), block.Hash().Bytes()) + err := WriteHead(bc.blockDb, block) if err != nil { glog.Fatal("db write fail:", err) } @@ -458,20 +394,15 @@ func (self *ChainManager) GetBlock(hash common.Hash) *types.Block { return block.(*types.Block) } - data, _ := self.blockDb.Get(append(blockHashPre, hash[:]...)) - if len(data) == 0 { - return nil - } - var block types.StorageBlock - if err := rlp.Decode(bytes.NewReader(data), &block); err != nil { - glog.V(logger.Error).Infof("invalid block RLP for hash %x: %v", hash, err) + block := GetBlockByHash(self.blockDb, hash) + if block == nil { return nil } // Add the block to the cache - self.cache.Add(hash, (*types.Block)(&block)) + self.cache.Add(hash, (*types.Block)(block)) - return (*types.Block)(&block) + return (*types.Block)(block) } func (self *ChainManager) GetBlockByNumber(num uint64) *types.Block { @@ -497,12 +428,7 @@ func (self *ChainManager) GetBlocksFromHash(hash common.Hash, n int) (blocks []* // non blocking version func (self *ChainManager) getBlockByNumber(num uint64) *types.Block { - key, _ := self.blockDb.Get(append(blockNumPre, big.NewInt(int64(num)).Bytes()...)) - if len(key) == 0 { - return nil - } - - return self.GetBlock(common.BytesToHash(key)) + return GetBlockByNumber(self.blockDb, num) } func (self *ChainManager) GetUnclesInChain(block *types.Block, length int) (uncles []*types.Header) { diff --git a/core/chain_util.go b/core/chain_util.go new file mode 100644 index 000000000..8051cc47a --- /dev/null +++ b/core/chain_util.go @@ -0,0 +1,98 @@ +package core + +import ( + "bytes" + "math/big" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rlp" +) + +// CalcDifficulty is the difficulty adjustment algorithm. It returns +// the difficulty that a new block b should have when created at time +// given the parent block's time and difficulty. +func CalcDifficulty(time int64, parentTime int64, parentDiff *big.Int) *big.Int { + diff := new(big.Int) + adjust := new(big.Int).Div(parentDiff, params.DifficultyBoundDivisor) + if big.NewInt(time-parentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parentDiff, adjust) + } else { + diff.Sub(parentDiff, adjust) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + return params.MinimumDifficulty + } + return diff +} + +// CalcTD computes the total difficulty of block. +func CalcTD(block, parent *types.Block) *big.Int { + if parent == nil { + return block.Difficulty() + } + d := block.Difficulty() + d.Add(d, parent.Td) + return d +} + +// CalcGasLimit computes the gas limit of the next block after parent. +// The result may be modified by the caller. +func CalcGasLimit(parent *types.Block) *big.Int { + decay := new(big.Int).Div(parent.GasLimit(), params.GasLimitBoundDivisor) + contrib := new(big.Int).Mul(parent.GasUsed(), big.NewInt(3)) + contrib = contrib.Div(contrib, big.NewInt(2)) + contrib = contrib.Div(contrib, params.GasLimitBoundDivisor) + + gl := new(big.Int).Sub(parent.GasLimit(), decay) + gl = gl.Add(gl, contrib) + gl = gl.Add(gl, big.NewInt(1)) + gl.Set(common.BigMax(gl, params.MinGasLimit)) + + if gl.Cmp(params.GenesisGasLimit) < 0 { + gl.Add(parent.GasLimit(), decay) + gl.Set(common.BigMin(gl, params.GenesisGasLimit)) + } + return gl +} + +// GetBlockByHash returns the block corresponding to the hash or nil if not found +func GetBlockByHash(db common.Database, hash common.Hash) *types.Block { + data, _ := db.Get(append(blockHashPre, hash[:]...)) + if len(data) == 0 { + return nil + } + var block types.StorageBlock + if err := rlp.Decode(bytes.NewReader(data), &block); err != nil { + glog.V(logger.Error).Infof("invalid block RLP for hash %x: %v", hash, err) + return nil + } + return (*types.Block)(&block) +} + +// GetBlockByHash returns the canonical block by number or nil if not found +func GetBlockByNumber(db common.Database, number uint64) *types.Block { + key, _ := db.Get(append(blockNumPre, big.NewInt(int64(number)).Bytes()...)) + if len(key) == 0 { + return nil + } + + return GetBlockByHash(db, common.BytesToHash(key)) +} + +// WriteHead force writes the current head +func WriteHead(db common.Database, block *types.Block) error { + key := append(blockNumPre, block.Number().Bytes()...) + err := db.Put(key, block.Hash().Bytes()) + if err != nil { + return err + } + err = db.Put([]byte("LastBlock"), block.Hash().Bytes()) + if err != nil { + return err + } + return nil +} -- cgit v1.2.3 From 529fb7a7d76e4c98f825bfcb9f3c1fb40b1d0d1e Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Thu, 2 Jul 2015 11:19:10 +0200 Subject: core, xeth: core.AddressFromMessage removed => crypto.CreateAddress --- core/state_transition.go | 6 ------ 1 file changed, 6 deletions(-) (limited to 'core') diff --git a/core/state_transition.go b/core/state_transition.go index e2212dfef..5611ffd0f 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/params" @@ -56,11 +55,6 @@ type Message interface { Data() []byte } -func AddressFromMessage(msg Message) common.Address { - from, _ := msg.From() - return crypto.CreateAddress(from, msg.Nonce()) -} - func MessageCreatesContract(msg Message) bool { return msg.To() == nil } -- cgit v1.2.3 From 744af9f497d25b55246695dec831eb9345401984 Mon Sep 17 00:00:00 2001 From: Vitalik Buterin Date: Thu, 2 Jul 2015 05:27:19 -0400 Subject: Switched canary addresses --- core/canary.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/canary.go b/core/canary.go index de77c4bba..90b4a2eaf 100644 --- a/core/canary.go +++ b/core/canary.go @@ -8,10 +8,10 @@ import ( ) var ( - jeff = common.HexToAddress("9d38997c624a71b21278389ea2fdc460d000e4b2") - vitalik = common.HexToAddress("b1e570be07eaa673e4fd0c8265b64ef739385709") - christoph = common.HexToAddress("529bc43a5d93789fa28de1961db6a07e752204ae") - gav = common.HexToAddress("e3e942b2aa524293c84ff6c7f87a6635790ad5e4") + jeff = common.HexToAddress("a8edb1ac2c86d3d9d78f96cd18001f60df29e52c") + vitalik = common.HexToAddress("1baf27b88c48dd02b744999cf3522766929d2b2a") + christoph = common.HexToAddress("60d11b58744784dc97f878f7e3749c0f1381a004") + gav = common.HexToAddress("4bb7e8ae99b645c2b7860b8f3a2328aae28bd80a") ) // Canary will check the 0'd address of the 4 contracts above. -- cgit v1.2.3 From 29e2fb38f8e80dfa077d139d8ff563169c644d74 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 3 Jul 2015 11:24:42 +0200 Subject: core, miner: miner header validation, transaction & receipt writing * Miners do now verify their own header, not their state. * Changed old putTx and putReceipts to be exported * Moved writing of transactions and receipts out of the block processer in to the chain manager. Closes #1386 * Miner post ChainHeadEvent & ChainEvent. Closes #1388 --- core/bench_test.go | 2 +- core/block_processor.go | 64 ++++++-------------------------------------- core/block_processor_test.go | 4 +-- core/chain_makers.go | 2 +- core/chain_makers_test.go | 2 +- core/chain_manager.go | 33 ++++++++++++++--------- core/chain_manager_test.go | 12 ++++----- core/manager.go | 1 + core/transaction_util.go | 51 +++++++++++++++++++++++++++++++++++ core/types/common.go | 2 +- 10 files changed, 92 insertions(+), 81 deletions(-) create mode 100644 core/transaction_util.go (limited to 'core') diff --git a/core/bench_test.go b/core/bench_test.go index 6d851febd..8cd8c4299 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -152,7 +152,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) { // Time the insertion of the new chain. // State and blocks are stored in the same DB. evmux := new(event.TypeMux) - chainman, _ := NewChainManager(genesis, db, db, FakePow{}, evmux) + chainman, _ := NewChainManager(genesis, db, db, db, FakePow{}, evmux) chainman.SetProcessor(NewBlockProcessor(db, db, FakePow{}, chainman, evmux)) defer chainman.Stop() b.ReportAllocs() diff --git a/core/block_processor.go b/core/block_processor.go index 9b77d10eb..7171e3b2e 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -151,7 +151,7 @@ func (sm *BlockProcessor) RetryProcess(block *types.Block) (logs state.Logs, err errch := make(chan bool) go func() { errch <- sm.Pow.Verify(block) }() - logs, err = sm.processWithParent(block, parent) + logs, _, err = sm.processWithParent(block, parent) if !<-errch { return nil, ValidationError("Block's nonce is invalid (= %x)", block.Nonce) } @@ -162,23 +162,23 @@ func (sm *BlockProcessor) RetryProcess(block *types.Block) (logs state.Logs, err // Process block will attempt to process the given block's transactions and applies them // on top of the block's parent state (given it exists) and will return wether it was // successful or not. -func (sm *BlockProcessor) Process(block *types.Block) (logs state.Logs, err error) { +func (sm *BlockProcessor) Process(block *types.Block) (logs state.Logs, receipts types.Receipts, err error) { // Processing a blocks may never happen simultaneously sm.mutex.Lock() defer sm.mutex.Unlock() if sm.bc.HasBlock(block.Hash()) { - return nil, &KnownBlockError{block.Number(), block.Hash()} + return nil, nil, &KnownBlockError{block.Number(), block.Hash()} } if !sm.bc.HasBlock(block.ParentHash()) { - return nil, ParentError(block.ParentHash()) + return nil, nil, ParentError(block.ParentHash()) } parent := sm.bc.GetBlock(block.ParentHash()) return sm.processWithParent(block, parent) } -func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs state.Logs, err error) { +func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs state.Logs, receipts types.Receipts, err error) { // Create a new state based on the parent's root (e.g., create copy) state := state.New(parent.Root(), sm.db) header := block.Header() @@ -192,10 +192,10 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st // There can be at most two uncles if len(uncles) > 2 { - return nil, ValidationError("Block can only contain maximum 2 uncles (contained %v)", len(uncles)) + return nil, nil, ValidationError("Block can only contain maximum 2 uncles (contained %v)", len(uncles)) } - receipts, err := sm.TransitionState(state, parent, block, false) + receipts, err = sm.TransitionState(state, parent, block, false) if err != nil { return } @@ -248,15 +248,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st // Sync the current block's state to the database state.Sync() - // This puts transactions in a extra db for rpc - for i, tx := range block.Transactions() { - putTx(sm.extraDb, tx, block, uint64(i)) - } - - // store the receipts - putReceipts(sm.extraDb, block.Hash(), receipts) - - return state.Logs(), nil + return state.Logs(), receipts, nil } var ( @@ -411,43 +403,3 @@ func getBlockReceipts(db common.Database, bhash common.Hash) (receipts types.Rec } return } - -func putTx(db common.Database, tx *types.Transaction, block *types.Block, i uint64) { - rlpEnc, err := rlp.EncodeToBytes(tx) - if err != nil { - glog.V(logger.Debug).Infoln("Failed encoding tx", err) - return - } - db.Put(tx.Hash().Bytes(), rlpEnc) - - var txExtra struct { - BlockHash common.Hash - BlockIndex uint64 - Index uint64 - } - txExtra.BlockHash = block.Hash() - txExtra.BlockIndex = block.NumberU64() - txExtra.Index = i - rlpMeta, err := rlp.EncodeToBytes(txExtra) - if err != nil { - glog.V(logger.Debug).Infoln("Failed encoding tx meta data", err) - return - } - db.Put(append(tx.Hash().Bytes(), 0x0001), rlpMeta) -} - -func putReceipts(db common.Database, hash common.Hash, receipts types.Receipts) error { - storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) - for i, receipt := range receipts { - storageReceipts[i] = (*types.ReceiptForStorage)(receipt) - } - - bytes, err := rlp.EncodeToBytes(storageReceipts) - if err != nil { - return err - } - - db.Put(append(receiptsPre, hash[:]...), bytes) - - return nil -} diff --git a/core/block_processor_test.go b/core/block_processor_test.go index dc328a3ea..99681dabf 100644 --- a/core/block_processor_test.go +++ b/core/block_processor_test.go @@ -18,7 +18,7 @@ func proc() (*BlockProcessor, *ChainManager) { var mux event.TypeMux genesis := GenesisBlock(0, db) - chainMan, err := NewChainManager(genesis, db, db, thePow(), &mux) + chainMan, err := NewChainManager(genesis, db, db, db, thePow(), &mux) if err != nil { fmt.Println(err) } @@ -64,7 +64,7 @@ func TestPutReceipt(t *testing.T) { Index: 0, }}) - putReceipts(db, hash, types.Receipts{receipt}) + PutReceipts(db, hash, types.Receipts{receipt}) receipts, err := getBlockReceipts(db, hash) if err != nil { t.Error("got err:", err) diff --git a/core/chain_makers.go b/core/chain_makers.go index 013251d74..37475e0ae 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -167,7 +167,7 @@ func makeHeader(parent *types.Block, state *state.StateDB) *types.Header { // InsertChain on the result of makeChain. func newCanonical(n int, db common.Database) (*BlockProcessor, error) { evmux := &event.TypeMux{} - chainman, _ := NewChainManager(GenesisBlock(0, db), db, db, FakePow{}, evmux) + chainman, _ := NewChainManager(GenesisBlock(0, db), db, db, db, FakePow{}, evmux) bman := NewBlockProcessor(db, db, FakePow{}, chainman, evmux) bman.bc.SetProcessor(bman) parent := bman.bc.CurrentBlock() diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index d5125e1c3..f4eeef082 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -58,7 +58,7 @@ func ExampleGenerateChain() { // Import the chain. This runs all block validation rules. evmux := &event.TypeMux{} - chainman, _ := NewChainManager(genesis, db, db, FakePow{}, evmux) + chainman, _ := NewChainManager(genesis, db, db, db, FakePow{}, evmux) chainman.SetProcessor(NewBlockProcessor(db, db, FakePow{}, chainman, evmux)) if i, err := chainman.InsertChain(chain); err != nil { fmt.Printf("insert error (block %d): %v\n", i, err) diff --git a/core/chain_manager.go b/core/chain_manager.go index 70a8b11c6..b5381e336 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -42,6 +42,7 @@ type ChainManager struct { //eth EthManager blockDb common.Database stateDb common.Database + extraDb common.Database processor types.BlockProcessor eventMux *event.TypeMux genesisBlock *types.Block @@ -70,11 +71,12 @@ type ChainManager struct { pow pow.PoW } -func NewChainManager(genesis *types.Block, blockDb, stateDb common.Database, pow pow.PoW, mux *event.TypeMux) (*ChainManager, error) { +func NewChainManager(genesis *types.Block, blockDb, stateDb, extraDb common.Database, pow pow.PoW, mux *event.TypeMux) (*ChainManager, error) { cache, _ := lru.New(blockCacheLimit) bc := &ChainManager{ blockDb: blockDb, stateDb: stateDb, + extraDb: extraDb, genesisBlock: GenesisBlock(42, stateDb), eventMux: mux, quit: make(chan struct{}), @@ -477,10 +479,10 @@ func (self *ChainManager) procFutureBlocks() { type writeStatus byte const ( - nonStatTy writeStatus = iota - canonStatTy - splitStatTy - sideStatTy + NonStatTy writeStatus = iota + CanonStatTy + SplitStatTy + SideStatTy ) // WriteBlock writes the block to the chain (or pending queue) @@ -497,10 +499,10 @@ func (self *ChainManager) WriteBlock(block *types.Block, queued bool) (status wr // during split we merge two different chains and create the new canonical chain err := self.merge(cblock, block) if err != nil { - return nonStatTy, err + return NonStatTy, err } - status = splitStatTy + status = SplitStatTy } self.mu.Lock() @@ -511,9 +513,9 @@ func (self *ChainManager) WriteBlock(block *types.Block, queued bool) (status wr self.setTransState(state.New(block.Root(), self.stateDb)) self.txState.SetState(state.New(block.Root(), self.stateDb)) - status = canonStatTy + status = CanonStatTy } else { - status = sideStatTy + status = SideStatTy } self.write(block) @@ -581,7 +583,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { // Call in to the block processor and check for errors. It's likely that if one block fails // all others will fail too (unless a known block is returned). - logs, err := self.processor.Process(block) + logs, receipts, err := self.processor.Process(block) if err != nil { if IsKnownBlockErr(err) { stats.ignored++ @@ -620,19 +622,24 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { return i, err } switch status { - case canonStatTy: + case CanonStatTy: if glog.V(logger.Debug) { glog.Infof("[%v] inserted block #%d (%d TXs %d UNCs) (%x...). Took %v\n", time.Now().UnixNano(), block.Number(), len(block.Transactions()), len(block.Uncles()), block.Hash().Bytes()[0:4], time.Since(bstart)) } queue[i] = ChainEvent{block, block.Hash(), logs} queueEvent.canonicalCount++ - case sideStatTy: + + // This puts transactions in a extra db for rpc + PutTransactions(self.extraDb, block, block.Transactions()) + // store the receipts + PutReceipts(self.extraDb, block.Hash(), receipts) + case SideStatTy: if glog.V(logger.Detail) { glog.Infof("inserted forked block #%d (TD=%v) (%d TXs %d UNCs) (%x...). Took %v\n", block.Number(), block.Difficulty(), len(block.Transactions()), len(block.Uncles()), block.Hash().Bytes()[0:4], time.Since(bstart)) } queue[i] = ChainSideEvent{block, logs} queueEvent.sideCount++ - case splitStatTy: + case SplitStatTy: queue[i] = ChainSplitEvent{block, logs} queueEvent.splitCount++ } diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index 6869bc746..c013fc729 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -33,7 +33,7 @@ func thePow() pow.PoW { func theChainManager(db common.Database, t *testing.T) *ChainManager { var eventMux event.TypeMux genesis := GenesisBlock(0, db) - chainMan, err := NewChainManager(genesis, db, db, thePow(), &eventMux) + chainMan, err := NewChainManager(genesis, db, db, db, thePow(), &eventMux) if err != nil { t.Error("failed creating chainmanager:", err) t.FailNow() @@ -96,7 +96,7 @@ func printChain(bc *ChainManager) { func testChain(chainB types.Blocks, bman *BlockProcessor) (*big.Int, error) { td := new(big.Int) for _, block := range chainB { - _, err := bman.bc.processor.Process(block) + _, _, err := bman.bc.processor.Process(block) if err != nil { if IsKnownBlockErr(err) { continue @@ -367,7 +367,7 @@ func TestGetBlocksFromHash(t *testing.T) { type bproc struct{} -func (bproc) Process(*types.Block) (state.Logs, error) { return nil, nil } +func (bproc) Process(*types.Block) (state.Logs, types.Receipts, error) { return nil, nil, nil } func makeChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.Block { var chain []*types.Block @@ -390,7 +390,7 @@ func makeChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.Block func chm(genesis *types.Block, db common.Database) *ChainManager { var eventMux event.TypeMux - bc := &ChainManager{blockDb: db, stateDb: db, genesisBlock: genesis, eventMux: &eventMux, pow: FakePow{}} + bc := &ChainManager{extraDb: db, blockDb: db, stateDb: db, genesisBlock: genesis, eventMux: &eventMux, pow: FakePow{}} bc.cache, _ = lru.New(100) bc.futureBlocks, _ = lru.New(100) bc.processor = bproc{} @@ -479,12 +479,12 @@ func TestGenesisMismatch(t *testing.T) { db, _ := ethdb.NewMemDatabase() var mux event.TypeMux genesis := GenesisBlock(0, db) - _, err := NewChainManager(genesis, db, db, thePow(), &mux) + _, err := NewChainManager(genesis, db, db, db, thePow(), &mux) if err != nil { t.Error(err) } genesis = GenesisBlock(1, db) - _, err = NewChainManager(genesis, db, db, thePow(), &mux) + _, err = NewChainManager(genesis, db, db, db, thePow(), &mux) if err == nil { t.Error("expected genesis mismatch error") } diff --git a/core/manager.go b/core/manager.go index ba0ecf9d1..576cf55b0 100644 --- a/core/manager.go +++ b/core/manager.go @@ -14,5 +14,6 @@ type Backend interface { TxPool() *TxPool BlockDb() common.Database StateDb() common.Database + ExtraDb() common.Database EventMux() *event.TypeMux } diff --git a/core/transaction_util.go b/core/transaction_util.go new file mode 100644 index 000000000..bbb215d91 --- /dev/null +++ b/core/transaction_util.go @@ -0,0 +1,51 @@ +package core + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/rlp" +) + +func PutTransactions(db common.Database, block *types.Block, txs types.Transactions) { + for i, tx := range block.Transactions() { + rlpEnc, err := rlp.EncodeToBytes(tx) + if err != nil { + glog.V(logger.Debug).Infoln("Failed encoding tx", err) + return + } + db.Put(tx.Hash().Bytes(), rlpEnc) + + var txExtra struct { + BlockHash common.Hash + BlockIndex uint64 + Index uint64 + } + txExtra.BlockHash = block.Hash() + txExtra.BlockIndex = block.NumberU64() + txExtra.Index = uint64(i) + rlpMeta, err := rlp.EncodeToBytes(txExtra) + if err != nil { + glog.V(logger.Debug).Infoln("Failed encoding tx meta data", err) + return + } + db.Put(append(tx.Hash().Bytes(), 0x0001), rlpMeta) + } +} + +func PutReceipts(db common.Database, hash common.Hash, receipts types.Receipts) error { + storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) + for i, receipt := range receipts { + storageReceipts[i] = (*types.ReceiptForStorage)(receipt) + } + + bytes, err := rlp.EncodeToBytes(storageReceipts) + if err != nil { + return err + } + + db.Put(append(receiptsPre, hash[:]...), bytes) + + return nil +} diff --git a/core/types/common.go b/core/types/common.go index dbdaaba0c..09d1e2fed 100644 --- a/core/types/common.go +++ b/core/types/common.go @@ -10,7 +10,7 @@ import ( ) type BlockProcessor interface { - Process(*Block) (state.Logs, error) + Process(*Block) (state.Logs, Receipts, error) } const bloomLength = 256 -- cgit v1.2.3 From 6afdc52483d068a2de346505e8951dd9f064b99f Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Fri, 3 Jul 2015 07:40:47 -0500 Subject: Prevent debug value from printing on console --- core/filter.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'core') diff --git a/core/filter.go b/core/filter.go index fcdf68dd0..121e4642d 100644 --- a/core/filter.go +++ b/core/filter.go @@ -1,7 +1,6 @@ package core import ( - "fmt" "math" "github.com/ethereum/go-ethereum/common" @@ -80,7 +79,6 @@ func (self *Filter) Find() state.Logs { done: for i := 0; block != nil; i++ { - fmt.Println(block.NumberU64() == 0) // Quit on latest switch { case block.NumberU64() == 0: -- cgit v1.2.3 From 2feb23c1dacf1cc7ef664d92f28b63dd46502f21 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sat, 4 Jul 2015 02:25:04 +0200 Subject: core, eth, miner, xeth: receipt storage fix * Added GetReceiptsFromBlock, GetReceipt, PutReceipts * Added ContractAddress to receipt. See #1042 --- core/block_processor.go | 34 +++++++++++++----------------- core/block_processor_test.go | 11 ++++------ core/chain_manager.go | 2 +- core/transaction_util.go | 50 +++++++++++++++++++++++++++++++++++++------- core/types/receipt.go | 8 +++++-- 5 files changed, 68 insertions(+), 37 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 7171e3b2e..e8014ec22 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -9,12 +9,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/pow" - "github.com/ethereum/go-ethereum/rlp" "gopkg.in/fatih/set.v0" ) @@ -24,8 +24,6 @@ const ( BlockChainVersion = 3 ) -var receiptsPre = []byte("receipts-") - type BlockProcessor struct { db common.Database extraDb common.Database @@ -83,6 +81,12 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated usedGas.Add(usedGas, gas) receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas) + receipt.TxHash = tx.Hash() + if MessageCreatesContract(tx) { + from, _ := tx.From() + receipt.ContractAddress = crypto.CreateAddress(from, tx.Nonce()) + } + logs := statedb.GetLogs(tx.Hash()) receipt.SetLogs(logs) receipt.Bloom = types.CreateBloom(types.Receipts{receipt}) @@ -319,16 +323,20 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty } // GetBlockReceipts returns the receipts beloniging to the block hash -func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) (receipts types.Receipts, err error) { - return getBlockReceipts(sm.extraDb, bhash) +func (sm *BlockProcessor) GetBlockReceipts(bhash common.Hash) types.Receipts { + if block := sm.ChainManager().GetBlock(bhash); block != nil { + return GetReceiptsFromBlock(sm.extraDb, block) + } + + return nil } // GetLogs returns the logs of the given block. This method is using a two step approach // where it tries to get it from the (updated) method which gets them from the receipts or // the depricated way by re-processing the block. func (sm *BlockProcessor) GetLogs(block *types.Block) (logs state.Logs, err error) { - receipts, err := sm.GetBlockReceipts(block.Hash()) - if err == nil && len(receipts) > 0 { + receipts := GetReceiptsFromBlock(sm.extraDb, block) + if len(receipts) > 0 { // coalesce logs for _, receipt := range receipts { logs = append(logs, receipt.Logs()...) @@ -391,15 +399,3 @@ func ValidateHeader(pow pow.PoW, block *types.Header, parent *types.Block, check return nil } - -func getBlockReceipts(db common.Database, bhash common.Hash) (receipts types.Receipts, err error) { - var rdata []byte - rdata, err = db.Get(append(receiptsPre, bhash[:]...)) - - if err == nil { - err = rlp.DecodeBytes(rdata, &receipts) - } else { - glog.V(logger.Detail).Infof("getBlockReceipts error %v\n", err) - } - return -} diff --git a/core/block_processor_test.go b/core/block_processor_test.go index 99681dabf..8c38d531f 100644 --- a/core/block_processor_test.go +++ b/core/block_processor_test.go @@ -64,12 +64,9 @@ func TestPutReceipt(t *testing.T) { Index: 0, }}) - PutReceipts(db, hash, types.Receipts{receipt}) - receipts, err := getBlockReceipts(db, hash) - if err != nil { - t.Error("got err:", err) - } - if len(receipts) != 1 { - t.Error("expected to get 1 receipt, got", len(receipts)) + PutReceipts(db, types.Receipts{receipt}) + receipt = GetReceipt(db, common.Hash{}) + if receipt == nil { + t.Error("expected to get 1 receipt, got none.") } } diff --git a/core/chain_manager.go b/core/chain_manager.go index b5381e336..4855162b5 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -632,7 +632,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { // This puts transactions in a extra db for rpc PutTransactions(self.extraDb, block, block.Transactions()) // store the receipts - PutReceipts(self.extraDb, block.Hash(), receipts) + PutReceipts(self.extraDb, receipts) case SideStatTy: if glog.V(logger.Detail) { glog.Infof("inserted forked block #%d (TD=%v) (%d TXs %d UNCs) (%x...). Took %v\n", block.Number(), block.Difficulty(), len(block.Transactions()), len(block.Uncles()), block.Hash().Bytes()[0:4], time.Since(bstart)) diff --git a/core/transaction_util.go b/core/transaction_util.go index bbb215d91..cb5d6c7f7 100644 --- a/core/transaction_util.go +++ b/core/transaction_util.go @@ -8,6 +8,9 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) +var receiptsPre = []byte("receipts-") + +// PutTransactions stores the transactions in the given database func PutTransactions(db common.Database, block *types.Block, txs types.Transactions) { for i, tx := range block.Transactions() { rlpEnc, err := rlp.EncodeToBytes(tx) @@ -34,18 +37,49 @@ func PutTransactions(db common.Database, block *types.Block, txs types.Transacti } } -func PutReceipts(db common.Database, hash common.Hash, receipts types.Receipts) error { - storageReceipts := make([]*types.ReceiptForStorage, len(receipts)) - for i, receipt := range receipts { - storageReceipts[i] = (*types.ReceiptForStorage)(receipt) +// PutReceipts stores the receipts in the current database +func PutReceipts(db common.Database, receipts types.Receipts) error { + for _, receipt := range receipts { + storageReceipt := (*types.ReceiptForStorage)(receipt) + bytes, err := rlp.EncodeToBytes(storageReceipt) + if err != nil { + return err + } + err = db.Put(append(receiptsPre, receipt.TxHash[:]...), bytes) + if err != nil { + return err + } + } + + return nil +} + +// GetReceipt returns a receipt by hash +func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt { + data, _ := db.Get(append(receiptsPre, txHash[:]...)) + if len(data) == 0 { + return nil } - bytes, err := rlp.EncodeToBytes(storageReceipts) + var receipt types.Receipt + err := rlp.DecodeBytes(data, &receipt) if err != nil { - return err + glog.V(logger.Error).Infoln("GetReceipt err:", err) } + return &receipt +} - db.Put(append(receiptsPre, hash[:]...), bytes) +// GetReceiptFromBlock returns all receipts with the given block +func GetReceiptsFromBlock(db common.Database, block *types.Block) types.Receipts { + // at some point we want: + //receipts := make(types.Receipts, len(block.Transactions())) + // but since we need to support legacy, we can't (yet) + var receipts types.Receipts + for _, tx := range block.Transactions() { + if receipt := GetReceipt(db, tx.Hash()); receipt != nil { + receipts = append(receipts, receipt) + } + } - return nil + return receipts } diff --git a/core/types/receipt.go b/core/types/receipt.go index 6b4024ada..ab52c6e60 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -15,6 +15,8 @@ type Receipt struct { PostState []byte CumulativeGasUsed *big.Int Bloom Bloom + TxHash common.Hash + ContractAddress common.Address logs state.Logs } @@ -39,12 +41,14 @@ func (self *Receipt) DecodeRLP(s *rlp.Stream) error { PostState []byte CumulativeGasUsed *big.Int Bloom Bloom + TxHash common.Hash + ContractAddress common.Address Logs state.Logs } if err := s.Decode(&r); err != nil { return err } - self.PostState, self.CumulativeGasUsed, self.Bloom, self.logs = r.PostState, r.CumulativeGasUsed, r.Bloom, r.Logs + self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs return nil } @@ -56,7 +60,7 @@ func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error { for i, log := range self.logs { storageLogs[i] = (*state.LogForStorage)(log) } - return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, storageLogs}) + return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, storageLogs}) } func (self *Receipt) RlpEncode() []byte { -- cgit v1.2.3 From 08caeedd842526373d30a929e63101a5fe7fda55 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Tue, 30 Jun 2015 23:49:34 +0200 Subject: core, core/state: only write necessary state. Skip intermediate --- core/block_processor.go | 2 +- core/state/state_object.go | 8 -------- core/state/statedb.go | 22 ++++++++++++++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index e8014ec22..5f745e491 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -243,7 +243,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st // Commit state objects/accounts to a temporary trie (does not save) // used to calculate the state root. - state.Update() + state.CleanUpdate() if header.Root != state.Root() { err = fmt.Errorf("invalid merkle root. received=%x got=%x", header.Root, state.Root()) return diff --git a/core/state/state_object.go b/core/state/state_object.go index a31c182d2..e40aeda82 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -57,8 +57,6 @@ type StateObject struct { initCode Code // Cached storage (flushed when updated) storage Storage - // Temporary prepaid gas, reward after transition - prepaid *big.Int // Total gas pool is the total amount of gas currently // left if this object is the coinbase. Gas is directly @@ -77,14 +75,10 @@ func (self *StateObject) Reset() { } func NewStateObject(address common.Address, db common.Database) *StateObject { - // This to ensure that it has 20 bytes (and not 0 bytes), thus left or right pad doesn't matter. - //address := common.ToAddress(addr) - object := &StateObject{db: db, address: address, balance: new(big.Int), gasPool: new(big.Int), dirty: true} object.trie = trie.NewSecure((common.Hash{}).Bytes(), db) object.storage = make(Storage) object.gasPool = new(big.Int) - object.prepaid = new(big.Int) return object } @@ -110,7 +104,6 @@ func NewStateObjectFromBytes(address common.Address, data []byte, db common.Data object.trie = trie.NewSecure(extobject.Root[:], db) object.storage = make(map[string]common.Hash) object.gasPool = new(big.Int) - object.prepaid = new(big.Int) object.code, _ = db.Get(extobject.CodeHash) return object @@ -172,7 +165,6 @@ func (self *StateObject) Update() { self.setAddr([]byte(key), value) } - self.storage = make(Storage) } func (c *StateObject) GetInstr(pc *big.Int) *common.Value { diff --git a/core/state/statedb.go b/core/state/statedb.go index f6f63f329..bd4ff6ff3 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -18,6 +18,7 @@ import ( type StateDB struct { db common.Database trie *trie.SecureTrie + root common.Hash stateObjects map[string]*StateObject @@ -31,7 +32,7 @@ type StateDB struct { // Create a new state from a given trie func New(root common.Hash, db common.Database) *StateDB { trie := trie.NewSecure(root[:], db) - return &StateDB{db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: new(big.Int), logs: make(map[common.Hash]Logs)} + return &StateDB{root: root, db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: new(big.Int), logs: make(map[common.Hash]Logs)} } func (self *StateDB) PrintRoot() { @@ -185,7 +186,7 @@ func (self *StateDB) DeleteStateObject(stateObject *StateObject) { addr := stateObject.Address() self.trie.Delete(addr[:]) - delete(self.stateObjects, addr.Str()) + //delete(self.stateObjects, addr.Str()) } // Retrieve a state object given my the address. Nil if not found @@ -340,6 +341,23 @@ func (self *StateDB) Update() { } } +func (self *StateDB) CleanUpdate() { + self.trie = trie.NewSecure(self.root[:], self.db) + + self.refund = new(big.Int) + + for _, stateObject := range self.stateObjects { + if stateObject.remove { + self.DeleteStateObject(stateObject) + } else { + stateObject.Update() + + self.UpdateStateObject(stateObject) + } + stateObject.dirty = false + } +} + // Debug stuff func (self *StateDB) CreateOutputForDiff() { for _, stateObject := range self.stateObjects { -- cgit v1.2.3 From ab16ce70fc68d9ab1b7d8cda57c180b4785cab6a Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Wed, 1 Jul 2015 12:07:14 +0200 Subject: core, miner, tests: renamed state methods * Update => SyncIntermediate * Added SyncObjects SyncIntermediate only updates whatever has changed, but, as a side effect, requires much more disk space. SyncObjects will only sync whatever is required for a block and will not save intermediate state to disk. As drawback this requires more time when more txs come in. --- core/block_processor.go | 4 ++-- core/chain_makers.go | 4 ++-- core/genesis.go | 2 +- core/state/state_test.go | 2 +- core/state/statedb.go | 6 ++++-- 5 files changed, 10 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 5f745e491..e7ad059c3 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -77,7 +77,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated } // Update the state with pending changes - statedb.Update() + statedb.SyncIntermediate() usedGas.Add(usedGas, gas) receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas) @@ -243,7 +243,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st // Commit state objects/accounts to a temporary trie (does not save) // used to calculate the state root. - state.CleanUpdate() + state.SyncObjects() if header.Root != state.Root() { err = fmt.Errorf("invalid merkle root. received=%x got=%x", header.Root, state.Root()) return diff --git a/core/chain_makers.go b/core/chain_makers.go index 37475e0ae..c46f627f8 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -77,7 +77,7 @@ func (b *BlockGen) AddTx(tx *types.Transaction) { if err != nil { panic(err) } - b.statedb.Update() + b.statedb.SyncIntermediate() b.header.GasUsed.Add(b.header.GasUsed, gas) receipt := types.NewReceipt(b.statedb.Root().Bytes(), b.header.GasUsed) logs := b.statedb.GetLogs(tx.Hash()) @@ -135,7 +135,7 @@ func GenerateChain(parent *types.Block, db common.Database, n int, gen func(int, gen(i, b) } AccumulateRewards(statedb, h, b.uncles) - statedb.Update() + statedb.SyncIntermediate() h.Root = statedb.Root() return types.NewBlock(h, b.txs, b.uncles, b.receipts) } diff --git a/core/genesis.go b/core/genesis.go index df13466ec..d27e7097b 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -64,7 +64,7 @@ func GenesisBlockForTesting(db common.Database, addr common.Address, balance *bi statedb := state.New(common.Hash{}, db) obj := statedb.GetOrNewStateObject(addr) obj.SetBalance(balance) - statedb.Update() + statedb.SyncObjects() statedb.Sync() block := types.NewBlock(&types.Header{ Difficulty: params.GenesisDifficulty, diff --git a/core/state/state_test.go b/core/state/state_test.go index 00e133dab..b63b8ae9b 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -72,7 +72,7 @@ func TestNull(t *testing.T) { //value := common.FromHex("0x823140710bf13990e4500136726d8b55") var value common.Hash state.SetState(address, common.Hash{}, value) - state.Update() + state.SyncIntermediate() state.Sync() value = state.GetState(address, common.Hash{}) if !common.EmptyHash(value) { diff --git a/core/state/statedb.go b/core/state/statedb.go index bd4ff6ff3..4ccda1fc7 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -324,7 +324,8 @@ func (self *StateDB) Refunds() *big.Int { return self.refund } -func (self *StateDB) Update() { +// SyncIntermediate updates the intermediate state and all mid steps +func (self *StateDB) SyncIntermediate() { self.refund = new(big.Int) for _, stateObject := range self.stateObjects { @@ -341,7 +342,8 @@ func (self *StateDB) Update() { } } -func (self *StateDB) CleanUpdate() { +// SyncObjects syncs the changed objects to the trie +func (self *StateDB) SyncObjects() { self.trie = trie.NewSecure(self.root[:], self.db) self.refund = new(big.Int) -- cgit v1.2.3 From 0f04af5916cba5234118a442b6100c8122389abf Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Fri, 3 Jul 2015 19:54:14 +0200 Subject: Fix core error forwarding, unify OOG VM err --- core/block_processor.go | 5 +++-- core/error.go | 22 ---------------------- core/execution.go | 2 +- core/state_transition.go | 2 +- core/vm/errors.go | 24 +++--------------------- core/vm/vm.go | 4 ++-- 6 files changed, 10 insertions(+), 49 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index e7ad059c3..660c917e4 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" @@ -72,7 +73,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated cb := statedb.GetStateObject(coinbase.Address()) _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb) - if err != nil && (IsNonceErr(err) || state.IsGasLimitErr(err) || IsInvalidTxErr(err)) { + if err != nil && err != vm.OutOfGasError { return nil, nil, err } @@ -118,7 +119,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state statedb.StartRecord(tx.Hash(), block.Hash(), i) receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, header, tx, totalUsedGas, transientProcess) - if err != nil && (IsNonceErr(err) || state.IsGasLimitErr(err) || IsInvalidTxErr(err)) { + if err != nil && err != vm.OutOfGasError { return nil, err } diff --git a/core/error.go b/core/error.go index 3f3c350df..fb64d09b2 100644 --- a/core/error.go +++ b/core/error.go @@ -30,7 +30,6 @@ func ParentError(hash common.Hash) error { func IsParentErr(err error) bool { _, ok := err.(*ParentErr) - return ok } @@ -48,7 +47,6 @@ func UncleError(format string, v ...interface{}) error { func IsUncleErr(err error) bool { _, ok := err.(*UncleErr) - return ok } @@ -67,7 +65,6 @@ func ValidationError(format string, v ...interface{}) *ValidationErr { func IsValidationErr(err error) bool { _, ok := err.(*ValidationErr) - return ok } @@ -86,7 +83,6 @@ func NonceError(is, exp uint64) *NonceErr { func IsNonceErr(err error) bool { _, ok := err.(*NonceErr) - return ok } @@ -121,24 +117,6 @@ func InvalidTxError(err error) *InvalidTxErr { func IsInvalidTxErr(err error) bool { _, ok := err.(*InvalidTxErr) - - return ok -} - -type OutOfGasErr struct { - Message string -} - -func OutOfGasError() *OutOfGasErr { - return &OutOfGasErr{Message: "Out of gas"} -} -func (self *OutOfGasErr) Error() string { - return self.Message -} - -func IsOutOfGasErr(err error) bool { - _, ok := err.(*OutOfGasErr) - return ok } diff --git a/core/execution.go b/core/execution.go index 9fb0210de..a8c4ffb6d 100644 --- a/core/execution.go +++ b/core/execution.go @@ -53,7 +53,7 @@ func (self *Execution) exec(contextAddr *common.Address, code []byte, caller vm. if env.Depth() > int(params.CallCreateDepth.Int64()) { caller.ReturnGas(self.Gas, self.price) - return nil, vm.DepthError{} + return nil, vm.DepthError } vsnapshot := env.State().Copy() diff --git a/core/state_transition.go b/core/state_transition.go index 5611ffd0f..465000e87 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -122,7 +122,7 @@ func (self *StateTransition) To() *state.StateObject { func (self *StateTransition) UseGas(amount *big.Int) error { if self.gas.Cmp(amount) < 0 { - return OutOfGasError() + return vm.OutOfGasError } self.gas.Sub(self.gas, amount) diff --git a/core/vm/errors.go b/core/vm/errors.go index 799eb6797..75b9c0f10 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -1,21 +1,14 @@ package vm import ( + "errors" "fmt" "github.com/ethereum/go-ethereum/params" ) -type OutOfGasError struct{} - -func (self OutOfGasError) Error() string { - return "Out Of Gas" -} - -func IsOOGErr(err error) bool { - _, ok := err.(OutOfGasError) - return ok -} +var OutOfGasError = errors.New("Out of gas") +var DepthError = fmt.Errorf("Max call depth exceeded (%d)", params.CallCreateDepth) type StackError struct { req, has int @@ -33,14 +26,3 @@ func IsStack(err error) bool { _, ok := err.(StackError) return ok } - -type DepthError struct{} - -func (self DepthError) Error() string { - return fmt.Sprintf("Max call depth exceeded (%d)", params.CallCreateDepth) -} - -func IsDepthErr(err error) bool { - _, ok := err.(DepthError) - return ok -} diff --git a/core/vm/vm.go b/core/vm/vm.go index ba803683b..e390fb89c 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -116,7 +116,7 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) { context.UseGas(context.Gas) - return context.Return(nil), OutOfGasError{} + return context.Return(nil), OutOfGasError } // Resize the memory calculated previously mem.Resize(newMemSize.Uint64()) @@ -789,7 +789,7 @@ func (self *Vm) RunPrecompiled(p *PrecompiledAccount, input []byte, context *Con return context.Return(ret), nil } else { - return nil, OutOfGasError{} + return nil, OutOfGasError } } -- cgit v1.2.3 From bcc1660abc1c0a5ef838dea89e4f3830d84fb51c Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sat, 4 Jul 2015 17:45:18 +0200 Subject: core, miner, tests: added test, implemented bad block reporting --- core/bad_block.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ core/chain_manager.go | 2 ++ 2 files changed, 58 insertions(+) create mode 100644 core/bad_block.go (limited to 'core') diff --git a/core/bad_block.go b/core/bad_block.go new file mode 100644 index 000000000..e8e736a13 --- /dev/null +++ b/core/bad_block.go @@ -0,0 +1,56 @@ +package core + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "net/http" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/rlp" +) + +// DisabledBadBlockReporting can be set to prevent blocks being reported. +var DisableBadBlockReporting = true + +// ReportBlock reports the block to the block reporting tool found at +// badblocks.ethdev.com +func ReportBlock(block *types.Block, err error) { + if DisableBadBlockReporting { + return + } + + const url = "https://badblocks.ethdev.com" + + blockRlp, _ := rlp.EncodeToBytes(block) + data := map[string]interface{}{ + "block": common.Bytes2Hex(blockRlp), + "errortype": err.Error(), + "hints": map[string]interface{}{ + "receipts": "NYI", + "vmtrace": "NYI", + }, + } + jsonStr, _ := json.Marshal(map[string]interface{}{"method": "eth_badBlock", "params": []interface{}{data}, "id": "1", "jsonrpc": "2.0"}) + + req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) + req.Header.Set("Content-Type", "application/json") + + client := &http.Client{} + resp, err := client.Do(req) + if err != nil { + glog.V(logger.Error).Infoln("POST err:", err) + return + } + defer resp.Body.Close() + + if glog.V(logger.Debug) { + glog.Infoln("response Status:", resp.Status) + glog.Infoln("response Headers:", resp.Header) + body, _ := ioutil.ReadAll(resp.Body) + glog.Infoln("response Body:", string(body)) + } +} diff --git a/core/chain_manager.go b/core/chain_manager.go index 4855162b5..682ddd2d5 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -611,6 +611,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { blockErr(block, err) + go ReportBlock(block, err) + return i, err } -- cgit v1.2.3 From ec9620fb2f375379d3404a834a3350089702648a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 6 Jul 2015 10:43:06 +0200 Subject: core/types, xeth: separate tx hash and tx signature hash --- core/types/transaction.go | 18 +++++++++++++----- core/types/transaction_test.go | 6 +++--- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/types/transaction.go b/core/types/transaction.go index 95deac36e..c381fc5f3 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -116,11 +116,21 @@ func (tx *Transaction) To() *common.Address { } } +// Hash hashes the RLP encoding of tx. +// It uniquely identifies the transaction. func (tx *Transaction) Hash() common.Hash { if hash := tx.hash.Load(); hash != nil { return hash.(common.Hash) } - v := rlpHash([]interface{}{ + v := rlpHash(tx) + tx.hash.Store(v) + return v +} + +// SigHash returns the hash to be signed by the sender. +// It does not uniquely identify the transaction. +func (tx *Transaction) SigHash() common.Hash { + return rlpHash([]interface{}{ tx.data.AccountNonce, tx.data.Price, tx.data.GasLimit, @@ -128,8 +138,6 @@ func (tx *Transaction) Hash() common.Hash { tx.data.Amount, tx.data.Payload, }) - tx.hash.Store(v) - return v } func (tx *Transaction) Size() common.StorageSize { @@ -180,7 +188,7 @@ func (tx *Transaction) publicKey() ([]byte, error) { sig[64] = tx.data.V - 27 // recover the public key from the signature - hash := tx.Hash() + hash := tx.SigHash() pub, err := crypto.Ecrecover(hash[:], sig) if err != nil { glog.V(logger.Error).Infof("Could not get pubkey from signature: ", err) @@ -204,7 +212,7 @@ func (tx *Transaction) WithSignature(sig []byte) (*Transaction, error) { } func (tx *Transaction) SignECDSA(prv *ecdsa.PrivateKey) (*Transaction, error) { - h := tx.Hash() + h := tx.SigHash() sig, err := crypto.Sign(h[:], prv) if err != nil { return nil, err diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index dd9c5e87b..c9da4b73b 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -34,11 +34,11 @@ var ( ) ) -func TestTransactionHash(t *testing.T) { - if emptyTx.Hash() != common.HexToHash("c775b99e7ad12f50d819fcd602390467e28141316969f4b57f0626f74fe3b386") { +func TestTransactionSigHash(t *testing.T) { + if emptyTx.SigHash() != common.HexToHash("c775b99e7ad12f50d819fcd602390467e28141316969f4b57f0626f74fe3b386") { t.Errorf("empty transaction hash mismatch, got %x", emptyTx.Hash()) } - if rightvrsTx.Hash() != common.HexToHash("fe7a79529ed5f7c3375d06b26b186a8644e0e16c373d7a12be41c62d6042b77a") { + if rightvrsTx.SigHash() != common.HexToHash("fe7a79529ed5f7c3375d06b26b186a8644e0e16c373d7a12be41c62d6042b77a") { t.Errorf("RightVRS transaction hash mismatch, got %x", rightvrsTx.Hash()) } } -- cgit v1.2.3 From e6bb9c1cadd311475f54ed60630fc20eb2f54871 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Mon, 6 Jul 2015 11:54:11 +0200 Subject: core, miner: removed vm errors from consensus err checking Removed VM errors from the consensus errors. They now used for output only. --- core/block_processor.go | 5 ++--- core/state_transition.go | 7 +++++++ core/types/transaction.go | 4 +++- core/vm/errors.go | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 660c917e4..9a7478381 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -9,7 +9,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" @@ -73,7 +72,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated cb := statedb.GetStateObject(coinbase.Address()) _, gas, err := ApplyMessage(NewEnv(statedb, self.bc, tx, header), tx, cb) - if err != nil && err != vm.OutOfGasError { + if err != nil { return nil, nil, err } @@ -119,7 +118,7 @@ func (self *BlockProcessor) ApplyTransactions(coinbase *state.StateObject, state statedb.StartRecord(tx.Hash(), block.Hash(), i) receipt, txGas, err := self.ApplyTransaction(coinbase, statedb, header, tx, totalUsedGas, transientProcess) - if err != nil && err != vm.OutOfGasError { + if err != nil { return nil, err } diff --git a/core/state_transition.go b/core/state_transition.go index 465000e87..5bcf6c45d 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -203,16 +203,23 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er glog.V(logger.Core).Infoln("Insufficient gas for creating code. Require", dataGas, "and have", self.gas) } } + glog.V(logger.Core).Infoln("VM create err:", err) } else { // Increment the nonce for the next transaction self.state.SetNonce(sender.Address(), sender.Nonce()+1) ret, err = vmenv.Call(sender, self.To().Address(), self.data, self.gas, self.gasPrice, self.value) + glog.V(logger.Core).Infoln("VM call err:", err) } if err != nil && IsValueTransferErr(err) { return nil, nil, InvalidTxError(err) } + // We aren't interested in errors here. Errors returned by the VM are non-consensus errors and therefor shouldn't bubble up + if err != nil { + err = nil + } + if vm.Debug { vm.StdErrFormat(vmenv.StructLogs()) } diff --git a/core/types/transaction.go b/core/types/transaction.go index c381fc5f3..f5392382b 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -15,6 +15,8 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) +var ErrInvalidSig = errors.New("invalid v, r, s values") + func IsContractAddr(addr []byte) bool { return len(addr) == 0 } @@ -177,7 +179,7 @@ func (tx *Transaction) SignatureValues() (v byte, r *big.Int, s *big.Int) { func (tx *Transaction) publicKey() ([]byte, error) { if !crypto.ValidateSignatureValues(tx.data.V, tx.data.R, tx.data.S) { - return nil, errors.New("invalid v, r, s values") + return nil, ErrInvalidSig } // encode the signature in uncompressed format diff --git a/core/vm/errors.go b/core/vm/errors.go index 75b9c0f10..209b64c7d 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -22,7 +22,7 @@ func (self StackError) Error() string { return fmt.Sprintf("stack error! require %v, have %v", self.req, self.has) } -func IsStack(err error) bool { +func IsStackErr(err error) bool { _, ok := err.(StackError) return ok } -- cgit v1.2.3 From 666a7dda369e9a30715f560c8f72b81735a347fc Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Mon, 6 Jul 2015 20:59:12 +0200 Subject: core, eth, rpc: proper gas used. Closes #1417 Added some additional backward compatibility code for old receipts --- core/block_processor.go | 1 + core/transaction_util.go | 2 +- core/types/receipt.go | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/block_processor.go b/core/block_processor.go index 9a7478381..362036445 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -82,6 +82,7 @@ func (self *BlockProcessor) ApplyTransaction(coinbase *state.StateObject, stated usedGas.Add(usedGas, gas) receipt := types.NewReceipt(statedb.Root().Bytes(), usedGas) receipt.TxHash = tx.Hash() + receipt.GasUsed = new(big.Int).Set(gas) if MessageCreatesContract(tx) { from, _ := tx.From() receipt.ContractAddress = crypto.CreateAddress(from, tx.Nonce()) diff --git a/core/transaction_util.go b/core/transaction_util.go index cb5d6c7f7..7d432848a 100644 --- a/core/transaction_util.go +++ b/core/transaction_util.go @@ -64,7 +64,7 @@ func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt { var receipt types.Receipt err := rlp.DecodeBytes(data, &receipt) if err != nil { - glog.V(logger.Error).Infoln("GetReceipt err:", err) + glog.V(logger.Core).Infoln("GetReceipt err:", err) } return &receipt } diff --git a/core/types/receipt.go b/core/types/receipt.go index ab52c6e60..aff29f565 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -18,6 +18,7 @@ type Receipt struct { TxHash common.Hash ContractAddress common.Address logs state.Logs + GasUsed *big.Int } func NewReceipt(root []byte, cumalativeGasUsed *big.Int) *Receipt { @@ -44,11 +45,12 @@ func (self *Receipt) DecodeRLP(s *rlp.Stream) error { TxHash common.Hash ContractAddress common.Address Logs state.Logs + GasUsed *big.Int } if err := s.Decode(&r); err != nil { return err } - self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs + self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, self.logs, self.GasUsed = r.PostState, r.CumulativeGasUsed, r.Bloom, r.TxHash, r.ContractAddress, r.Logs, r.GasUsed return nil } @@ -60,7 +62,7 @@ func (self *ReceiptForStorage) EncodeRLP(w io.Writer) error { for i, log := range self.logs { storageLogs[i] = (*state.LogForStorage)(log) } - return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, storageLogs}) + return rlp.Encode(w, []interface{}{self.PostState, self.CumulativeGasUsed, self.Bloom, self.TxHash, self.ContractAddress, storageLogs, self.GasUsed}) } func (self *Receipt) RlpEncode() []byte { -- cgit v1.2.3 From ea54283b304a1d308141d21e3ef75b7de0f4519d Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 02:54:22 +0200 Subject: all: update license information --- core/asm.go | 16 ++++++++++++++++ core/bad_block.go | 16 ++++++++++++++++ core/bench_test.go | 16 ++++++++++++++++ core/block_cache.go | 16 ++++++++++++++++ core/block_cache_test.go | 16 ++++++++++++++++ core/block_processor.go | 16 ++++++++++++++++ core/block_processor_test.go | 16 ++++++++++++++++ core/blocks.go | 16 ++++++++++++++++ core/canary.go | 16 ++++++++++++++++ core/chain_makers.go | 16 ++++++++++++++++ core/chain_makers_test.go | 16 ++++++++++++++++ core/chain_manager.go | 16 ++++++++++++++++ core/chain_manager_test.go | 16 ++++++++++++++++ core/chain_util.go | 16 ++++++++++++++++ core/error.go | 16 ++++++++++++++++ core/events.go | 16 ++++++++++++++++ core/execution.go | 16 ++++++++++++++++ core/fees.go | 16 ++++++++++++++++ core/filter.go | 16 ++++++++++++++++ core/filter_test.go | 16 ++++++++++++++++ core/genesis.go | 16 ++++++++++++++++ core/helper_test.go | 16 ++++++++++++++++ core/manager.go | 16 ++++++++++++++++ core/state/dump.go | 16 ++++++++++++++++ core/state/errors.go | 16 ++++++++++++++++ core/state/log.go | 16 ++++++++++++++++ core/state/main_test.go | 16 ++++++++++++++++ core/state/managed_state.go | 16 ++++++++++++++++ core/state/managed_state_test.go | 16 ++++++++++++++++ core/state/state_object.go | 16 ++++++++++++++++ core/state/state_test.go | 16 ++++++++++++++++ core/state/statedb.go | 16 ++++++++++++++++ core/state_transition.go | 16 ++++++++++++++++ core/transaction_pool.go | 16 ++++++++++++++++ core/transaction_pool_test.go | 16 ++++++++++++++++ core/transaction_util.go | 16 ++++++++++++++++ core/types/block.go | 16 ++++++++++++++++ core/types/block_test.go | 16 ++++++++++++++++ core/types/bloom9.go | 16 ++++++++++++++++ core/types/bloom9_test.go | 16 ++++++++++++++++ core/types/common.go | 16 ++++++++++++++++ core/types/derive_sha.go | 16 ++++++++++++++++ core/types/receipt.go | 16 ++++++++++++++++ core/types/transaction.go | 16 ++++++++++++++++ core/types/transaction_test.go | 16 ++++++++++++++++ core/vm/analysis.go | 16 ++++++++++++++++ core/vm/asm.go | 16 ++++++++++++++++ core/vm/common.go | 16 ++++++++++++++++ core/vm/context.go | 16 ++++++++++++++++ core/vm/contracts.go | 16 ++++++++++++++++ core/vm/disasm.go | 16 ++++++++++++++++ core/vm/environment.go | 16 ++++++++++++++++ core/vm/errors.go | 16 ++++++++++++++++ core/vm/gas.go | 16 ++++++++++++++++ core/vm/logger.go | 16 ++++++++++++++++ core/vm/memory.go | 16 ++++++++++++++++ core/vm/opcodes.go | 16 ++++++++++++++++ core/vm/stack.go | 16 ++++++++++++++++ core/vm/virtual_machine.go | 16 ++++++++++++++++ core/vm/vm.go | 16 ++++++++++++++++ core/vm/vm_jit.go | 16 ++++++++++++++++ core/vm/vm_jit_fake.go | 16 ++++++++++++++++ core/vm_env.go | 16 ++++++++++++++++ 63 files changed, 1008 insertions(+) (limited to 'core') diff --git a/core/asm.go b/core/asm.go index f40c07904..071663992 100644 --- a/core/asm.go +++ b/core/asm.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/bad_block.go b/core/bad_block.go index e8e736a13..55c114645 100644 --- a/core/bad_block.go +++ b/core/bad_block.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/bench_test.go b/core/bench_test.go index 8cd8c4299..645df48c2 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/block_cache.go b/core/block_cache.go index 0c747d37c..655f6c24b 100644 --- a/core/block_cache.go +++ b/core/block_cache.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/block_cache_test.go b/core/block_cache_test.go index 80d118599..abea0a654 100644 --- a/core/block_cache_test.go +++ b/core/block_cache_test.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/block_processor.go b/core/block_processor.go index 362036445..e912c0b6e 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/block_processor_test.go b/core/block_processor_test.go index 8c38d531f..4250b897b 100644 --- a/core/block_processor_test.go +++ b/core/block_processor_test.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/blocks.go b/core/blocks.go index f0d39e1e1..b3a559279 100644 --- a/core/blocks.go +++ b/core/blocks.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import "github.com/ethereum/go-ethereum/common" diff --git a/core/canary.go b/core/canary.go index 90b4a2eaf..710e31530 100644 --- a/core/canary.go +++ b/core/canary.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/chain_makers.go b/core/chain_makers.go index c46f627f8..07670608a 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/chain_makers_test.go b/core/chain_makers_test.go index f4eeef082..2f001be9b 100644 --- a/core/chain_makers_test.go +++ b/core/chain_makers_test.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/chain_manager.go b/core/chain_manager.go index 682ddd2d5..d8123c14e 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go index c013fc729..92f080f01 100644 --- a/core/chain_manager_test.go +++ b/core/chain_manager_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/chain_util.go b/core/chain_util.go index 8051cc47a..96c9a03d8 100644 --- a/core/chain_util.go +++ b/core/chain_util.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/error.go b/core/error.go index fb64d09b2..299317a8e 100644 --- a/core/error.go +++ b/core/error.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/events.go b/core/events.go index 7b56f8bb6..e47f78923 100644 --- a/core/events.go +++ b/core/events.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/execution.go b/core/execution.go index a8c4ffb6d..a4734dca5 100644 --- a/core/execution.go +++ b/core/execution.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/fees.go b/core/fees.go index bbce01b84..0eda52f6d 100644 --- a/core/fees.go +++ b/core/fees.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/filter.go b/core/filter.go index 121e4642d..277976a55 100644 --- a/core/filter.go +++ b/core/filter.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/filter_test.go b/core/filter_test.go index 9a8bc9592..50dc64b2e 100644 --- a/core/filter_test.go +++ b/core/filter_test.go @@ -1 +1,17 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core diff --git a/core/genesis.go b/core/genesis.go index d27e7097b..2d369aae0 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/helper_test.go b/core/helper_test.go index a308153aa..fbd900ab7 100644 --- a/core/helper_test.go +++ b/core/helper_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/manager.go b/core/manager.go index 576cf55b0..a72ef1952 100644 --- a/core/manager.go +++ b/core/manager.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/state/dump.go b/core/state/dump.go index f6f2f9029..d1273f9b6 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/errors.go b/core/state/errors.go index 5a847d38b..29acb5cc8 100644 --- a/core/state/errors.go +++ b/core/state/errors.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/log.go b/core/state/log.go index 882977061..5351c1831 100644 --- a/core/state/log.go +++ b/core/state/log.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/main_test.go b/core/state/main_test.go index f3d3f7e23..03225ba8c 100644 --- a/core/state/main_test.go +++ b/core/state/main_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/managed_state.go b/core/state/managed_state.go index aa6650d9b..4dee02992 100644 --- a/core/state/managed_state.go +++ b/core/state/managed_state.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/managed_state_test.go b/core/state/managed_state_test.go index c7ef2b323..7ae7c0393 100644 --- a/core/state/managed_state_test.go +++ b/core/state/managed_state_test.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/state_object.go b/core/state/state_object.go index e40aeda82..216ce9132 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/state_test.go b/core/state/state_test.go index b63b8ae9b..345bd9874 100644 --- a/core/state/state_test.go +++ b/core/state/state_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state/statedb.go b/core/state/statedb.go index 4ccda1fc7..7271373dd 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package state import ( diff --git a/core/state_transition.go b/core/state_transition.go index 5bcf6c45d..aacf53799 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/transaction_pool.go b/core/transaction_pool.go index ac9027755..e02a3a6ac 100644 --- a/core/transaction_pool.go +++ b/core/transaction_pool.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index 5744ef059..fdd0a7872 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/transaction_util.go b/core/transaction_util.go index 7d432848a..0efeddfde 100644 --- a/core/transaction_util.go +++ b/core/transaction_util.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( diff --git a/core/types/block.go b/core/types/block.go index e8919e9a0..45bab2c95 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/block_test.go b/core/types/block_test.go index e0b98cd26..2c1b18b5d 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/bloom9.go b/core/types/bloom9.go index aa76a2e9d..565c831ee 100644 --- a/core/types/bloom9.go +++ b/core/types/bloom9.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/bloom9_test.go b/core/types/bloom9_test.go index 3c95772ec..a3cc1922a 100644 --- a/core/types/bloom9_test.go +++ b/core/types/bloom9_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types /* diff --git a/core/types/common.go b/core/types/common.go index 09d1e2fed..4a8a7b5c4 100644 --- a/core/types/common.go +++ b/core/types/common.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/derive_sha.go b/core/types/derive_sha.go index f25e5937e..c446a5f27 100644 --- a/core/types/derive_sha.go +++ b/core/types/derive_sha.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/receipt.go b/core/types/receipt.go index aff29f565..7c44e6307 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/transaction.go b/core/types/transaction.go index f5392382b..09fde8ebe 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index c9da4b73b..77717ce28 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package types import ( diff --git a/core/vm/analysis.go b/core/vm/analysis.go index a7aa8da39..ba0a02e0a 100644 --- a/core/vm/analysis.go +++ b/core/vm/analysis.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/asm.go b/core/vm/asm.go index 83fcb0e08..c5c6ef269 100644 --- a/core/vm/asm.go +++ b/core/vm/asm.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/common.go b/core/vm/common.go index 7b8b7dc4d..c40712bfe 100644 --- a/core/vm/common.go +++ b/core/vm/common.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/context.go b/core/vm/context.go index e33324b53..05bcee86c 100644 --- a/core/vm/context.go +++ b/core/vm/context.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 90e356b1d..f32df3d41 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/disasm.go b/core/vm/disasm.go index 858ee684a..bb07b5816 100644 --- a/core/vm/disasm.go +++ b/core/vm/disasm.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import "fmt" diff --git a/core/vm/environment.go b/core/vm/environment.go index 0a5891f5c..2368b5170 100644 --- a/core/vm/environment.go +++ b/core/vm/environment.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/errors.go b/core/vm/errors.go index 209b64c7d..d0c332068 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/gas.go b/core/vm/gas.go index 32f5fec04..1710ef0c9 100644 --- a/core/vm/gas.go +++ b/core/vm/gas.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/logger.go b/core/vm/logger.go index 0e2a417ae..a99b268b4 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/memory.go b/core/vm/memory.go index ea2ee80fb..413507ae5 100644 --- a/core/vm/memory.go +++ b/core/vm/memory.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import "fmt" diff --git a/core/vm/opcodes.go b/core/vm/opcodes.go index 1ea80a212..5c74220a5 100644 --- a/core/vm/opcodes.go +++ b/core/vm/opcodes.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/stack.go b/core/vm/stack.go index 2be5c3dbe..31541f38f 100644 --- a/core/vm/stack.go +++ b/core/vm/stack.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/virtual_machine.go b/core/vm/virtual_machine.go index 1fd1dcd88..44d3d5d7e 100644 --- a/core/vm/virtual_machine.go +++ b/core/vm/virtual_machine.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm type VirtualMachine interface { diff --git a/core/vm/vm.go b/core/vm/vm.go index e390fb89c..3fca5f636 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package vm import ( diff --git a/core/vm/vm_jit.go b/core/vm/vm_jit.go index 991ade318..25e59eaf4 100644 --- a/core/vm/vm_jit.go +++ b/core/vm/vm_jit.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + // +build evmjit package vm diff --git a/core/vm/vm_jit_fake.go b/core/vm/vm_jit_fake.go index d6b5be45b..66a6d833d 100644 --- a/core/vm/vm_jit_fake.go +++ b/core/vm/vm_jit_fake.go @@ -1,3 +1,19 @@ +// Copyright 2015 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + // +build !evmjit package vm diff --git a/core/vm_env.go b/core/vm_env.go index 24a29545f..8a39af196 100644 --- a/core/vm_env.go +++ b/core/vm_env.go @@ -1,3 +1,19 @@ +// Copyright 2014 The go-ethereum Authors +// This file is part of go-ethereum. +// +// go-ethereum is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// go-ethereum is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with go-ethereum. If not, see . + package core import ( -- cgit v1.2.3 From bdae4fd573dbc163bab3d0e2d1a5c457892037cd Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 05:08:16 +0200 Subject: all: add some godoc synopsis comments --- core/chain_manager.go | 1 + core/state/statedb.go | 1 + core/types/block.go | 1 + core/vm/vm.go | 1 + 4 files changed, 4 insertions(+) (limited to 'core') diff --git a/core/chain_manager.go b/core/chain_manager.go index d8123c14e..bd49bafc2 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with go-ethereum. If not, see . +// Package core implements the Ethereum consensus protocol. package core import ( diff --git a/core/state/statedb.go b/core/state/statedb.go index 7271373dd..3a2ad10e2 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with go-ethereum. If not, see . +// Package state provides a caching layer atop the Ethereum state trie. package state import ( diff --git a/core/types/block.go b/core/types/block.go index 45bab2c95..562fa64b9 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with go-ethereum. If not, see . +// Package types contains data types related to Ethereum consensus. package types import ( diff --git a/core/vm/vm.go b/core/vm/vm.go index 3fca5f636..9b3fd0009 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with go-ethereum. If not, see . +// Package vm implements the Ethereum Virtual Machine. package vm import ( -- cgit v1.2.3 From 4fb28e0dab912854570c6b6b183004f4b3e7ac05 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Jul 2015 05:10:49 +0200 Subject: all: goimports -w --- core/vm/vm_jit.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/vm/vm_jit.go b/core/vm/vm_jit.go index 25e59eaf4..34f45b5f4 100644 --- a/core/vm/vm_jit.go +++ b/core/vm/vm_jit.go @@ -34,10 +34,12 @@ import ( "bytes" "errors" "fmt" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/crypto" "math/big" "unsafe" + + "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" ) type JitVm struct { -- cgit v1.2.3