mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
remove database field from Ethereum object (#1750)
This commit is contained in:
parent
00f700675b
commit
5019610cfb
@ -16,28 +16,7 @@
|
||||
|
||||
package eth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/ledgerwatch/turbo-geth/common"
|
||||
"github.com/ledgerwatch/turbo-geth/consensus"
|
||||
"github.com/ledgerwatch/turbo-geth/core"
|
||||
"github.com/ledgerwatch/turbo-geth/core/bloombits"
|
||||
"github.com/ledgerwatch/turbo-geth/core/rawdb"
|
||||
"github.com/ledgerwatch/turbo-geth/core/state"
|
||||
"github.com/ledgerwatch/turbo-geth/core/types"
|
||||
"github.com/ledgerwatch/turbo-geth/core/vm"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/downloader"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/gasprice"
|
||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||
"github.com/ledgerwatch/turbo-geth/event"
|
||||
"github.com/ledgerwatch/turbo-geth/params"
|
||||
"github.com/ledgerwatch/turbo-geth/rpc"
|
||||
)
|
||||
|
||||
/*
|
||||
// EthAPIBackend implements ethapi.Backend for full nodes
|
||||
type EthAPIBackend struct {
|
||||
extRPCEnabled bool
|
||||
@ -362,3 +341,4 @@ func (b *EthAPIBackend) StatesInRange(ctx context.Context, fromBlock *types.Bloc
|
||||
func (b *EthAPIBackend) StateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (core.Message, vm.BlockContext, *state.IntraBlockState, func(), error) {
|
||||
return b.eth.stateAtTransaction(block, txIndex, reexec)
|
||||
}
|
||||
*/
|
||||
|
@ -50,13 +50,11 @@ import (
|
||||
"github.com/ledgerwatch/turbo-geth/eth/downloader"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/ethconfig"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/ethutils"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/gasprice"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/protocols/eth"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/stagedsync"
|
||||
"github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages"
|
||||
"github.com/ledgerwatch/turbo-geth/ethdb"
|
||||
"github.com/ledgerwatch/turbo-geth/ethdb/remote/remotedbserver"
|
||||
"github.com/ledgerwatch/turbo-geth/internal/ethapi"
|
||||
"github.com/ledgerwatch/turbo-geth/log"
|
||||
"github.com/ledgerwatch/turbo-geth/node"
|
||||
"github.com/ledgerwatch/turbo-geth/p2p"
|
||||
@ -85,22 +83,21 @@ type Ethereum struct {
|
||||
snapDialCandidates enode.Iterator
|
||||
|
||||
// DB interfaces
|
||||
chainDb ethdb.Database // Block chain database
|
||||
chainKV ethdb.RwKV // Same as chainDb, but different interface
|
||||
chainKV ethdb.RwKV // Same as chainDb, but different interface
|
||||
privateAPI *grpc.Server
|
||||
|
||||
engine consensus.Engine
|
||||
|
||||
bloomRequests chan chan *bloombits.Retrieval // Channel receiving bloom data retrieval requests
|
||||
|
||||
APIBackend *EthAPIBackend
|
||||
//APIBackend *EthAPIBackend
|
||||
|
||||
gasPrice *uint256.Int
|
||||
etherbase common.Address
|
||||
signer *ecdsa.PrivateKey
|
||||
|
||||
networkID uint64
|
||||
netRPCService *ethapi.PublicNetAPI
|
||||
networkID uint64
|
||||
//netRPCService *ethapi.PublicNetAPI
|
||||
|
||||
p2pServer *p2p.Server
|
||||
|
||||
@ -273,7 +270,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||
|
||||
eth := &Ethereum{
|
||||
config: config,
|
||||
chainDb: chainDb,
|
||||
chainKV: chainDb.(ethdb.HasRwKV).RwKV(),
|
||||
engine: ethconfig.CreateConsensusEngine(chainConfig, &config.Ethash, config.Miner.Notify, config.Miner.Noverify, chainDb),
|
||||
networkID: config.NetworkID,
|
||||
@ -439,12 +435,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||
eth.handler.SetStagedSync(stagedSync)
|
||||
eth.handler.SetMining(mining)
|
||||
|
||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
||||
//eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
||||
gpoParams := config.GPO
|
||||
if gpoParams.Default == nil {
|
||||
gpoParams.Default = config.Miner.GasPrice
|
||||
}
|
||||
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
|
||||
//eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
|
||||
eth.ethDialCandidates, err = setupDiscovery(eth.config.EthDiscoveryURLs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -498,6 +494,11 @@ func BlockchainRuntimeConfig(config *ethconfig.Config) (vm.Config, *core.CacheCo
|
||||
// return extra
|
||||
// }
|
||||
|
||||
func (s *Ethereum) APIs() []rpc.API {
|
||||
return []rpc.API{}
|
||||
}
|
||||
|
||||
/*
|
||||
// APIs return the collection of RPC services the ethereum package offers.
|
||||
// NOTE, some of these services probably need to be moved to somewhere else.
|
||||
func (s *Ethereum) APIs() []rpc.API {
|
||||
@ -564,6 +565,7 @@ func (s *Ethereum) APIs() []rpc.API {
|
||||
},
|
||||
}...)
|
||||
}
|
||||
*/
|
||||
|
||||
func (s *Ethereum) Etherbase() (eb common.Address, err error) {
|
||||
s.lock.RLock()
|
||||
@ -684,7 +686,6 @@ func (s *Ethereum) IsMining() bool { return s.config.Miner.Enabled }
|
||||
func (s *Ethereum) BlockChain() *core.BlockChain { return s.blockchain }
|
||||
func (s *Ethereum) TxPool() *core.TxPool { return s.txPool }
|
||||
func (s *Ethereum) Engine() consensus.Engine { return s.engine }
|
||||
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
|
||||
func (s *Ethereum) ChainKV() ethdb.RwKV { return s.chainKV }
|
||||
func (s *Ethereum) IsListening() bool { return true } // Always listening
|
||||
func (s *Ethereum) Downloader() *downloader.Downloader { return s.handler.downloader }
|
||||
@ -698,7 +699,11 @@ func (s *Ethereum) ArchiveMode() bool { return !s.config.Pruning }
|
||||
// Protocols returns all the currently configured
|
||||
// network protocols to start.
|
||||
func (s *Ethereum) Protocols() []p2p.Protocol {
|
||||
headHeight, _ := stages.GetStageProgress(s.chainDb, stages.Finish)
|
||||
var headHeight uint64
|
||||
_ = s.chainKV.View(context.Background(), func(tx ethdb.Tx) error {
|
||||
headHeight, _ = stages.GetStageProgress(tx, stages.Finish)
|
||||
return nil
|
||||
})
|
||||
protos := eth.MakeProtocols((*ethHandler)(s.handler), s.networkID, s.ethDialCandidates, s.chainConfig, s.genesisHash, headHeight)
|
||||
return protos
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package eth
|
||||
|
||||
/*
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
@ -33,3 +34,4 @@ const (
|
||||
// to accumulate request an entire batch (avoiding hysteresis).
|
||||
bloomRetrievalWait = time.Duration(0)
|
||||
)
|
||||
*/
|
||||
|
@ -121,6 +121,8 @@ type Config struct {
|
||||
Pruning bool // Whether to disable pruning and flush everything to disk
|
||||
TxLookupLimit uint64 `toml:",omitempty"` // The maximum number of blocks from head whose tx indices are reserved.
|
||||
|
||||
EnableDownloaderV2 bool
|
||||
|
||||
StorageMode ethdb.StorageMode
|
||||
CacheSize datasize.ByteSize // Cache size for execution stage
|
||||
BatchSize datasize.ByteSize // Batch size for execution stage
|
||||
|
@ -15,30 +15,3 @@
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package eth
|
||||
|
||||
import (
|
||||
"github.com/ledgerwatch/turbo-geth/core"
|
||||
"github.com/ledgerwatch/turbo-geth/core/state"
|
||||
"github.com/ledgerwatch/turbo-geth/core/types"
|
||||
"github.com/ledgerwatch/turbo-geth/core/vm"
|
||||
)
|
||||
|
||||
// stateAtBlock retrieves the state database associated with a certain block.
|
||||
// If no state is locally available for the given block, a number of blocks are
|
||||
// attempted to be reexecuted to generate the desired state.
|
||||
func (eth *Ethereum) stateAtBlock(block *types.Block, reexec uint64) (statedb *state.IntraBlockState, release func(), err error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// statesInRange retrieves a batch of state databases associated with the specific
|
||||
// block ranges. If no state is locally available for the given range, a number of
|
||||
// blocks are attempted to be reexecuted to generate the ancestor state.
|
||||
func (eth *Ethereum) statesInRange(fromBlock, toBlock *types.Block, reexec uint64) (states []*state.IntraBlockState, release func(), err error) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// stateAtTransaction returns the execution environment of a certain transaction.
|
||||
func (eth *Ethereum) stateAtTransaction(block *types.Block, txIndex int, reexec uint64) (core.Message, vm.BlockContext, *state.IntraBlockState, func(), error) {
|
||||
return nil, vm.BlockContext{}, nil, nil, nil
|
||||
|
||||
}
|
||||
|
@ -17,32 +17,25 @@
|
||||
package ethapi
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/holiman/uint256"
|
||||
|
||||
"github.com/ledgerwatch/turbo-geth/accounts/abi"
|
||||
"github.com/ledgerwatch/turbo-geth/common"
|
||||
"github.com/ledgerwatch/turbo-geth/common/hexutil"
|
||||
"github.com/ledgerwatch/turbo-geth/common/math"
|
||||
"github.com/ledgerwatch/turbo-geth/consensus/ethash"
|
||||
"github.com/ledgerwatch/turbo-geth/core"
|
||||
"github.com/ledgerwatch/turbo-geth/core/types"
|
||||
"github.com/ledgerwatch/turbo-geth/core/vm"
|
||||
"github.com/ledgerwatch/turbo-geth/crypto"
|
||||
"github.com/ledgerwatch/turbo-geth/log"
|
||||
"github.com/ledgerwatch/turbo-geth/p2p"
|
||||
"github.com/ledgerwatch/turbo-geth/params"
|
||||
"github.com/ledgerwatch/turbo-geth/rlp"
|
||||
"github.com/ledgerwatch/turbo-geth/rpc"
|
||||
)
|
||||
|
||||
/*
|
||||
// PublicEthereumAPI provides an API to access Ethereum related information.
|
||||
// It offers only methods that operate on public data that is freely available to anyone.
|
||||
type PublicEthereumAPI struct {
|
||||
@ -328,6 +321,7 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A
|
||||
state.GetState(address, &keyHash, &res)
|
||||
return res.Bytes(), state.Error()
|
||||
}
|
||||
*/
|
||||
|
||||
// CallArgs represents the arguments for a call.
|
||||
type CallArgs struct {
|
||||
@ -459,7 +453,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
|
||||
|
||||
// Execute the message.
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64)
|
||||
result, err := core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */)
|
||||
result, err := core.ApplyMessage(evm, msg, gp, true, false)
|
||||
if err := vmError(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -504,6 +498,7 @@ func (e *RevertError) ErrorData() interface{} {
|
||||
return e.reason
|
||||
}
|
||||
|
||||
/*
|
||||
// Call executes the given transaction on the state for the given block number.
|
||||
//
|
||||
// Additionally, the caller can specify a batch of contract for fields overriding.
|
||||
@ -644,6 +639,7 @@ func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args CallArgs, bl
|
||||
}
|
||||
return DoEstimateGas(ctx, s.b, args, bNrOrHash, s.b.RPCGasCap())
|
||||
}
|
||||
*/
|
||||
|
||||
// ExecutionResult groups all structured logs emitted by the EVM
|
||||
// while replaying a transaction in debug mode as well as transaction
|
||||
@ -765,6 +761,8 @@ func RPCMarshalBlock(block *types.Block, inclTx bool, fullTx bool) (map[string]i
|
||||
return fields, nil
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// rpcMarshalHeader uses the generalized output filler, then adds the total difficulty field, which requires
|
||||
// a `PublicBlockchainAPI`.
|
||||
func (s *PublicBlockChainAPI) rpcMarshalHeader(ctx context.Context, header *types.Header) map[string]interface{} {
|
||||
@ -785,6 +783,7 @@ func (s *PublicBlockChainAPI) rpcMarshalBlock(ctx context.Context, b *types.Bloc
|
||||
}
|
||||
return fields, err
|
||||
}
|
||||
*/
|
||||
|
||||
// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction
|
||||
type RPCTransaction struct {
|
||||
@ -850,10 +849,12 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
|
||||
return result
|
||||
}
|
||||
|
||||
/*
|
||||
// newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
|
||||
func newRPCPendingTransaction(tx *types.Transaction) *RPCTransaction {
|
||||
return newRPCTransaction(tx, common.Hash{}, 0, 0)
|
||||
}
|
||||
*/
|
||||
|
||||
// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation.
|
||||
func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransaction {
|
||||
@ -864,6 +865,7 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransacti
|
||||
return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index)
|
||||
}
|
||||
|
||||
/*
|
||||
// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.
|
||||
func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.Bytes {
|
||||
txs := b.Transactions()
|
||||
@ -873,6 +875,7 @@ func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.By
|
||||
blob, _ := txs[index].MarshalBinary()
|
||||
return blob
|
||||
}
|
||||
*/
|
||||
|
||||
// newRPCTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.
|
||||
func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransaction {
|
||||
@ -884,6 +887,7 @@ func newRPCTransactionFromBlockHash(b *types.Block, hash common.Hash) *RPCTransa
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
// PublicTransactionPoolAPI exposes methods for the RPC interface
|
||||
type PublicTransactionPoolAPI struct {
|
||||
b Backend
|
||||
@ -1351,3 +1355,4 @@ func checkTxFee(gasPrice *big.Int, gas uint64, cap float64) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
*/
|
||||
|
@ -88,6 +88,11 @@ type Backend interface {
|
||||
Engine() consensus.Engine
|
||||
}
|
||||
|
||||
func GetAPIs(apiBackend Backend) []rpc.API {
|
||||
return []rpc.API{}
|
||||
}
|
||||
|
||||
/*
|
||||
func GetAPIs(apiBackend Backend) []rpc.API {
|
||||
nonceLock := new(AddrLocker)
|
||||
return []rpc.API{
|
||||
@ -123,3 +128,4 @@ func GetAPIs(apiBackend Backend) []rpc.API {
|
||||
},
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -50,6 +50,11 @@ var (
|
||||
Value: 500,
|
||||
}
|
||||
|
||||
DownloaderV2Flag = cli.BoolFlag{
|
||||
Name: "downloader.v2",
|
||||
Usage: "enable experimental downloader v2",
|
||||
}
|
||||
|
||||
StorageModeFlag = cli.StringFlag{
|
||||
Name: "storage-mode",
|
||||
Usage: `Configures the storage mode of the app:
|
||||
@ -113,6 +118,7 @@ var (
|
||||
)
|
||||
|
||||
func ApplyFlagsForEthConfig(ctx *cli.Context, cfg *ethconfig.Config) {
|
||||
cfg.EnableDownloaderV2 = ctx.GlobalBool(DownloaderV2Flag.Name)
|
||||
mode, err := ethdb.StorageModeFromString(ctx.GlobalString(StorageModeFlag.Name))
|
||||
if err != nil {
|
||||
utils.Fatalf(fmt.Sprintf("error while parsing mode: %v", err))
|
||||
|
Loading…
Reference in New Issue
Block a user