aboutsummaryrefslogtreecommitdiff
path: root/eth
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-10-21 14:47:51 -0400
committerDeterminant <[email protected]>2019-10-21 14:47:51 -0400
commit79b1169a9ff0b54ddf3b520a70a79c78ba5c988d (patch)
tree13fc62be3ebf344544547eeb9979450a3c6ecd40 /eth
parent913e9439a7c7883881895ee597a0cc464fb92353 (diff)
customize Blockchain code
Diffstat (limited to 'eth')
-rw-r--r--eth/api.go2
-rw-r--r--eth/api_backend.go5
-rw-r--r--eth/backend.go67
-rw-r--r--eth/bloombits.go2
-rw-r--r--eth/config.go4
-rw-r--r--eth/enr_entry.go61
-rw-r--r--eth/filters/filter.go2
-rw-r--r--eth/filters/filter_system.go2
-rw-r--r--eth/gen_config.go2
-rw-r--r--eth/handler.go2
-rw-r--r--eth/protocol.go2
11 files changed, 48 insertions, 103 deletions
diff --git a/eth/api.go b/eth/api.go
index 59750ce..97a0758 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -28,11 +28,11 @@ import (
"strings"
"time"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/internal/ethapi"
"github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/common/hexutil"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/rawdb"
"github.com/ava-labs/go-ethereum/core/state"
"github.com/ava-labs/go-ethereum/core/types"
diff --git a/eth/api_backend.go b/eth/api_backend.go
index 99556c9..c4ec8f0 100644
--- a/eth/api_backend.go
+++ b/eth/api_backend.go
@@ -21,12 +21,13 @@ import (
"errors"
"math/big"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth/gasprice"
"github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/accounts"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/common/math"
- "github.com/ava-labs/go-ethereum/core"
+ ethcore "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/bloombits"
"github.com/ava-labs/go-ethereum/core/rawdb"
"github.com/ava-labs/go-ethereum/core/state"
@@ -141,7 +142,7 @@ func (b *EthAPIBackend) GetTd(blockHash common.Hash) *big.Int {
return b.eth.blockchain.GetTdByHash(blockHash)
}
-func (b *EthAPIBackend) GetEVM(ctx context.Context, msg core.Message, state *state.StateDB, header *types.Header) (*vm.EVM, func() error, error) {
+func (b *EthAPIBackend) GetEVM(ctx context.Context, msg ethcore.Message, state *state.StateDB, header *types.Header) (*vm.EVM, func() error, error) {
state.SetBalance(msg.From(), math.MaxBig256)
vmError := func() error { return nil }
diff --git a/eth/backend.go b/eth/backend.go
index 95d4c24..02a23cc 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -26,7 +26,7 @@ import (
"sync/atomic"
"github.com/ava-labs/coreth/consensus/dummy"
- mycore "github.com/ava-labs/coreth/core"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth/filters"
"github.com/ava-labs/coreth/eth/gasprice"
"github.com/ava-labs/coreth/internal/ethapi"
@@ -40,7 +40,6 @@ import (
"github.com/ava-labs/go-ethereum/consensus"
"github.com/ava-labs/go-ethereum/consensus/clique"
"github.com/ava-labs/go-ethereum/consensus/ethash"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/bloombits"
"github.com/ava-labs/go-ethereum/core/rawdb"
"github.com/ava-labs/go-ethereum/core/types"
@@ -50,7 +49,7 @@ import (
"github.com/ava-labs/go-ethereum/event"
"github.com/ava-labs/go-ethereum/log"
"github.com/ava-labs/go-ethereum/p2p"
- "github.com/ava-labs/go-ethereum/p2p/enr"
+ //"github.com/ava-labs/go-ethereum/p2p/enr"
"github.com/ava-labs/go-ethereum/params"
"github.com/ava-labs/go-ethereum/rlp"
"github.com/ava-labs/go-ethereum/rpc"
@@ -154,7 +153,7 @@ func New(ctx *node.ServiceContext, config *Config,
return nil, err
}
}
- chainConfig, genesisHash, genesisErr := mycore.SetupGenesisBlock(chainDb, config.Genesis)
+ chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis)
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
return nil, genesisErr
}
@@ -205,7 +204,7 @@ func New(ctx *node.ServiceContext, config *Config,
TrieTimeLimit: config.TrieTimeout,
}
)
- eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, chainConfig, eth.engine, vmConfig, eth.shouldPreserve)
+ eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, chainConfig, eth.engine, vmConfig, eth.shouldPreserve, config.ManualCanonical)
if err != nil {
return nil, err
}
@@ -222,15 +221,15 @@ func New(ctx *node.ServiceContext, config *Config,
}
eth.txPool = core.NewTxPool(config.TxPool, chainConfig, eth.blockchain)
- // Permit the downloader to use the trie cache allowance during fast sync
- cacheLimit := cacheConfig.TrieCleanLimit + cacheConfig.TrieDirtyLimit
- checkpoint := config.Checkpoint
- if checkpoint == nil {
- checkpoint = params.TrustedCheckpoints[genesisHash]
- }
- if eth.protocolManager, err = NewProtocolManager(chainConfig, checkpoint, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb, cacheLimit, config.Whitelist); err != nil {
- return nil, err
- }
+ //// Permit the downloader to use the trie cache allowance during fast sync
+ //cacheLimit := cacheConfig.TrieCleanLimit + cacheConfig.TrieDirtyLimit
+ //checkpoint := config.Checkpoint
+ //if checkpoint == nil {
+ // checkpoint = params.TrustedCheckpoints[genesisHash]
+ //}
+ //if eth.protocolManager, err = NewProtocolManager(chainConfig, checkpoint, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb, cacheLimit, config.Whitelist); err != nil {
+ // return nil, err
+ //}
eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock, mcb)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
@@ -295,11 +294,11 @@ func (s *Ethereum) APIs() []rpc.API {
Version: "1.0",
Service: NewPublicMinerAPI(s),
Public: true,
- }, {
- Namespace: "eth",
- Version: "1.0",
- Service: downloader.NewPublicDownloaderAPI(s.protocolManager.downloader, s.eventMux),
- Public: true,
+ //}, {
+ // Namespace: "eth",
+ // Version: "1.0",
+ // Service: downloader.NewPublicDownloaderAPI(s.protocolManager.downloader, s.eventMux),
+ // Public: true,
}, {
Namespace: "miner",
Version: "1.0",
@@ -451,9 +450,9 @@ func (s *Ethereum) StartMining(threads int) error {
log.Error("Cannot start mining without etherbase", "err", err)
return fmt.Errorf("etherbase missing: %v", err)
}
- // If mining is started, we can disable the transaction rejection mechanism
- // introduced to speed sync times.
- atomic.StoreUint32(&s.protocolManager.acceptTxs, 1)
+ //// If mining is started, we can disable the transaction rejection mechanism
+ //// introduced to speed sync times.
+ //atomic.StoreUint32(&s.protocolManager.acceptTxs, 1)
//go s.miner.Start(eb)
s.miner.Start(eb)
@@ -495,20 +494,20 @@ func (s *Ethereum) ArchiveMode() bool { return s.config.NoPruni
// network protocols to start.
func (s *Ethereum) Protocols() []p2p.Protocol {
protos := make([]p2p.Protocol, len(ProtocolVersions))
- for i, vsn := range ProtocolVersions {
- protos[i] = s.protocolManager.makeProtocol(vsn)
- protos[i].Attributes = []enr.Entry{s.currentEthEntry()}
- }
- if s.lesServer != nil {
- protos = append(protos, s.lesServer.Protocols()...)
- }
+ //for i, vsn := range ProtocolVersions {
+ // protos[i] = s.protocolManager.makeProtocol(vsn)
+ // protos[i].Attributes = []enr.Entry{s.currentEthEntry()}
+ //}
+ //if s.lesServer != nil {
+ // protos = append(protos, s.lesServer.Protocols()...)
+ //}
return protos
}
// Start implements node.Service, starting all internal goroutines needed by the
// Ethereum protocol implementation.
func (s *Ethereum) Start(srvr *p2p.Server) error {
- s.startEthEntryUpdate(srvr.LocalNode())
+ //s.startEthEntryUpdate(srvr.LocalNode())
// Start the bloom bits servicing goroutines
s.startBloomHandlers(params.BloomBitsBlocks)
@@ -525,7 +524,9 @@ func (s *Ethereum) Start(srvr *p2p.Server) error {
maxPeers -= s.config.LightPeers
}
// Start the networking layer and the light server if requested
- s.protocolManager.Start(maxPeers)
+ if s.protocolManager != nil {
+ s.protocolManager.Start(maxPeers)
+ }
if s.lesServer != nil {
s.lesServer.Start(srvr)
}
@@ -538,7 +539,9 @@ func (s *Ethereum) Stop() error {
s.bloomIndexer.Close()
s.blockchain.Stop()
s.engine.Close()
- s.protocolManager.Stop()
+ if s.protocolManager != nil {
+ s.protocolManager.Stop()
+ }
if s.lesServer != nil {
s.lesServer.Stop()
}
diff --git a/eth/bloombits.go b/eth/bloombits.go
index 0119fad..e4792bb 100644
--- a/eth/bloombits.go
+++ b/eth/bloombits.go
@@ -20,9 +20,9 @@ import (
"context"
"time"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/common/bitutil"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/bloombits"
"github.com/ava-labs/go-ethereum/core/rawdb"
"github.com/ava-labs/go-ethereum/core/types"
diff --git a/eth/config.go b/eth/config.go
index 8aee0eb..0313783 100644
--- a/eth/config.go
+++ b/eth/config.go
@@ -24,12 +24,12 @@ import (
"runtime"
"time"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth/gasprice"
"github.com/ava-labs/coreth/miner"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/common/hexutil"
"github.com/ava-labs/go-ethereum/consensus/ethash"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/eth/downloader"
"github.com/ava-labs/go-ethereum/params"
)
@@ -62,6 +62,7 @@ var DefaultConfig = Config{
Blocks: 20,
Percentile: 60,
},
+ ManualCanonical: false,
}
func init() {
@@ -155,6 +156,7 @@ type Config struct {
// CheckpointOracle is the configuration for checkpoint oracle.
CheckpointOracle *params.CheckpointOracleConfig `toml:",omitempty"`
+ ManualCanonical bool
}
func MyDefaultConfig() Config {
diff --git a/eth/enr_entry.go b/eth/enr_entry.go
deleted file mode 100644
index d50328c..0000000
--- a/eth/enr_entry.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2019 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library 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.
-//
-// The go-ethereum library 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 the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package eth
-
-import (
- "github.com/ava-labs/go-ethereum/core"
- "github.com/ava-labs/go-ethereum/core/forkid"
- "github.com/ava-labs/go-ethereum/p2p/enode"
- "github.com/ava-labs/go-ethereum/rlp"
-)
-
-// ethEntry is the "eth" ENR entry which advertises eth protocol
-// on the discovery network.
-type ethEntry struct {
- ForkID forkid.ID // Fork identifier per EIP-2124
-
- // Ignore additional fields (for forward compatibility).
- Rest []rlp.RawValue `rlp:"tail"`
-}
-
-// ENRKey implements enr.Entry.
-func (e ethEntry) ENRKey() string {
- return "eth"
-}
-
-func (eth *Ethereum) startEthEntryUpdate(ln *enode.LocalNode) {
- var newHead = make(chan core.ChainHeadEvent, 10)
- sub := eth.blockchain.SubscribeChainHeadEvent(newHead)
-
- go func() {
- defer sub.Unsubscribe()
- for {
- select {
- case <-newHead:
- ln.Set(eth.currentEthEntry())
- case <-sub.Err():
- // Would be nice to sync with eth.Stop, but there is no
- // good way to do that.
- return
- }
- }
- }()
-}
-
-func (eth *Ethereum) currentEthEntry() *ethEntry {
- return &ethEntry{ForkID: forkid.NewID(eth.blockchain)}
-}
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index fa3d985..b25792c 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -21,9 +21,9 @@ import (
"errors"
"math/big"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/rpc"
"github.com/ava-labs/go-ethereum/common"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/bloombits"
"github.com/ava-labs/go-ethereum/core/types"
"github.com/ava-labs/go-ethereum/ethdb"
diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go
index a27859f..f8ee038 100644
--- a/eth/filters/filter_system.go
+++ b/eth/filters/filter_system.go
@@ -25,10 +25,10 @@ import (
"sync"
"time"
+ "github.com/ava-labs/coreth/core"
myrpc "github.com/ava-labs/coreth/rpc"
ethereum "github.com/ava-labs/go-ethereum"
"github.com/ava-labs/go-ethereum/common"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/rawdb"
"github.com/ava-labs/go-ethereum/core/types"
"github.com/ava-labs/go-ethereum/event"
diff --git a/eth/gen_config.go b/eth/gen_config.go
index a254f5d..6b8ddf1 100644
--- a/eth/gen_config.go
+++ b/eth/gen_config.go
@@ -6,11 +6,11 @@ import (
"math/big"
"time"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth/gasprice"
"github.com/ava-labs/coreth/miner"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/consensus/ethash"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/eth/downloader"
"github.com/ava-labs/go-ethereum/params"
)
diff --git a/eth/handler.go b/eth/handler.go
index 3e47b20..f502973 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -26,9 +26,9 @@ import (
"sync/atomic"
"time"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/consensus"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/types"
"github.com/ava-labs/go-ethereum/eth/downloader"
"github.com/ava-labs/go-ethereum/eth/fetcher"
diff --git a/eth/protocol.go b/eth/protocol.go
index b60905f..07d2def 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -21,8 +21,8 @@ import (
"io"
"math/big"
+ "github.com/ava-labs/coreth/core"
"github.com/ava-labs/go-ethereum/common"
- "github.com/ava-labs/go-ethereum/core"
"github.com/ava-labs/go-ethereum/core/types"
"github.com/ava-labs/go-ethereum/event"
"github.com/ava-labs/go-ethereum/rlp"