diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go
index d15432936f..d928bff23b 100644
--- a/accounts/abi/bind/backends/simulated.go
+++ b/accounts/abi/bind/backends/simulated.go
@@ -117,7 +117,7 @@ func (b *SimulatedBackend) Commit() {
panic(err) // This cannot happen unless the simulator is wrong, fail in that case
}
stateDB, _ := b.blockchain.State()
- b.blockchain.WriteBlockWithState(b.pendingBlock, b.pendingReceipts, nil, stateDB, true)
+ b.blockchain.WriteBlockWithState(b.pendingBlock, b.pendingReceipts, nil, stateDB, true, nil)
b.rollback()
}
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 3d95f0a31b..767d71ce03 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -126,11 +126,11 @@ func monitorFreeDiskSpace(sigc chan os.Signal, path string, freeDiskSpaceCritica
break
}
if freeSpace < freeDiskSpaceCritical {
- log.Error("Low disk space. Gracefully shutting down Geth to prevent database corruption.", "available", common.StorageSize(freeSpace))
+ log.Error("Low disk space. Gracefully shutting down PlatON to prevent database corruption.", "available", common.StorageSize(freeSpace))
sigc <- syscall.SIGTERM
break
} else if freeSpace < 2*freeDiskSpaceCritical {
- log.Warn("Disk space is running low. Geth will shutdown if disk space runs below critical level.", "available", common.StorageSize(freeSpace), "critical_level", common.StorageSize(freeDiskSpaceCritical))
+ log.Warn("Disk space is running low. PlatON will shutdown if disk space runs below critical level.", "available", common.StorageSize(freeSpace), "critical_level", common.StorageSize(freeDiskSpaceCritical))
}
time.Sleep(60 * time.Second)
}
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index bcbc0e688e..d8a81ba536 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -1353,7 +1353,7 @@ func RegisterEthService(stack *node.Node, cfg *ethconfig.Config) ethapi.Backend
} else {
backend, err := eth.New(stack, cfg)
if err != nil {
- Fatalf("Failed to register the Ethereum service: %v", err)
+ Fatalf("Failed to register the PlatON service: %v", err)
}
stack.RegisterAPIs(tracers.APIs(backend.APIBackend))
return backend.APIBackend
diff --git a/common/vm/inner_contract.go b/common/vm/inner_contract.go
index baa5b609ee..f5f4787805 100644
--- a/common/vm/inner_contract.go
+++ b/common/vm/inner_contract.go
@@ -28,6 +28,7 @@ var (
DelegateRewardPoolAddr = common.HexToAddress("0x1000000000000000000000000000000000000006") // The PlatON Precompiled contract addr for delegate reward
ValidatorInnerContractAddr = common.HexToAddress("0x2000000000000000000000000000000000000000") // The PlatON Precompiled contract addr for cbft inner
VrfInnerContractAddr = common.HexToAddress("0x3000000000000000000000000000000000000001") // The PlatON Precompiled contract addr for vrf inner
+ BlsVerifyContractAddr = common.HexToAddress("0x3000000000000000000000000000000000000002") // The PlatON Precompiled contract addr for bls verify
)
type PrecompiledContractCheck interface {
diff --git a/consensus/bft_mock.go b/consensus/bft_mock.go
index 8452230855..1cdd3bd71c 100644
--- a/consensus/bft_mock.go
+++ b/consensus/bft_mock.go
@@ -165,7 +165,7 @@ func (bm *BftMock) Author(header *types.Header) (common.Address, error) {
// VerifyHeader checks whether a header conforms to the consensus rules of a
// given engine. Verifying the seal may be done optionally here, or explicitly
// via the VerifySeal method.
-func (bm *BftMock) VerifyHeader(chain ChainReader, header *types.Header, seal bool) error {
+func (bm *BftMock) VerifyHeader(chain ChainReader, header *types.Header, async bool) error {
if bm.fakeFail == header.Number.Uint64() {
return fmt.Errorf("failed verifyHeader on bftMock")
}
@@ -292,48 +292,11 @@ func (bm *BftMock) ShouldSeal(curTime time.Time) (bool, error) {
return true, nil
}
-// OnBlockSignature received a new block signature
-// Need to verify if the signature is signed by nodeID
-func (bm *BftMock) OnBlockSignature(chain ChainReader, nodeID enode.IDv0, sig *cbfttypes.BlockSignature) error {
- return nil
-}
-
-// OnNewBlock processes the BFT signatures
-func (bm *BftMock) OnNewBlock(chain ChainReader, block *types.Block) error {
- return nil
-}
-
-// OnPong processes the BFT signatures
-func (bm *BftMock) OnPong(nodeID enode.IDv0, netLatency int64) error {
- return nil
-
-}
-
-// OnBlockSynced sends a signal if a block synced from other peer.
-func (bm *BftMock) OnBlockSynced() {
-
-}
-
-// CheckConsensusNode is a fake interface, no need to implement.
-func (bm *BftMock) CheckConsensusNode(nodeID enode.IDv0) (bool, error) {
- return true, nil
-}
-
// IsConsensusNode is a fake interface, no need to implement.
func (bm *BftMock) IsConsensusNode() bool {
return true
}
-// HighestLogicalBlock is a fake interface, no need to implement.
-func (bm *BftMock) HighestLogicalBlock() *types.Block {
- return nil
-}
-
-// HighestConfirmedBlock is a fake interface, no need to implement.
-func (bm *BftMock) HighestConfirmedBlock() *types.Block {
- return nil
-}
-
// GetBlock is a fake interface, no need to implement.
func (bm *BftMock) GetBlock(hash common.Hash, number uint64) *types.Block {
return nil
@@ -364,32 +327,17 @@ func (bm *BftMock) GetBlockByHashAndNum(hash common.Hash, number uint64) *types.
return nil
}
-// Status is a fake interface, no need to implement.
-func (bm *BftMock) Status() string {
- return ""
-}
-
// CurrentBlock is a fake interface, no need to implement.
func (bm *BftMock) CurrentBlock() *types.Block {
- //if len(bm.Blocks) == 0 {
- // h := types.Header{Number: big.NewInt(0)}
- // return types.NewBlockWithHeader(&h)
- //}
- //return bm.Blocks[len(bm.Blocks)-1]
return bm.Current
}
// TracingSwitch is a fake interface, no need to implement.
-func (bm *BftMock) TracingSwitch(flag int8) {
-
-}
+func (bm *BftMock) TracingSwitch(flag int8) {}
-func (bm *BftMock) Pause() {
+func (bm *BftMock) Pause() {}
-}
-func (bm *BftMock) Resume() {
-
-}
+func (bm *BftMock) Resume() {}
func (bm *BftMock) Syncing() bool {
return false
diff --git a/consensus/cbft/cbft.go b/consensus/cbft/cbft.go
index cda997d89b..6e60c17662 100644
--- a/consensus/cbft/cbft.go
+++ b/consensus/cbft/cbft.go
@@ -325,7 +325,7 @@ func (cbft *Cbft) ReceiveMessage(msg *ctypes.MsgInfo) error {
cMsg := msg.Msg.(ctypes.ConsensusMsg)
if invalidMsg(cMsg.EpochNum(), cMsg.ViewNum()) {
- cbft.log.Debug("Invalid msg", "peer", msg.PeerID, "type", reflect.TypeOf(msg.Msg), "msg", msg.Msg.String())
+ cbft.log.Trace("Invalid msg", "peer", msg.PeerID, "type", reflect.TypeOf(msg.Msg), "msg", msg.Msg.String())
return nil
}
@@ -641,7 +641,7 @@ func (cbft *Cbft) Author(header *types.Header) (common.Address, error) {
return header.Coinbase, nil
}
-func (cbft *Cbft) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error {
+func (cbft *Cbft) VerifyHeader(chain consensus.ChainReader, header *types.Header, async bool) error {
// Short circuit if the header is known, or its parent not
number := header.Number.Uint64()
if chain.GetHeader(header.Hash(), number) != nil {
@@ -650,7 +650,12 @@ func (cbft *Cbft) VerifyHeader(chain consensus.ChainReader, header *types.Header
parent := chain.GetHeader(header.ParentHash, number-1)
if parent == nil {
- parentBlock := cbft.GetBlockWithoutLock(header.ParentHash, number-1)
+ var parentBlock *types.Block
+ if async {
+ parentBlock = cbft.GetBlockWithLock(header.ParentHash, number-1)
+ } else {
+ parentBlock = cbft.GetBlockWithoutLock(header.ParentHash, number-1)
+ }
if parentBlock != nil {
parent = parentBlock.Header()
}
@@ -738,7 +743,7 @@ func (cbft *Cbft) verifyHeaderWorker(chain consensus.ChainReader, headers []*typ
if index == 0 {
parent = chain.GetHeader(headers[0].ParentHash, headers[0].Number.Uint64()-1)
if parent == nil {
- parentBlock := cbft.GetBlockWithoutLock(headers[0].ParentHash, headers[0].Number.Uint64()-1)
+ parentBlock := cbft.GetBlockWithLock(headers[0].ParentHash, headers[0].Number.Uint64()-1)
if parentBlock != nil {
parent = parentBlock.Header()
}
@@ -1312,6 +1317,25 @@ func (cbft *Cbft) GetBlock(hash common.Hash, number uint64) *types.Block {
return <-result
}
+// GetBlockWithLock synchronously obtains blocks according to the specified number and hash.
+func (cbft *Cbft) GetBlockWithLock(hash common.Hash, number uint64) *types.Block {
+ result := make(chan *types.Block, 1)
+
+ cbft.asyncCallCh <- func() {
+ block, _ := cbft.blockTree.FindBlockAndQC(hash, number)
+ if block == nil {
+ if eb := cbft.state.FindBlock(hash, number); eb != nil {
+ block = eb
+ } else {
+ cbft.log.Debug("Get block failed", "hash", hash, "number", number)
+ }
+ }
+ result <- block
+ }
+
+ return <-result
+}
+
// GetBlockWithoutLock returns the block corresponding to the specified number and hash.
func (cbft *Cbft) GetBlockWithoutLock(hash common.Hash, number uint64) *types.Block {
block, _ := cbft.blockTree.FindBlockAndQC(hash, number)
diff --git a/consensus/cbft/sync_process.go b/consensus/cbft/sync_process.go
index 06bdd6ebcf..0ec3bfc23a 100644
--- a/consensus/cbft/sync_process.go
+++ b/consensus/cbft/sync_process.go
@@ -248,7 +248,7 @@ func (cbft *Cbft) prepareVoteFetchRules(id string, vote *protocols.PrepareVote)
func (cbft *Cbft) OnGetPrepareBlock(id string, msg *protocols.GetPrepareBlock) error {
if msg.Epoch == cbft.state.Epoch() && msg.ViewNumber == cbft.state.ViewNumber() {
prepareBlock := cbft.state.PrepareBlockByIndex(msg.BlockIndex)
- if prepareBlock != nil {
+ if prepareBlock != nil && prepareBlock.Signature.NotEmpty() {
cbft.log.Debug("Send PrepareBlock", "peer", id, "prepareBlock", prepareBlock.String())
cbft.network.Send(id, prepareBlock)
}
diff --git a/consensus/cbft/types/crypto.go b/consensus/cbft/types/crypto.go
index f655033043..56f54facb3 100644
--- a/consensus/cbft/types/crypto.go
+++ b/consensus/cbft/types/crypto.go
@@ -14,10 +14,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the PlatON-Go library. If not, see .
-
package types
import (
+ "bytes"
"fmt"
"reflect"
@@ -48,6 +48,11 @@ func (sig *Signature) Bytes() []byte {
return target
}
+func (sig *Signature) NotEmpty() bool {
+ var a Signature
+ return bytes.Compare(sig.Bytes(), a.Bytes()) != 0
+}
+
// MarshalText returns the hex representation of a.
func (sig Signature) MarshalText() ([]byte, error) {
return hexutil.Bytes(sig[:]).MarshalText()
diff --git a/consensus/cbft/types/crypto_test.go b/consensus/cbft/types/crypto_test.go
index 55a7e57ae4..19c124279d 100644
--- a/consensus/cbft/types/crypto_test.go
+++ b/consensus/cbft/types/crypto_test.go
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the PlatON-Go library. If not, see .
-
package types
import (
@@ -106,3 +105,12 @@ func Test_ViewChangeQC_MaxBlock(t *testing.T) {
epoch, viewNumber, blockEpoch, blockViewNumber, blockHash, blockNumber = viewChangeQC.MaxBlock()
assert.Equal(t, uint64(0), epoch)
}
+
+func Test_Signature_NotEmpty(t *testing.T) {
+ var sig Signature
+ assert.False(t, sig.NotEmpty())
+ sig = Signature{byte(0), byte(0), byte(0)}
+ assert.False(t, sig.NotEmpty())
+ sig = Signature{byte(0), byte(0), byte(1)}
+ assert.True(t, sig.NotEmpty())
+}
diff --git a/consensus/cbft/validator/validator.go b/consensus/cbft/validator/validator.go
index fdc6fa7b27..909ee05ecc 100644
--- a/consensus/cbft/validator/validator.go
+++ b/consensus/cbft/validator/validator.go
@@ -419,6 +419,12 @@ func (vp *ValidatorPool) Update(blockNumber uint64, epoch uint64, eventMux *even
isValidatorAfter := vp.isValidator(epoch, vp.nodeID)
+ nodes := make(map[enode.ID]struct{})
+ for _, validator := range vp.currentValidators.Nodes {
+ nodes[validator.NodeID] = struct{}{}
+ }
+ eventMux.Post(cbfttypes.UpdateValidatorEvent{Nodes: nodes})
+
if isValidatorBefore {
// If we are still a consensus node, that adding
// new validators as consensus peer, and removing
diff --git a/consensus/consensus.go b/consensus/consensus.go
index a3fba47c6f..eff698936a 100644
--- a/consensus/consensus.go
+++ b/consensus/consensus.go
@@ -81,7 +81,7 @@ type Engine interface {
// VerifyHeader checks whether a header conforms to the consensus rules of a
// given engine. Verifying the seal may be done optionally here, or explicitly
// via the VerifySeal method.
- VerifyHeader(chain ChainReader, header *types.Header, seal bool) error
+ VerifyHeader(chain ChainReader, header *types.Header, async bool) error
// VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers
// concurrently. The method returns a quit channel to abort the operations and
diff --git a/core/blockchain.go b/core/blockchain.go
index 0d9f736b1b..2f8f2cf999 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -325,30 +325,34 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
// Make sure the state associated with the block is available
head := bc.CurrentBlock()
if _, err := state.New(head.Root(), bc.stateCache, bc.snaps); err != nil {
- // Head state is missing, before the state recovery, find out the
- // disk layer point of snapshot(if it's enabled). Make sure the
- // rewound point is lower than disk layer.
- var diskRoot common.Hash
- if bc.cacheConfig.SnapshotLimit > 0 {
- diskRoot = rawdb.ReadSnapshotRoot(bc.db)
- }
- if diskRoot != (common.Hash{}) {
- log.Warn("Head state missing, repairing", "number", head.Number(), "hash", head.Hash(), "snaproot", diskRoot)
-
- snapDisk, err := bc.setHeadBeyondRoot(head.NumberU64(), diskRoot, true)
- if err != nil {
- return nil, err
+ log.Warn("Head state missing, repair not supported", "number", head.NumberU64(), "hash", head.Hash().String())
+ return nil, fmt.Errorf("head state missing, repair not supported, number:%d, hash:%s", head.NumberU64(), head.Hash().String())
+ /*
+ // Head state is missing, before the state recovery, find out the
+ // disk layer point of snapshot(if it's enabled). Make sure the
+ // rewound point is lower than disk layer.
+ var diskRoot common.Hash
+ if bc.cacheConfig.SnapshotLimit > 0 {
+ diskRoot = rawdb.ReadSnapshotRoot(bc.db)
}
- // Chain rewound, persist old snapshot number to indicate recovery procedure
- if snapDisk != 0 {
- rawdb.WriteSnapshotRecoveryNumber(bc.db, snapDisk)
- }
- } else {
- log.Warn("Head state missing, repairing", "number", head.Number(), "hash", head.Hash())
- if _, err := bc.setHeadBeyondRoot(head.NumberU64(), common.Hash{}, true); err != nil {
- return nil, err
+ if diskRoot != (common.Hash{}) {
+ log.Warn("Head state missing, repairing", "number", head.Number(), "hash", head.Hash(), "snaproot", diskRoot)
+
+ snapDisk, err := bc.setHeadBeyondRoot(head.NumberU64(), diskRoot, true)
+ if err != nil {
+ return nil, err
+ }
+ // Chain rewound, persist old snapshot number to indicate recovery procedure
+ if snapDisk != 0 {
+ rawdb.WriteSnapshotRecoveryNumber(bc.db, snapDisk)
+ }
+ } else {
+ log.Warn("Head state missing, repairing", "number", head.Number(), "hash", head.Hash())
+ if _, err := bc.setHeadBeyondRoot(head.NumberU64(), common.Hash{}, true); err != nil {
+ return nil, err
+ }
}
- }
+ */
}
// Ensure that a previous crash in SetHead doesn't leave extra ancients
@@ -399,10 +403,11 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
var recover bool
head := bc.CurrentBlock()
- if layer := rawdb.ReadSnapshotRecoveryNumber(bc.db); layer != nil && *layer > head.NumberU64() {
- log.Warn("Enabling snapshot recovery", "chainhead", head.NumberU64(), "diskbase", *layer)
- recover = true
- }
+ // Repair not supported
+ //if layer := rawdb.ReadSnapshotRecoveryNumber(bc.db); layer != nil && *layer > head.NumberU64() {
+ // log.Warn("Enabling snapshot recovery", "chainhead", head.NumberU64(), "diskbase", *layer)
+ // recover = true
+ //}
bc.snaps, _ = snapshot.New(bc.db, bc.stateCache.TrieDB(), bc.cacheConfig.SnapshotLimit, head.Root(), !bc.cacheConfig.SnapshotWait, true, recover)
}
@@ -1247,11 +1252,14 @@ func (bc *BlockChain) WriteBlockWithoutState(block *types.Block) (err error) {
}
// WriteBlockWithState writes the block and all associated state to the database.
-func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
+func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool, cbftBridgeUpdateChainState func()) (status WriteStatus, err error) {
if !bc.chainmu.TryLock() {
return NonStatTy, errInsertionInterrupted
}
defer bc.chainmu.Unlock()
+ if cbftBridgeUpdateChainState != nil {
+ cbftBridgeUpdateChainState()
+ }
return bc.writeBlockWithState(block, receipts, logs, state, emitHeadEvent)
}
@@ -1530,13 +1538,14 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
headers[i] = block.Header()
seals[i] = verifySeals
}
- abort, results := bc.engine.VerifyHeaders(bc, headers, seals)
- defer close(abort)
// Pause engine
bc.engine.Pause()
defer bc.engine.Resume()
+ abort, results := bc.engine.VerifyHeaders(bc, headers, seals)
+ defer close(abort)
+
// Peek the error for the first block to decide the directing import logic
it := newInsertIterator(chain, results, bc.Validator())
block, err := it.next()
@@ -1561,7 +1570,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
return it.index, err
}
// No validation errors for the first block (or chain prefix skipped)
- for ; block != nil && err == nil; block, err = it.next() {
+ for ; block != nil && (err == nil || errors.Is(err, ErrKnownBlock)); block, err = it.next() {
// If the chain is terminating, stop processing blocks
if bc.insertStopped() {
log.Debug("Abort during block processing")
diff --git a/core/blockchain_cache.go b/core/blockchain_cache.go
index a419df91cc..7c85953734 100644
--- a/core/blockchain_cache.go
+++ b/core/blockchain_cache.go
@@ -328,7 +328,7 @@ func (bcc *BlockChainCache) executeBlock(block *types.Block, parent *types.Block
t := time.Now()
//to execute
receipts, err := bcc.ProcessDirectly(block, state, parent)
- log.Debug("Execute block", "number", block.Number(), "hash", block.Hash(),
+ log.Debug("Execute block", "number", block.Number(), "hash", block.Hash(), "stateRoot", block.Root().String(),
"parentNumber", parent.Number(), "parentHash", parent.Hash(), "duration", time.Since(t), "makeState", elapse, "err", err)
if err == nil {
//save the receipts and state to consensusCache
@@ -370,7 +370,7 @@ func (bcc *BlockChainCache) WriteBlock(block *types.Block) error {
// Commit block and state to database.
//block.SetExtraData(extraData)
log.Debug("Write extra data", "txs", len(block.Transactions()), "extra", len(block.ExtraData()))
- _, err := bcc.WriteBlockWithState(block, _receipts, nil, state, true)
+ _, err := bcc.WriteBlockWithState(block, _receipts, nil, state, true, nil)
if err != nil {
log.Error("Failed writing block to chain", "hash", block.Hash(), "number", block.NumberU64(), "err", err)
return fmt.Errorf("failed writing block to chain, number:%d, hash:%s, err:%s", block.NumberU64(), block.Hash().String(), err.Error())
diff --git a/core/blockchain_reactor.go b/core/blockchain_reactor.go
index 4ea114ae28..88192b66ae 100644
--- a/core/blockchain_reactor.go
+++ b/core/blockchain_reactor.go
@@ -365,7 +365,7 @@ func (bcr *BlockChainReactor) EndBlocker(header *types.Header, state xcom.StateD
func (bcr *BlockChainReactor) VerifyTx(tx *types.Transaction, to common.Address, rules params.Rules) error {
- if !vm.IsPlatONPrecompiledContract(to, rules) {
+ if !vm.IsPlatONPrecompiledContract(to, rules, false) {
return nil
}
diff --git a/core/cbfttypes/type.go b/core/cbfttypes/type.go
index 0db6477a9e..fd50b15f39 100644
--- a/core/cbfttypes/type.go
+++ b/core/cbfttypes/type.go
@@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"math"
- "math/big"
"sort"
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
@@ -38,24 +37,6 @@ import (
"github.com/PlatONnetwork/PlatON-Go/crypto/bls"
)
-// Block's Signature info
-type BlockSignature struct {
- SignHash common.Hash // Signature hash,header[0:32]
- Hash common.Hash // Block hash,header[:]
- Number *big.Int
- Signature *common.BlockConfirmSign
-}
-
-func (bs *BlockSignature) Copy() *BlockSignature {
- sign := *bs.Signature
- return &BlockSignature{
- SignHash: bs.SignHash,
- Hash: bs.Hash,
- Number: new(big.Int).Set(bs.Number),
- Signature: &sign,
- }
-}
-
type UpdateChainStateFn func(qcState, lockState, commitState *protocols.State)
type CbftResult struct {
@@ -65,28 +46,6 @@ type CbftResult struct {
ChainStateUpdateCB func()
}
-type ProducerState struct {
- count int
- miner common.Address
-}
-
-func (ps *ProducerState) Add(miner common.Address) {
- if ps.miner == miner {
- ps.count++
- } else {
- ps.miner = miner
- ps.count = 1
- }
-}
-
-func (ps *ProducerState) Get() (common.Address, int) {
- return ps.miner, ps.count
-}
-
-func (ps *ProducerState) Validate(period int) bool {
- return ps.count < period
-}
-
type AddValidatorEvent struct {
Node *enode.Node
}
@@ -95,7 +54,9 @@ type RemoveValidatorEvent struct {
Node *enode.Node
}
-type UpdateValidatorEvent struct{}
+type UpdateValidatorEvent struct {
+ Nodes map[enode.ID]struct{}
+}
type ValidateNode struct {
Index uint32 `json:"index"`
diff --git a/core/chain_makers.go b/core/chain_makers.go
index 50aa1abab8..af0840d923 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -263,7 +263,7 @@ func GenerateBlockChain2(config *params.ChainConfig, parent *types.Block, engine
// Finalize and seal the block
block, _ := b.engine.Finalize(chainreader, b.header, statedb, b.txs, b.receipts)
- _, err := blockchain.WriteBlockWithState(block, b.receipts, nil, statedb, false)
+ _, err := blockchain.WriteBlockWithState(block, b.receipts, nil, statedb, false, nil)
if err != nil {
panic(err)
}
@@ -305,7 +305,7 @@ func GenerateBlockChain3(config *params.ChainConfig, parent *types.Block, engine
// Finalize and seal the block
block, _ := b.engine.Finalize(chainreader, b.header, statedb, b.txs, b.receipts)
- _, err := chain.WriteBlockWithState(block, b.receipts, nil, statedb, false)
+ _, err := chain.WriteBlockWithState(block, b.receipts, nil, statedb, false, nil)
if err != nil {
panic(err)
}
@@ -360,7 +360,7 @@ func GenerateBlockChain(config *params.ChainConfig, parent *types.Block, engine
// Finalize and seal the block
block, _ := b.engine.Finalize(chainreader, b.header, statedb, b.txs, b.receipts)
- _, err := blockchain.WriteBlockWithState(block, b.receipts, nil, statedb, false)
+ _, err := blockchain.WriteBlockWithState(block, b.receipts, nil, statedb, false, nil)
if err != nil {
panic(err)
}
diff --git a/core/events.go b/core/events.go
index 434675db8e..3f5738ead8 100644
--- a/core/events.go
+++ b/core/events.go
@@ -18,7 +18,6 @@ package core
import (
"github.com/PlatONnetwork/PlatON-Go/common"
- "github.com/PlatONnetwork/PlatON-Go/core/cbfttypes"
"github.com/PlatONnetwork/PlatON-Go/core/types"
)
@@ -28,15 +27,6 @@ type NewTxsEvent struct{ Txs []*types.Transaction }
// NewMinedBlockEvent is posted when a block has been imported.
type NewMinedBlockEvent struct{ Block *types.Block }
-type PrepareMinedBlockEvent struct {
- Block *types.Block
- // ConsensusNodes []discover.NodeID
-}
-type BlockSignatureEvent struct {
- BlockSignature *cbfttypes.BlockSignature
- // ConsensusNodes []discover.NodeID
-}
-
// RemovedLogsEvent is posted when a reorg happens
type RemovedLogsEvent struct{ Logs []*types.Log }
diff --git a/core/parallel_context.go b/core/parallel_context.go
index d699021166..80065a3f84 100644
--- a/core/parallel_context.go
+++ b/core/parallel_context.go
@@ -175,7 +175,7 @@ func (ctx *ParallelContext) buildTransferFailedResult(idx int, err error, needRe
tx := ctx.GetTx(idx)
log.Debug("Execute trasnfer failed", "blockNumber", ctx.header.Number.Uint64(), "txIdx", idx, "txHash", ctx.GetTx(idx).Hash().TerminalString(),
"gasPool", ctx.gp.Gas(), "txGasLimit", tx.Gas(), "txFrom", tx.FromAddr(ctx.signer).String(), "txTo", tx.To().String(),
- "txValue", tx.Value().Uint64(), "needRefundGasPool", needRefundGasPool, "error", err.Error())
+ "txValue", tx.Value(), "needRefundGasPool", needRefundGasPool, "error", err.Error())
}
func (ctx *ParallelContext) buildTransferSuccessResult(idx int, fromStateObject, toStateObject *state.ParallelStateObject, txGasUsed uint64, minerEarnings *big.Int) {
@@ -201,7 +201,7 @@ func (ctx *ParallelContext) buildTransferSuccessResult(idx int, fromStateObject,
ctx.SetResult(idx, result)
log.Trace("Execute trasnfer success", "blockNumber", ctx.header.Number.Uint64(), "txIdx", idx, "txHash", tx.Hash().TerminalString(),
"gasPool", ctx.gp.Gas(), "txGasLimit", tx.Gas(), "txUsedGas", txGasUsed, "txFrom", tx.FromAddr(ctx.signer).String(), "txTo", tx.To().String(),
- "txValue", tx.Value().Uint64(), "minerEarnings", minerEarnings.Uint64())
+ "txValue", tx.Value(), "minerEarnings", minerEarnings.Uint64())
}
func (ctx *ParallelContext) batchMerge(originIdxList []int) {
diff --git a/core/parallel_executor.go b/core/parallel_executor.go
index 7d68c58574..4ac8c3bc2e 100644
--- a/core/parallel_executor.go
+++ b/core/parallel_executor.go
@@ -158,7 +158,7 @@ func (exe *Executor) preCheck(msg types.Message, fromObj *state.ParallelStateObj
// check balance
mgval := new(big.Int).Mul(new(big.Int).SetUint64(msg.Gas()), msg.GasPrice())
balanceCheck := mgval
- if msg.GasFeeCap() != nil {
+ if gte150 {
balanceCheck = new(big.Int).SetUint64(msg.Gas())
balanceCheck = balanceCheck.Mul(balanceCheck, msg.GasFeeCap())
balanceCheck.Add(balanceCheck, msg.Value())
@@ -223,7 +223,7 @@ func (exe *Executor) executeParallelTx(ctx *ParallelContext, idx int, intrinsicG
minerEarnings := new(big.Int).Mul(new(big.Int).SetUint64(intrinsicGas), effectiveTip)
// sender fee
fee := new(big.Int).Mul(new(big.Int).SetUint64(intrinsicGas), msg.GasPrice())
- log.Trace("Execute parallel tx", "baseFee", ctx.header.BaseFee, "gasTipCap", msg.GasTipCap(), "gasFeeCap", msg.GasFeeCap(), "gasPrice", msg.GasPrice(), "effectiveTip", effectiveTip)
+ log.Trace("Execute parallel tx", "baseFee", ctx.header.BaseFee, "gasTipCap", msg.GasTipCap(), "gasFeeCap", msg.GasFeeCap(), "gasPrice", msg.GasPrice(), "effectiveTip", effectiveTip, "intrinsicGas", intrinsicGas)
cost := new(big.Int).Add(msg.Value(), fee)
if fromObj.GetBalance().Cmp(cost) < 0 {
ctx.buildTransferFailedResult(idx, errInsufficientBalanceForGas, true)
@@ -263,7 +263,7 @@ func (exe *Executor) executeContractTransaction(ctx *ParallelContext, idx int) {
ctx.AddPackedTx(tx)
ctx.GetState().IncreaseTxIdx()
ctx.AddReceipt(receipt)
- log.Debug("Execute contract transaction success", "blockNumber", ctx.GetHeader().Number.Uint64(), "txHash", tx.Hash().Hex(), "gasPool", ctx.gp.Gas(), "txGasLimit", tx.Gas(), "gasUsed", receipt.GasUsed)
+ log.Trace("Execute contract transaction success", "blockNumber", ctx.GetHeader().Number.Uint64(), "txHash", tx.Hash().Hex(), "gasPool", ctx.gp.Gas(), "txGasLimit", tx.Gas(), "gasUsed", receipt.GasUsed)
}
func (exe *Executor) isContract(tx *types.Transaction, state *state.StateDB, ctx *ParallelContext) bool {
diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go
index ad8b2a8bb5..9a7c438f71 100644
--- a/core/parallel_state_processor.go
+++ b/core/parallel_state_processor.go
@@ -65,7 +65,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
txHaveCal = txHaveCal + txs
tasks--
case <-timeout.C:
- log.Warn("Parallel cal tx from time out", "num", block.Number(), "left_task", tasks, "total_task", cap(block.CalTxFromCH), "txcal", txHaveCal)
+ log.Warn("Parallel cal tx from timeout", "num", block.Number(), "left_task", tasks, "total_task", cap(block.CalTxFromCH), "txcal", txHaveCal)
tasks = 0
}
}
diff --git a/core/tx_pool.go b/core/tx_pool.go
index 646dba23d5..527ad33cee 100644
--- a/core/tx_pool.go
+++ b/core/tx_pool.go
@@ -800,7 +800,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// Verify inner contract tx
if nil != tx.To() {
- if err := bcr.VerifyTx(tx, *(tx.To()), pool.chainconfig.Rules(pool.chainconfig.NewtonBlock)); nil != err {
+ if err := bcr.VerifyTx(tx, *(tx.To()), pool.chainconfig.Rules(pool.resetHead.Number())); nil != err {
log.Error("Failed to verify tx", "txHash", tx.Hash().Hex(), "to", tx.To().Hex(), "err", err)
return fmt.Errorf("%s: %s", ErrPlatONTxDataInvalid.Error(), err.Error())
}
diff --git a/core/types/block.go b/core/types/block.go
index 9d5df87f52..4662e174fd 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -41,7 +41,9 @@ import (
)
var (
- EmptyRootHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
+ EmptyRootHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
+ EmptyUncleHash = rlpHash([]*Header(nil))
+
// Extra field in the block header, maximum length
ExtraMaxSize = 97
HttpEthCompatible = false
diff --git a/core/vm/contracts.go b/core/vm/contracts.go
index ca14d38a1c..62dfe44433 100644
--- a/core/vm/contracts.go
+++ b/core/vm/contracts.go
@@ -21,6 +21,7 @@ import (
"encoding/binary"
"errors"
"fmt"
+ "github.com/PlatONnetwork/PlatON-Go/crypto/bls"
"math/big"
"github.com/PlatONnetwork/PlatON-Go/crypto/bls12381"
@@ -179,7 +180,7 @@ var PlatONPrecompiledContracts = map[common.Address]PrecompiledContract{
vm.DelegateRewardPoolAddr: &DelegateRewardContract{},
}
-var PlatONPrecompiledContracts120 = map[common.Address]PrecompiledContract{
+var PlatONPrecompiledContractsNewton = map[common.Address]PrecompiledContract{
vm.ValidatorInnerContractAddr: &validatorInnerContract{},
// add by economic model
vm.StakingContractAddr: &StakingContract{},
@@ -191,6 +192,19 @@ var PlatONPrecompiledContracts120 = map[common.Address]PrecompiledContract{
vm.VrfInnerContractAddr: &vrf{},
}
+var PlatONPrecompiledContractsPauli = map[common.Address]PrecompiledContract{
+ vm.ValidatorInnerContractAddr: &validatorInnerContract{},
+ // add by economic model
+ vm.StakingContractAddr: &StakingContract{},
+ vm.RestrictingContractAddr: &RestrictingContract{},
+ vm.SlashingContractAddr: &SlashingContract{},
+ vm.GovContractAddr: &GovContract{},
+ vm.RewardManagerPoolAddr: &rewardEmpty{},
+ vm.DelegateRewardPoolAddr: &DelegateRewardContract{},
+ vm.VrfInnerContractAddr: &vrf{},
+ vm.BlsVerifyContractAddr: &blsSignVerify{},
+}
+
// ActivePrecompiles returns the precompiles enabled with the current configuration.
func ActivePrecompiles(state xcom.StateDB) []common.Address {
if gov.Gte150VersionState(state) {
@@ -244,9 +258,14 @@ func IsEVMPrecompiledContract(addr common.Address, rules params.Rules, gte150Ver
return false
}
-func IsPlatONPrecompiledContract(addr common.Address, rules params.Rules) bool {
+func IsPlatONPrecompiledContract(addr common.Address, rules params.Rules, gte150Version bool) bool {
+ if rules.IsPauli || gte150Version {
+ if _, ok := PlatONPrecompiledContractsPauli[addr]; ok {
+ return true
+ }
+ }
if rules.IsNewton {
- if _, ok := PlatONPrecompiledContracts120[addr]; ok {
+ if _, ok := PlatONPrecompiledContractsNewton[addr]; ok {
return true
}
} else {
@@ -261,7 +280,7 @@ func IsPrecompiledContract(addr common.Address, rules params.Rules, gte150Versio
if IsEVMPrecompiledContract(addr, rules, gte150Version) {
return true
} else {
- return IsPlatONPrecompiledContract(addr, rules)
+ return IsPlatONPrecompiledContract(addr, rules, gte150Version)
}
}
@@ -1181,3 +1200,51 @@ func (v vrf) Run(input []byte) ([]byte, error) {
}
return randomNumbers, nil
}
+
+var (
+ errBlsSignVerifyInvalidInputLength = errors.New("invalid input length")
+ errBlsSignVerifyFailed = errors.New("bls sign verify failed")
+)
+
+type blsSignVerify struct {
+ Evm *EVM
+}
+
+func (b blsSignVerify) RequiredGas(input []byte) uint64 {
+ return params.BlsVerifyGas
+}
+
+// input由 签名+消息+n个bls公钥组成
+// 签名长度 64
+// 消息长度 32
+// bls公钥长度 96*n
+
+func (b blsSignVerify) Run(input []byte) ([]byte, error) {
+ if len(input) == 0 || len(input) == 96 || len(input)%96 != 0 {
+ return nil, errBlsSignVerifyInvalidInputLength
+ }
+
+ var (
+ sig bls.Sign
+ msg []byte
+ pubKey = new(bls.PublicKey)
+ )
+ if err := sig.Deserialize(getData(input, 0, 64)); err != nil {
+ return nil, err
+ }
+
+ for i := 1; i < len(input)/96; i++ {
+ pub := new(bls.PublicKey)
+ if err := pub.Deserialize(getData(input, uint64(96*i), 96)); err != nil {
+ return nil, err
+ }
+ pubKey.Add(pub)
+ }
+
+ msg = getData(input, 64, 32)
+
+ if !sig.Verify(pubKey, string(msg)) {
+ return nil, errBlsSignVerifyFailed
+ }
+ return nil, nil
+}
diff --git a/core/vm/evm.go b/core/vm/evm.go
index 028cd64815..fe6dfd52e4 100644
--- a/core/vm/evm.go
+++ b/core/vm/evm.go
@@ -67,12 +67,20 @@ func run(evm *EVM, contract *Contract, input []byte, readOnly bool) ([]byte, err
if p := precompiles[*contract.CodeAddr]; p != nil {
return RunPrecompiledContract(p, input, contract)
}
- if p := PlatONPrecompiledContracts120[*contract.CodeAddr]; p != nil {
+
+ platONPrecompiledContracts := PlatONPrecompiledContracts
+ if gov.Gte150VersionState(evm.StateDB) {
+ platONPrecompiledContracts = PlatONPrecompiledContractsPauli
+ } else if evm.chainRules.IsNewton {
+ platONPrecompiledContracts = PlatONPrecompiledContractsNewton
+ }
+
+ if p := platONPrecompiledContracts[*contract.CodeAddr]; p != nil {
switch p.(type) {
case *vrf:
- if evm.chainRules.IsNewton {
- return RunPrecompiledContract(&vrf{Evm: evm}, input, contract)
- }
+ return RunPrecompiledContract(&vrf{Evm: evm}, input, contract)
+ case *blsSignVerify:
+ return RunPrecompiledContract(&blsSignVerify{Evm: evm}, input, contract)
case *validatorInnerContract:
vic := &validatorInnerContract{
Contract: contract,
@@ -298,12 +306,13 @@ func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas
)
if !evm.StateDB.Exist(addr) {
precompiles := PrecompiledContractsByzantium
- if gov.Gte150VersionState(evm.StateDB) {
+ gte150 := gov.Gte150VersionState(evm.StateDB)
+ if gte150 {
precompiles = PrecompiledContractsBerlin2
} else if evm.chainRules.IsHubble {
precompiles = PrecompiledContractsBerlin
}
- if precompiles[addr] == nil && !IsPlatONPrecompiledContract(addr, evm.chainConfig.Rules(evm.Context.BlockNumber)) && value.Sign() == 0 {
+ if precompiles[addr] == nil && !IsPlatONPrecompiledContract(addr, evm.chainConfig.Rules(evm.Context.BlockNumber), gte150) && value.Sign() == 0 {
// Calling a non existing account, don't do anything, but ping the tracer
if evm.Config.Debug {
if evm.depth == 0 {
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index b4534377a3..784ac23c8e 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -40,8 +40,8 @@ const (
)
var (
- blockCacheMaxItems = 128 // Maximum number of blocks to cache before throttling the download
- blockCacheInitialItems = 128 // Initial number of blocks to start fetching, before we know the sizes of the blocks
+ blockCacheMaxItems = 1024 // Maximum number of blocks to cache before throttling the download
+ blockCacheInitialItems = 256 // Initial number of blocks to start fetching, before we know the sizes of the blocks
blockCacheMemory = 256 * 1024 * 1024 // Maximum amount of memory to use for block caching
blockCacheSizeWeight = 0.1 // Multiplier to approximate the average block size based on past ones
)
diff --git a/eth/fetcher/block_fetcher.go b/eth/fetcher/block_fetcher.go
index 2f3c7ec0f5..0e26017771 100644
--- a/eth/fetcher/block_fetcher.go
+++ b/eth/fetcher/block_fetcher.go
@@ -369,10 +369,12 @@ func (f *BlockFetcher) loop() {
break
}
// If we have a valid block number, check that it's potentially useful
- if dist := int64(notification.number) - int64(f.chainHeight()); dist <= minQueueDist || dist > maxQueueDist {
- log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
- blockAnnounceDropMeter.Mark(1)
- break
+ if notification.number > 0 {
+ if dist := int64(notification.number) - int64(f.chainHeight()); dist <= minQueueDist || dist > maxQueueDist {
+ log.Debug("Peer discarded announcement", "peer", notification.origin, "number", notification.number, "hash", notification.hash, "distance", dist)
+ blockAnnounceDropMeter.Mark(1)
+ break
+ }
}
// All is well, schedule the announce if block's not yet downloading
if _, ok := f.fetching[notification.hash]; ok {
diff --git a/eth/handler.go b/eth/handler.go
index 714adb211e..2732333dec 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -194,7 +194,7 @@ func newHandler(config *handlerConfig) (*handler, error) {
return h.chain.Engine().VerifyHeader(h.chain, header, true)
}
heighter := func() uint64 {
- return h.chain.CurrentBlock().NumberU64()
+ return h.chain.Engine().CurrentBlock().NumberU64() + 1
}
inserter := func(blocks types.Blocks) (int, error) {
// If fast sync is running, deny importing weird blocks. This is a problematic
diff --git a/eth/handler_eth.go b/eth/handler_eth.go
index f48a67ff95..41c8bb7c6c 100644
--- a/eth/handler_eth.go
+++ b/eth/handler_eth.go
@@ -19,6 +19,7 @@ package eth
import (
"errors"
"fmt"
+ "math/big"
"sync/atomic"
"time"
@@ -194,7 +195,7 @@ func (h *ethHandler) handleBlockAnnounces(peer *eth.Peer, hashes []common.Hash,
unknownNumbers = make([]uint64, 0, len(numbers))
)
for i := 0; i < len(hashes); i++ {
- if !h.chain.HasBlock(hashes[i], numbers[i]) {
+ if !h.chain.HasBlock(hashes[i], numbers[i]) && !h.engine.HasBlock(hashes[i], numbers[i]) {
unknownHashes = append(unknownHashes, hashes[i])
unknownNumbers = append(unknownNumbers, numbers[i])
}
@@ -208,6 +209,10 @@ func (h *ethHandler) handleBlockAnnounces(peer *eth.Peer, hashes []common.Hash,
// handleBlockBroadcast is invoked from a peer's message handler when it transmits a
// block broadcast for the local node to process.
func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, block *types.Block) error {
+ if h.engine.HasBlock(block.Hash(), block.NumberU64()) {
+ return nil
+ }
+
// Schedule the block for import
h.blockFetcher.Enqueue(peer.ID(), block)
@@ -215,7 +220,7 @@ func (h *ethHandler) handleBlockBroadcast(peer *eth.Peer, block *types.Block) er
// calculate the head hash and TD that the peer truly must have.
var (
trueHead = block.ParentHash()
- trueBN = block.Number()
+ trueBN = new(big.Int).Sub(block.Number(), big.NewInt(1))
)
// Update the peer's total difficulty if better than the previous
if _, bn := peer.Head(); trueBN.Cmp(bn) > 0 {
diff --git a/eth/handler_test.go b/eth/handler_test.go
index 4f2eeecc0c..f5f353696e 100644
--- a/eth/handler_test.go
+++ b/eth/handler_test.go
@@ -182,7 +182,15 @@ func newTestHandlerWithBlocks2(blocks int) *testHandler {
Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(1000000)}},
})
parent := genesis.MustCommit(db)
- chain := core.GenerateBlockChain2(params.TestChainConfig, parent, consensus.NewFakerWithDataBase(db), db, blocks, nil)
+
+ errCh := make(chan error, 1)
+
+ engine := consensus.NewFakerWithDataBase(db)
+
+ errCh <- engine.InsertChain(parent)
+ <-errCh
+
+ chain := core.GenerateBlockChain2(params.TestChainConfig, parent, engine, db, blocks, nil)
txpool := newTestTxPool()
handler, _ := newHandler(&handlerConfig{
@@ -207,4 +215,5 @@ func newTestHandlerWithBlocks2(blocks int) *testHandler {
func (b *testHandler) close() {
b.handler.Stop()
b.chain.Stop()
+ b.db.Close()
}
diff --git a/eth/sync_test.go b/eth/sync_test.go
index eec4a8a67d..cd936ee6c4 100644
--- a/eth/sync_test.go
+++ b/eth/sync_test.go
@@ -38,7 +38,7 @@ func testFastSyncDisabling(t *testing.T, protocol uint) {
t.Parallel()
// Create an empty handler and ensure it's in fast sync mode
- empty := newTestHandler2()
+ empty := newTestHandler()
if atomic.LoadUint32(&empty.handler.fastSync) == 0 {
t.Fatalf("fast sync disabled on pristine blockchain")
}
diff --git a/go.mod b/go.mod
index fe7ab89ada..ea1e1258f3 100644
--- a/go.mod
+++ b/go.mod
@@ -5,8 +5,7 @@ go 1.17
require (
github.com/AlayaNetwork/graphql-go v1.2.1-0.20211227063951-8d66eefcb4e3
github.com/PlatONnetwork/wagon v0.6.1-0.20201026015350-67507c2a7b96
- github.com/VictoriaMetrics/fastcache v1.6.0
- github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c
+ github.com/VictoriaMetrics/fastcache v1.5.7
github.com/btcsuite/btcd/btcutil v1.1.0
github.com/cespare/cp v0.1.0
github.com/davecgh/go-spew v1.1.1
@@ -29,11 +28,9 @@ require (
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/holiman/bloomfilter/v2 v2.0.3
github.com/holiman/uint256 v1.2.0
- github.com/huin/goupnp v1.0.2
- github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883
- github.com/influxdata/influxdb-client-go/v2 v2.4.0
- github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
- github.com/jackpal/go-nat-pmp v1.0.2
+ github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88
+ github.com/influxdata/influxdb v1.7.6
+ github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b
github.com/julienschmidt/httprouter v1.3.0
github.com/karalabe/hid v0.0.0-20170821103837-f00545f9f374
@@ -51,25 +48,29 @@ require (
github.com/rs/cors v1.7.0
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4
- github.com/stretchr/testify v1.7.0
+ github.com/stretchr/testify v1.8.0
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tealeg/xlsx v1.0.5
- golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
- golang.org/x/net v0.9.0
+ golang.org/x/crypto v0.14.0
golang.org/x/sync v0.1.0
- golang.org/x/sys v0.7.0
- golang.org/x/text v0.9.0
+ golang.org/x/sys v0.13.0
+ golang.org/x/text v0.13.0
golang.org/x/time v0.3.0
golang.org/x/tools v0.8.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6
gopkg.in/urfave/cli.v1 v1.20.0
- gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools v2.2.0+incompatible
gotest.tools/v3 v3.4.0 // indirect
)
+require (
+ github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c
+ github.com/herumi/bls v1.37.0
+ github.com/influxdata/influxdb-client-go/v2 v2.12.3
+ golang.org/x/net v0.17.0
+)
require (
github.com/AlayaNetwork/Alaya-Go v0.16.2 // indirect
@@ -81,6 +82,7 @@ require (
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/go-cmp v0.5.9 // indirect
+ github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
diff --git a/go.sum b/go.sum
index d39b727945..a6e308a2f6 100644
--- a/go.sum
+++ b/go.sum
@@ -9,9 +9,8 @@ github.com/PlatONnetwork/wagon v0.6.1-0.20201026015350-67507c2a7b96 h1:BA5xEQQrv
github.com/PlatONnetwork/wagon v0.6.1-0.20201026015350-67507c2a7b96/go.mod h1:zPWloKR2Ep7uqrhyLyE483NCxlAlQnbPsQUJXWN6bVM=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
+github.com/VictoriaMetrics/fastcache v1.5.7 h1:4y6y0G8PRzszQUYIQHHssv/jgPHAb5qQuuDNdCbyAgw=
github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8=
-github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
-github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@@ -48,14 +47,12 @@ github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ=
github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
-github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2 h1:SegyeYGcdi0jLLrpbCMoJxnUUn8GBXHsvr4rbzjuhfU=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
@@ -83,7 +80,6 @@ github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWo
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
-github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs=
@@ -115,7 +111,6 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
-github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y=
@@ -143,25 +138,22 @@ github.com/herumi/bls v1.37.0 h1:EKPaFujxWsxSMlfN1NeR9GTfVOeAsAaNRGbdBfn9lBE=
github.com/herumi/bls v1.37.0/go.mod h1:CnmR5QZ/QBnBE8Z55O+OtmUc6ICUdrOW9fwSRQwz5Bo=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
+github.com/holiman/uint256 v1.1.1 h1:4JywC80b+/hSfljFlEBLHrrh+CIONLDz9NuFl0af4Mw=
github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
-github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=
-github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag=
-github.com/huin/goupnp v1.0.2 h1:RfGLP+h3mvisuWEyybxNq5Eft3NWhHLPeUN72kpKZoI=
-github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSamkM=
+github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88 h1:bcAj8KroPf552TScjFPIakjH2/tdIrIH8F+cc4v4SRo=
+github.com/huin/goupnp v1.0.1-0.20210310174557-0ca763054c88/go.mod h1:nNs7wvRfN1eKaMknBydLNQU6146XQim8t4h+q90biWo=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
-github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883 h1:FSeK4fZCo8u40n2JMnyAsd6x7+SbvoOMHvQOU/n10P4=
github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY=
-github.com/influxdata/influxdb-client-go/v2 v2.4.0 h1:HGBfZYStlx3Kqvsv1h2pJixbCl/jhnFtxpKFAv9Tu5k=
-github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8=
+github.com/influxdata/influxdb v1.7.6 h1:8mQ7A/V+3noMGCt/P9pD09ISaiz9XvgCk303UYA3gcs=
+github.com/influxdata/influxdb v1.7.6/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY=
+github.com/influxdata/influxdb-client-go/v2 v2.12.3 h1:28nRlNMRIV4QbtIUvxhWqaxn0IpXeMSkY/uJa/O/vC4=
+github.com/influxdata/influxdb-client-go/v2 v2.12.3/go.mod h1:IrrLUbCjjfkmRuaCiGQg4m2GbkaeJDcuWoxiWdQEbA0=
+github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 h1:W9WBk7wlPfJLvMCdtV4zPulc4uCPrlywQOmbFOhgQNU=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
-github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 h1:vilfsDSy7TDxedi9gyBkMvAirat/oRcL0lFdJBf6tdM=
-github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 h1:6OvNmYgJyexcZ3pYbTI9jWx5tHo1Dee/tWbLMfPe2TA=
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
-github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
-github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b h1:ZGiXF8sz7PDk6RgkP+A/SFfUD0ZR/AgG6SpRNEDKZy8=
github.com/jedisct1/go-minisign v0.0.0-20211028175153-1c139d1cc84b/go.mod h1:hQmNrgofl+IY/8L+n20H6E6PWBBTokdsv+q49j0QhsU=
github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
@@ -289,12 +281,15 @@ github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
@@ -319,8 +314,9 @@ golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
-golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
+golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
+golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
@@ -328,6 +324,7 @@ golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -340,8 +337,11 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
-golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
+golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
+golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
+golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
+golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -375,7 +375,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -384,13 +383,17 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
+golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
+golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
+golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20171227012246-e19ae1496984/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
@@ -399,8 +402,9 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
+golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 9d38bdc100..2ab6e45a3c 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -1159,7 +1159,7 @@ func RPCMarshalHeader(head *types.Header, ethCompatible bool) map[string]interfa
result["mixHash"] = common.ZeroHash
result["nonce"] = hexutil.Bytes(head.Nonce[0:8])
result["timestamp"] = hexutil.Uint64(head.Time / 1000)
- result["sha3Uncles"] = common.ZeroHash
+ result["sha3Uncles"] = types.EmptyUncleHash
result["difficulty"] = (*hexutil.Big)(head.Number)
}
diff --git a/miner/worker.go b/miner/worker.go
index 0b3ab72de1..4ca1ab5f4a 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -438,9 +438,6 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timestamp time.Time // timestamp for each round of mining.
)
- vdEvent := w.mux.Subscribe(cbfttypes.UpdateValidatorEvent{})
- defer vdEvent.Unsubscribe()
-
timer := time.NewTimer(0)
defer timer.Stop()
<-timer.C // discard the initial tick
@@ -695,7 +692,7 @@ func (w *worker) taskLoop() {
w.blockChainCache.WriteReceipts(sealHash, task.receipts, task.block.NumberU64())
w.blockChainCache.AddSealBlock(sealHash, task.block.NumberU64())
task.state.UpdateSnaps()
- log.Debug("Add seal block to blockchain cache", "sealHash", sealHash, "number", task.block.NumberU64())
+ log.Debug("Add seal block to blockchain cache", "sealHash", sealHash, "number", task.block.NumberU64(), "stateRoot", task.block.Root().String())
if err := cbftEngine.Seal(w.chain, task.block, w.prepareResultCh, stopCh, w.prepareCompleteCh); err != nil {
log.Warn("Block sealing failed on bft engine", "err", err)
w.commitWorkEnv.setCommitStatusIdle()
@@ -758,7 +755,6 @@ func (w *worker) resultLoop() {
log.Debug("Pending task", "exist", exist)
var _receipts []*types.Receipt
var _state *state.StateDB
- //todo remove extra magic number
if exist && w.engine.(consensus.Bft).IsSignedBySelf(sealhash, block.Header()) {
_receipts = task.receipts
_state = task.state
@@ -809,8 +805,7 @@ func (w *worker) resultLoop() {
block.SetExtraData(cbftResult.ExtraData)
log.Debug("Write extra data", "txs", len(block.Transactions()), "extra", len(block.ExtraData()))
// update 3-chain state
- cbftResult.ChainStateUpdateCB()
- _, err := w.chain.WriteBlockWithState(block, receipts, logs, _state, true)
+ _, err := w.chain.WriteBlockWithState(block, receipts, logs, _state, true, cbftResult.ChainStateUpdateCB)
if err != nil {
if cbftResult.SyncState != nil {
cbftResult.SyncState <- err
diff --git a/miner/worker_test.go b/miner/worker_test.go
index 907e3df3df..659680b496 100644
--- a/miner/worker_test.go
+++ b/miner/worker_test.go
@@ -196,7 +196,7 @@ func newTestWorker(t *testing.T, chainConfig *params.ChainConfig, miningConfig *
}
// block write to real chain
- _, err = w.chain.WriteBlockWithState(cbftResult.Block, nil, nil, stateDB, false)
+ _, err = w.chain.WriteBlockWithState(cbftResult.Block, nil, nil, stateDB, false, nil)
if nil != err {
panic(err)
}
diff --git a/p2p/consensus_dialed.go b/p2p/consensus_dialed.go
index 1351b8d23d..459a87882f 100644
--- a/p2p/consensus_dialed.go
+++ b/p2p/consensus_dialed.go
@@ -52,12 +52,12 @@ func (tasks *dialedTasks) AddTask(task *dialTask) error {
return nil
}
-func (tasks *dialedTasks) RemoveTask(NodeID *enode.Node) error {
+func (tasks *dialedTasks) RemoveTask(NodeID enode.ID) error {
log.Info("[before remove]Consensus dialed task list before RemoveTask operation", "task queue", tasks.description())
if !tasks.isEmpty() {
for i, t := range tasks.queue {
- if t.dest.ID() == NodeID.ID() {
+ if t.dest.ID() == NodeID {
tasks.queue = append(tasks.queue[:i], tasks.queue[i+1:]...)
break
}
diff --git a/p2p/dial.go b/p2p/dial.go
index ba194d48f6..5ee758b51f 100644
--- a/p2p/dial.go
+++ b/p2p/dial.go
@@ -122,7 +122,9 @@ type dialScheduler struct {
static map[enode.ID]*dialTask
staticPool []*dialTask
- consensus *dialedTasks
+ consensusPeers int
+ updateConsensusPeersCh chan int
+ consensusPool *dialedTasks
// The dial history keeps recently dialed nodes. Members of history are not dialed.
history expHeap
@@ -170,20 +172,21 @@ func (cfg dialConfig) withDefaults() dialConfig {
func newDialScheduler(config dialConfig, it enode.Iterator, setupFunc dialSetupFunc) *dialScheduler {
d := &dialScheduler{
- dialConfig: config.withDefaults(),
- setupFunc: setupFunc,
- dialing: make(map[enode.ID]*dialTask),
- static: make(map[enode.ID]*dialTask),
- peers: make(map[enode.ID]struct{}),
- doneCh: make(chan *dialTask),
- nodesIn: make(chan *enode.Node),
- addStaticCh: make(chan *enode.Node),
- remStaticCh: make(chan *enode.Node),
- addPeerCh: make(chan *conn),
- remPeerCh: make(chan *conn),
- addconsensus: make(chan *enode.Node),
- removeconsensus: make(chan *enode.Node),
- consensus: NewDialedTasks(config.MaxConsensusPeers*2, nil),
+ dialConfig: config.withDefaults(),
+ setupFunc: setupFunc,
+ dialing: make(map[enode.ID]*dialTask),
+ static: make(map[enode.ID]*dialTask),
+ peers: make(map[enode.ID]struct{}),
+ doneCh: make(chan *dialTask),
+ nodesIn: make(chan *enode.Node),
+ addStaticCh: make(chan *enode.Node),
+ remStaticCh: make(chan *enode.Node),
+ addPeerCh: make(chan *conn),
+ remPeerCh: make(chan *conn),
+ addconsensus: make(chan *enode.Node),
+ removeconsensus: make(chan *enode.Node),
+ updateConsensusPeersCh: make(chan int),
+ consensusPool: NewDialedTasks(config.MaxConsensusPeers*2, nil),
}
d.lastStatsLog = d.clock.Now()
d.ctx, d.cancel = context.WithCancel(context.Background())
@@ -215,6 +218,13 @@ func (d *dialScheduler) removeStatic(n *enode.Node) {
}
}
+func (d *dialScheduler) updateConsensusNun(n int) {
+ select {
+ case d.updateConsensusPeersCh <- n:
+ case <-d.ctx.Done():
+ }
+}
+
func (d *dialScheduler) addConsensus(n *enode.Node) {
select {
case d.addconsensus <- n:
@@ -234,7 +244,7 @@ func (d *dialScheduler) removeConsensusFromQueue(n *enode.Node) {
}
func (d *dialScheduler) initRemoveConsensusPeerFn(removeConsensusPeerFn removeConsensusPeerFn) {
- d.consensus.InitRemoveConsensusPeerFn(removeConsensusPeerFn)
+ d.consensusPool.InitRemoveConsensusPeerFn(removeConsensusPeerFn)
}
// peerAdded updates the peer set.
@@ -264,8 +274,8 @@ loop:
for {
// Launch new dials if slots are available.
slots := d.freeDialSlots()
- slots -= d.startConsensusDials(slots)
slots -= d.startStaticDials(slots)
+ slots -= d.startConsensusDials(slots)
if slots > 0 {
nodesCh = d.nodesIn
} else {
@@ -289,7 +299,7 @@ loop:
d.doneSinceLastLog++
case c := <-d.addPeerCh:
- if c.is(dynDialedConn) || c.is(staticDialedConn) || c.is(consensusDialedConn) {
+ if c.is(dynDialedConn) || c.is(staticDialedConn) {
d.dialPeers++
}
id := c.node.ID()
@@ -302,7 +312,7 @@ loop:
// TODO: cancel dials to connected peers
case c := <-d.remPeerCh:
- if c.is(dynDialedConn) || c.is(staticDialedConn) || c.is(consensusDialedConn) {
+ if c.is(dynDialedConn) || c.is(staticDialedConn) {
d.dialPeers--
}
delete(d.peers, c.node.ID())
@@ -333,10 +343,12 @@ loop:
}
case node := <-d.addconsensus:
log.Warn("dial adding consensus node", "node", node)
- d.consensus.AddTask(&dialTask{flags: consensusDialedConn, dest: node})
+ d.consensusPool.AddTask(newDialTask(node, dynDialedConn|consensusDialedConn))
case node := <-d.removeconsensus:
- d.consensus.RemoveTask(node)
-
+ d.consensusPool.RemoveTask(node.ID())
+ case num := <-d.updateConsensusPeersCh:
+ d.log.Debug("update added consensus peers num", "num", num)
+ d.consensusPeers = num
case <-historyExp:
d.expireHistory()
@@ -461,22 +473,33 @@ func (d *dialScheduler) startStaticDials(n int) (started int) {
}
func (d *dialScheduler) startConsensusDials(n int) (started int) {
+ if len(d.consensusPool.ListTask()) == 0 {
+ return
+ }
+
+ // 如果没有多余得slot,但是共识连接数量不够,那么每次额外拿出最多3个slot来执行,使得旧的连接可以被踢掉
+ if n <= 0 && d.MaxConsensusPeers > d.consensusPeers {
+ n = d.MaxConsensusPeers - d.consensusPeers
+ if n > 3 {
+ n = 3
+ }
+ }
+
// Create dials for consensus nodes if they are not connected.
- i := 0
- for _, t := range d.consensus.ListTask() {
- if i >= n {
+ for _, t := range d.consensusPool.ListTask() {
+ if started >= n {
break
}
err := d.checkDial(t.dest)
switch err {
case errNetRestrict, errSelf:
- d.consensus.RemoveTask(t.dest)
+ d.consensusPool.RemoveTask(t.dest.ID())
case nil:
d.startDial(t)
- i++
+ started++
}
}
- return i
+ return started
}
// updateStaticPool attempts to move the given static dial back into staticPool.
diff --git a/p2p/discover/v4_udp.go b/p2p/discover/v4_udp.go
index f3b762500e..49d3841737 100644
--- a/p2p/discover/v4_udp.go
+++ b/p2p/discover/v4_udp.go
@@ -161,7 +161,6 @@ func ListenV4(c UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv4, error) {
if cfg.ChainID != nil {
bytes_ChainId, _ := rlp.EncodeToBytes(cfg.ChainID)
- cRest = []rlp.RawValue{bytes_ChainId, bytes_ChainId}
log.Info("UDP set chain ID", "chainId", cfg.ChainID, "bytes_ChainId", bytes_ChainId)
}
if cfg.PIP7ChainID != nil {
@@ -364,6 +363,7 @@ func (t *UDPv4) RequestENR(n *enode.Node) (*enode.Node, error) {
req := &v4wire.ENRRequest{
Expiration: uint64(time.Now().Add(expiration).Unix()),
+ Rest: cRestPIP7,
}
packet, hash, err := v4wire.Encode(t.priv, req)
if err != nil {
@@ -572,7 +572,7 @@ func (t *UDPv4) handlePacket(from *net.UDPAddr, buf []byte) error {
packet := t.wrapPacket(rawpacket)
fromID := fromKey.ID()
if err == nil && packet.preverify != nil {
- if !reflect.DeepEqual(rawpacket.Fork(), cRest) && !reflect.DeepEqual(rawpacket.Fork(), cRestPIP7) {
+ if !reflect.DeepEqual(rawpacket.Fork(), cRestPIP7) {
return errData
}
err = packet.preverify(packet, from, fromID, fromKey)
@@ -798,9 +798,12 @@ func (t *UDPv4) verifyENRRequest(h *packetHandlerV4, from *net.UDPAddr, fromID e
}
func (t *UDPv4) handleENRRequest(h *packetHandlerV4, from *net.UDPAddr, fromID enode.ID, mac []byte) {
+ req := h.Packet.(*v4wire.ENRRequest)
+
t.send(from, fromID, &v4wire.ENRResponse{
ReplyTok: mac,
Record: *t.localNode.Node().Record(),
+ Rest: req.Rest,
})
}
diff --git a/p2p/discover/v4wire/v4wire.go b/p2p/discover/v4wire/v4wire.go
index 4bbf7614be..4889eae5f7 100644
--- a/p2p/discover/v4wire/v4wire.go
+++ b/p2p/discover/v4wire/v4wire.go
@@ -23,7 +23,6 @@ import (
"crypto/elliptic"
"errors"
"fmt"
- "io"
"math/big"
"net"
"time"
@@ -195,16 +194,6 @@ func (req *Ping) Fork() []rlp.RawValue {
return req.ForkID
}
-func (req *Ping) EncodeRLP(w io.Writer) error {
- return rlp.Encode(w, PingV1{
- Version: req.Version,
- From: req.From,
- To: req.To,
- Expiration: req.Expiration,
- Rest: req.ForkID,
- })
-}
-
func (req *Ping) DecodeRLP(s *rlp.Stream) error {
// Retrieve the entire receipt blob as we need to try multiple decoders
blob, err := s.Raw()
@@ -259,15 +248,6 @@ func (req *Pong) Fork() []rlp.RawValue {
return req.ForkID
}
-func (req *Pong) EncodeRLP(w io.Writer) error {
- return rlp.Encode(w, PongV1{
- To: req.To,
- ReplyTok: req.ReplyTok,
- Expiration: req.Expiration,
- Rest: req.ForkID,
- })
-}
-
func (req *Pong) DecodeRLP(s *rlp.Stream) error {
// Retrieve the entire receipt blob as we need to try multiple decoders
blob, err := s.Raw()
diff --git a/p2p/server.go b/p2p/server.go
index 241b00ef37..b140895696 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -381,33 +381,17 @@ func (srv *Server) RemovePeer(node *enode.Node) {
// server is shut down. If the connection fails for any reason, the server will
// attempt to reconnect the peer.
func (srv *Server) AddConsensusPeer(node *enode.Node) {
- srv.dialsched.addConsensus(node)
+ select {
+ case srv.addconsensus <- node:
+ case <-srv.quit:
+ }
}
// RemoveConsensusPeer disconnects from the given consensus node
func (srv *Server) RemoveConsensusPeer(node *enode.Node) {
- var (
- ch chan *PeerEvent
- sub event.Subscription
- )
- // Disconnect the peer on the main loop.
- srv.doPeerOp(func(peers map[enode.ID]*Peer) {
- srv.dialsched.removeConsensus(node)
- if peer := peers[node.ID()]; peer != nil {
- ch = make(chan *PeerEvent, 1)
- sub = srv.peerFeed.Subscribe(ch)
- peer.Disconnect(DiscRequested)
- }
- })
- srv.log.Trace("Removing consensus node from dialstate", "node", node)
- // Wait for the peer connection to end.
- if ch != nil {
- defer sub.Unsubscribe()
- for ev := range ch {
- if ev.Peer == node.ID() && ev.Type == PeerEventTypeDrop {
- return
- }
- }
+ select {
+ case srv.removeconsensus <- node:
+ case <-srv.quit:
}
}
@@ -527,6 +511,8 @@ func (srv *Server) Start() (err error) {
srv.removetrusted = make(chan *enode.Node)
srv.peerOp = make(chan peerOpFunc)
srv.peerOpDone = make(chan struct{})
+ srv.addconsensus = make(chan *enode.Node)
+ srv.removeconsensus = make(chan *enode.Node)
if err := srv.setupLocalNode(); err != nil {
return err
@@ -794,7 +780,7 @@ running:
// to the consensus node set.
srv.log.Trace("Adding consensus node", "node", n)
id := n.ID()
- if bytes.Equal(crypto.Keccak256(srv.ourHandshake.ID), id[:]) {
+ if srv.localnode.ID() == id {
srv.log.Debug("We are become an consensus node")
srv.consensus = true
} else {
@@ -802,15 +788,16 @@ running:
}
consensusNodes[id] = true
if p, ok := peers[id]; ok {
- srv.log.Debug("Add consensus flag", "peer", id)
p.rw.set(consensusDialedConn, true)
+ srv.dialsched.updateConsensusNun(srv.numConsensusPeer(peers))
+ srv.log.Debug("Add consensus flag", "peer", id, "flag", p.rw.flags)
}
case n := <-srv.removeconsensus:
// This channel is used by RemoveConsensusNode to remove an enode
// from the consensus node set.
srv.log.Trace("Removing consensus node", "node", n)
id := n.ID()
- if bytes.Equal(crypto.Keccak256(srv.ourHandshake.ID), id[:]) {
+ if srv.localnode.ID() == id {
srv.log.Debug("We are not an consensus node")
srv.consensus = false
}
@@ -820,10 +807,8 @@ running:
}
if p, ok := peers[n.ID()]; ok {
p.rw.set(consensusDialedConn, false)
- if !p.rw.is(staticDialedConn | trustedConn | inboundConn) {
- p.rw.set(dynDialedConn, true)
- }
- srv.log.Debug("Remove consensus flag", "peer", n.ID(), "consensus", srv.consensus)
+ srv.dialsched.updateConsensusNun(srv.numConsensusPeer(peers))
+ srv.log.Debug("Remove consensus flag", "peer", n.ID(), "consensus", srv.consensus, "flag", p.rw.flags)
if len(peers) > srv.MaxPeers && !p.rw.is(staticDialedConn|trustedConn) {
srv.log.Debug("Disconnect non-consensus node", "peer", n.ID(), "flags", p.rw.flags, "peers", len(peers), "consensus", srv.consensus)
p.Disconnect(DiscRequested)
@@ -861,7 +846,7 @@ running:
}
if consensusNodes[c.node.ID()] {
- c.flags |= consensusDialedConn
+ c.set(consensusDialedConn, true)
}
// TODO: track in-progress inbound node IDs (pre-Peer) to avoid dialing them.
@@ -877,6 +862,9 @@ running:
peers[c.node.ID()] = p
srv.log.Debug("Adding p2p peer", "peercount", len(peers), "id", p.ID(), "conn", c.flags, "addr", p.RemoteAddr(), "name", p.Name())
srv.dialsched.peerAdded(c)
+ if srv.consensus {
+ srv.dialsched.updateConsensusNun(srv.numConsensusPeer(peers))
+ }
if p.Inbound() {
inboundCount++
}
@@ -889,6 +877,9 @@ running:
delete(peers, pd.ID())
srv.log.Debug("Removing p2p peer", "peercount", len(peers), "id", pd.ID(), "duration", d, "req", pd.requested, "err", pd.err)
srv.dialsched.peerRemoved(pd.rw)
+ if srv.consensus {
+ srv.dialsched.updateConsensusNun(srv.numConsensusPeer(peers))
+ }
if pd.Inbound() {
inboundCount--
}
@@ -920,7 +911,8 @@ running:
func (srv *Server) postHandshakeChecks(peers map[enode.ID]*Peer, inboundCount int, c *conn) error {
// Disconnect over limit non-consensus node.
- if srv.consensus && len(peers) >= srv.MaxPeers && c.is(consensusDialedConn) && srv.numConsensusPeer(peers) < srv.MaxConsensusPeers {
+ numConsensusPeer := srv.numConsensusPeer(peers)
+ if srv.consensus && len(peers) >= srv.MaxPeers && c.is(consensusDialedConn) && numConsensusPeer < srv.MaxConsensusPeers {
for _, p := range peers {
if p.rw.is(inboundConn|dynDialedConn) && !p.rw.is(trustedConn|staticDialedConn|consensusDialedConn) {
srv.log.Debug("Disconnect over limit connection", "peer", p.ID(), "flags", p.rw.flags, "peers", len(peers))
@@ -931,7 +923,7 @@ func (srv *Server) postHandshakeChecks(peers map[enode.ID]*Peer, inboundCount in
}
switch {
- case c.is(consensusDialedConn) && srv.numConsensusPeer(peers) >= srv.MaxConsensusPeers:
+ case c.is(consensusDialedConn) && numConsensusPeer >= srv.MaxConsensusPeers:
return DiscTooManyConsensusPeers
case !srv.consensus && c.is(consensusDialedConn) && len(peers) >= srv.MaxPeers:
return DiscTooManyPeers
@@ -1272,7 +1264,7 @@ func (srv *Server) StartWatching(eventMux *event.TypeMux) {
}
func (srv *Server) watching() {
- events := srv.eventMux.Subscribe(cbfttypes.AddValidatorEvent{}, cbfttypes.RemoveValidatorEvent{})
+ events := srv.eventMux.Subscribe(cbfttypes.AddValidatorEvent{}, cbfttypes.RemoveValidatorEvent{}, cbfttypes.UpdateValidatorEvent{})
defer events.Unsubscribe()
for {
@@ -1289,6 +1281,30 @@ func (srv *Server) watching() {
case cbfttypes.RemoveValidatorEvent:
srv.log.Trace("Received RemoveValidatorEvent", "nodeID", data.Node.ID().String())
srv.RemoveConsensusPeer(data.Node)
+ case cbfttypes.UpdateValidatorEvent:
+ if _, ok := data.Nodes[srv.localnode.ID()]; ok {
+ srv.doPeerOp(func(peers map[enode.ID]*Peer) {
+ for id, peer := range peers {
+ if _, ok := data.Nodes[id]; ok {
+ peer.rw.set(consensusDialedConn, true)
+ } else {
+ peer.rw.set(consensusDialedConn, false)
+ }
+ }
+ srv.log.Debug("We are become an consensus node")
+ srv.consensus = true
+ srv.dialsched.updateConsensusNun(srv.numConsensusPeer(peers))
+ })
+ } else {
+ srv.doPeerOp(func(peers map[enode.ID]*Peer) {
+ for _, peer := range peers {
+ peer.rw.set(consensusDialedConn, false)
+ }
+ srv.log.Debug("We are not an consensus node")
+ srv.consensus = false
+ srv.dialsched.updateConsensusNun(0)
+ })
+ }
default:
srv.log.Error("Received unexcepted event")
}
diff --git a/params/protocol_params.go b/params/protocol_params.go
index f8eb1e9b04..287789041d 100644
--- a/params/protocol_params.go
+++ b/params/protocol_params.go
@@ -157,6 +157,8 @@ const (
Bls12381MapG1Gas uint64 = 5500 // Gas price for BLS12-381 mapping field element to G1 operation
Bls12381MapG2Gas uint64 = 110000 // Gas price for BLS12-381 mapping field element to G2 operation
+ BlsVerifyGas uint64 = 21000 // Gas price for BLS12-381 mapping field element to G2 operation
+
// The Refund Quotient is the cap on how much of the used gas can be refunded. Before EIP-3529,
// up to half the consumed gas could be refunded. Redefined as 1/5th in EIP-3529
RefundQuotient uint64 = 2