good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 4a176e44 authored by Alex Sharov's avatar Alex Sharov Committed by GitHub
Browse files

Mining docs (#1628)

parent 86ccfd03
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ Turbo-Geth is a fork of [Go-Ethereum](https://github.com/ethereum/go-ethereum) w ...@@ -7,6 +7,7 @@ Turbo-Geth is a fork of [Go-Ethereum](https://github.com/ethereum/go-ethereum) w
- [Usage](#usage) - [Usage](#usage)
+ [Getting Started](#getting-started) + [Getting Started](#getting-started)
+ [Testnets](#testnets) + [Testnets](#testnets)
+ [Mining](#mining)
+ [Windows](#windows) + [Windows](#windows)
+ [GoDoc](https://godoc.org/github.com/ledgerwatch/turbo-geth) + [GoDoc](https://godoc.org/github.com/ledgerwatch/turbo-geth)
- [Key features](#key-features) - [Key features](#key-features)
...@@ -67,6 +68,24 @@ If you would like to give turbo-geth a try, but do not have spare 2Tb on your dr ...@@ -67,6 +68,24 @@ If you would like to give turbo-geth a try, but do not have spare 2Tb on your dr
Please note the `--datadir` option that allows you to store turbo-geth files in a non-default location, in this example, in `goerli` subdirectory of the current directory. Please note the `--datadir` option that allows you to store turbo-geth files in a non-default location, in this example, in `goerli` subdirectory of the current directory.
### Mining
Support only remote-miners.
* To enable, add `--mine --miner.etherbase=...` or `--mine --miner.miner.sigkey=...` flags.
* Other supported options: `--miner.extradata`, `--miner.notify`, `--miner.gaslimit`, `--miner.gasprice`
, `--miner.gastarget`
* RPCDaemon supports methods: eth_coinbase , eth_hashrate, eth_mining, eth_getWork, eth_submitWork, eth_submitHashrate
* RPCDaemon supports websocket methods: newPendingTransaction
* TODO:
+ we don't broadcast mined blocks to p2p-network yet, [but it's easy to accomplish](https://github.com/ledgerwatch/turbo-geth/blob/9b8cdc0f2289a7cef78218a15043de5bdff4465e/eth/downloader/downloader.go#L673)
+ eth_newPendingTransactionFilter
+ eth_newBlockFilter
+ eth_newFilter
+ websocket Logs
<code> 🔬 Detailed mining explanation is [here](/docs/mining.md).</code>
### Windows ### Windows
Windows users may run turbo-geth in 3 possible ways: Windows users may run turbo-geth in 3 possible ways:
......
This diff is collapsed.
## Mining
Support only remote-miners.
* To enable, add `--mine --miner.etherbase=...` or `--mine --miner.miner.sigkey=...` flags.
* Other supported options: `--miner.extradata`, `--miner.notify`, `--miner.gaslimit`, `--miner.gasprice`
, `--miner.gastarget`
* RPCDaemon supports methods: eth_coinbase , eth_hashrate, eth_mining, eth_getWork, eth_submitWork, eth_submitHashrate
* RPCDaemon supports websocket methods: newPendingTransaction
## Implementation details
* mining implemented as independent 🔬[Staged Sync](/eth/stagedsync/)
* stages are declared in `eth/stagedsync/stagebuilder.go:MiningStages`
* mining work done inside 1 db transaction which RollingBack after block prepared and `--miner.notify` notifications
sent
## Testing
Integration tool - supports mining of existing blocks. It moving TurboGeth to block X, does mine block X+1, then compare
mined block with real block X+1 in db. To enable - just add `--mine --miner.etherbase=<etherbase>` flag
to `integration state_stages` command:
```
./build/bin/integration state_stages --datadir=<datadir> --unwind=1 --unwind.every=2 --integrity.fast=false --integrity.slow=false --mine --miner.etherbase=<etherbase>
```
* TODO:
+ we don't broadcast mined blocks to p2p-network yet, [but it's easy to accomplish](https://github.com/ledgerwatch/turbo-geth/blob/9b8cdc0f2289a7cef78218a15043de5bdff4465e/eth/downloader/downloader.go#L673)
+ eth_newPendingTransactionFilter
+ eth_newBlockFilter
+ eth_newFilter
+ websocket Logs
package stagedsync package stagedsync
import ( import (
"fmt"
"github.com/ledgerwatch/turbo-geth/consensus" "github.com/ledgerwatch/turbo-geth/consensus"
"github.com/ledgerwatch/turbo-geth/core/types" "github.com/ledgerwatch/turbo-geth/core/types"
"github.com/ledgerwatch/turbo-geth/ethdb" "github.com/ledgerwatch/turbo-geth/ethdb"
...@@ -11,7 +13,7 @@ import ( ...@@ -11,7 +13,7 @@ import (
//var prev common.Hash //var prev common.Hash
func SpawnMiningFinishStage(s *StageState, tx ethdb.Database, current *miningBlock, engine consensus.Engine, chainConfig *params.ChainConfig, results chan<- *types.Block, sealCancel <-chan struct{}, quit <-chan struct{}) error { func SpawnMiningFinishStage(s *StageState, tx ethdb.Database, current *miningBlock, engine consensus.Engine, chainConfig *params.ChainConfig, results chan<- *types.Block, sealCancel <-chan struct{}, quit <-chan struct{}) error {
//logPrefix := s.state.LogPrefix() logPrefix := s.state.LogPrefix()
// Short circuit when receiving duplicate result caused by resubmitting. // Short circuit when receiving duplicate result caused by resubmitting.
//if w.chain.HasBlock(block.Hash(), block.NumberU64()) { //if w.chain.HasBlock(block.Hash(), block.NumberU64()) {
...@@ -36,24 +38,19 @@ func SpawnMiningFinishStage(s *StageState, tx ethdb.Database, current *miningBlo ...@@ -36,24 +38,19 @@ func SpawnMiningFinishStage(s *StageState, tx ethdb.Database, current *miningBlo
return nil return nil
} }
log.Info(fmt.Sprintf("[%s] block ready for seal", logPrefix),
"number", block.NumberU64(),
"transactions", block.Transactions().Len(),
"gas_used", block.GasUsed(),
"gas_limit", block.GasLimit(),
"difficulty", block.Difficulty(),
)
chain := ChainReader{chainConfig, tx} chain := ChainReader{chainConfig, tx}
if err := engine.Seal(chain, block, results, sealCancel); err != nil { if err := engine.Seal(chain, block, results, sealCancel); err != nil {
log.Warn("Block sealing failed", "err", err) log.Warn("Block sealing failed", "err", err)
} }
//select {
//case <-ctx.Done():
// return ctx.Err()
//case <-quit:
// ctx.CancelFunc()
// return common.ErrStopped
//case result := <-resultCh:
// block = result.Block
//}
//
//log.Info(fmt.Sprintf("[%s] mined block", logPrefix), "txs", block.Transactions().Len())
//result <- *block
s.Done() s.Done()
return nil return nil
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment