From: mars Date: Wed, 6 Mar 2019 07:11:17 +0000 (+0800) Subject: modify dpos X-Git-Tag: v1.0.5~219^2~3^2 X-Git-Url: http://git.osdn.net/view?p=bytom%2Fvapor.git;a=commitdiff_plain;h=bab9415cf7ddc5eb606286f96365a7af6cc2b80e modify dpos --- diff --git a/cmd/vapor/consensus.json b/cmd/vapor/consensus.json index b6585cc4..ee174372 100644 --- a/cmd/vapor/consensus.json +++ b/cmd/vapor/consensus.json @@ -1,7 +1,7 @@ { "consensus":{ "dpos": { - "period": 1, + "period": 3, "epoch": 300, "maxSignersCount": 1, "minVoterBalance": 0, diff --git a/cmd/vaporcli/bytomcli.exe b/cmd/vaporcli/bytomcli.exe deleted file mode 100644 index 3560fed3..00000000 Binary files a/cmd/vaporcli/bytomcli.exe and /dev/null differ diff --git a/consensus/consensus/consensus.go b/consensus/consensus/consensus.go index d5eb7d75..61c2dfcd 100644 --- a/consensus/consensus/consensus.go +++ b/consensus/consensus/consensus.go @@ -8,21 +8,6 @@ import ( // Engine is an algorithm agnostic consensus engine. type Engine interface { - // Author retrieves the Ethereum address of the account that minted the given - // block, which may be different from the header's coinbase if a consensus - // engine is based on signatures. - Author(header *types.BlockHeader, c chain.Chain) (string, 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. - VerifyHeader(c chain.Chain, header *types.BlockHeader, seal 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 - // a results channel to retrieve the async verifications (the order is that of - // the input slice). - VerifyHeaders(c chain.Chain, headers []*types.BlockHeader, seals []bool) (chan<- struct{}, <-chan error) // VerifySeal checks whether the crypto seal on a header is valid according to // the consensus rules of the given engine. diff --git a/consensus/consensus/dpos/custom_tx.go b/consensus/consensus/dpos/custom_tx.go index 8cc8b5a9..586abeab 100644 --- a/consensus/consensus/dpos/custom_tx.go +++ b/consensus/consensus/dpos/custom_tx.go @@ -187,11 +187,6 @@ func (d *Dpos) processCustomTx(headerExtra HeaderExtra, c chain.Chain, header *t } } } - /* - if height > 1 { - headerExtra.ModifyPredecessorVotes = d.processPredecessorVoter(headerExtra.ModifyPredecessorVotes, stake, from, to, snap) - } - */ } } @@ -283,14 +278,13 @@ func (d *Dpos) processEventDeclare(currentBlockDeclares []Declare, txDataInfo [] } func (d *Dpos) processEventVote(currentBlockVotes []Vote, stake uint64, voter, to string) []Vote { - - //if new(big.Int).SetUint64(stake).Cmp(d.config.MinVoterBalance) > 0 { - currentBlockVotes = append(currentBlockVotes, Vote{ - Voter: voter, - Candidate: to, - Stake: stake, - }) - //} + if stake >= d.config.MinVoterBalance { + currentBlockVotes = append(currentBlockVotes, Vote{ + Voter: voter, + Candidate: to, + Stake: stake, + }) + } return currentBlockVotes } @@ -309,7 +303,6 @@ func (d *Dpos) processEventConfirm(currentBlockConfirmations []Confirmation, c c if extraVanity+extraSeal > len(confirmedHeader.Extra) { return currentBlockConfirmations } - //err = rlp.DecodeBytes(confirmedHeader.Extra[extraVanity:len(confirmedHeader.Extra)-extraSeal], &confirmedHeaderExtra) if err := json.Unmarshal(confirmedHeader.Extra[extraVanity:len(confirmedHeader.Extra)-extraSeal], &confirmedHeaderExtra); err != nil { log.Info("Fail to decode parent header", "err", err) return currentBlockConfirmations @@ -327,24 +320,3 @@ func (d *Dpos) processEventConfirm(currentBlockConfirmations []Confirmation, c c return currentBlockConfirmations } - -func (d *Dpos) processPredecessorVoter(modifyPredecessorVotes []Vote, stake uint64, voter, to string, snap *Snapshot) []Vote { - if stake > 0 { - if snap.isVoter(voter) { - modifyPredecessorVotes = append(modifyPredecessorVotes, Vote{ - Voter: voter, - Candidate: "", - Stake: stake, - }) - } - if snap.isVoter(to) { - modifyPredecessorVotes = append(modifyPredecessorVotes, Vote{ - Voter: to, - Candidate: "", - Stake: stake, - }) - } - - } - return modifyPredecessorVotes -} diff --git a/consensus/consensus/dpos/dpos.go b/consensus/consensus/dpos/dpos.go index 3ea6220d..5eaf632b 100644 --- a/consensus/consensus/dpos/dpos.go +++ b/consensus/consensus/dpos/dpos.go @@ -103,21 +103,12 @@ type Dpos struct { recents *lru.ARCCache // Snapshots for recent block to speed up reorgs signatures *lru.ARCCache // Signatures of recent blocks to speed up mining signer string // Ethereum address of the signing key - signFn SignerFn // Signer function to authorize hashes with - signTxFn SignTxFn // Sign transaction function to sign tx lock sync.RWMutex // Protects the signer fields lcsc uint64 // Last confirmed side chain } -// SignerFn is a signer callback function to request a hash to be signed by a backing account. -type SignerFn func(string, []byte) ([]byte, error) - -// SignTxFn is a signTx -type SignTxFn func(string, *bc.Tx, *big.Int) (*bc.Tx, error) - // func ecrecover(header *types.BlockHeader, sigcache *lru.ARCCache, c chain.Chain) (string, error) { - xpub := &chainkd.XPub{} xpub.UnmarshalText(header.Coinbase) derivedPK := xpub.PublicKey() @@ -157,33 +148,14 @@ func New(config *config.DposConfig, store protocol.Store) *Dpos { } // Authorize injects a private key into the consensus engine to mint new blocks with. -func (d *Dpos) Authorize(signer string /*, signFn SignerFn*/) { +func (d *Dpos) Authorize(signer string) { d.lock.Lock() defer d.lock.Unlock() - d.signer = signer - //d.signFn = signFn -} - -// 从BLockHeader中获取到地址 -func (d *Dpos) Author(header *types.BlockHeader, c chain.Chain) (string, error) { - return ecrecover(header, d.signatures, c) -} - -func (d *Dpos) VerifyHeader(c chain.Chain, header *types.BlockHeader, seal bool) error { - return d.verifyCascadingFields(c, header, nil) -} - -func (d *Dpos) VerifyHeaders(c chain.Chain, headers []*types.BlockHeader, seals []bool) (chan<- struct{}, <-chan error) { - return nil, nil } func (d *Dpos) VerifySeal(c chain.Chain, header *types.BlockHeader) error { - return nil -} - -func (d *Dpos) verifyHeader(c chain.Chain, header *types.BlockHeader, parents []*types.BlockHeader) error { - return nil + return d.verifyCascadingFields(c, header, nil) } func (d *Dpos) verifyCascadingFields(c chain.Chain, header *types.BlockHeader, parents []*types.BlockHeader) error { @@ -233,11 +205,7 @@ func (d *Dpos) verifySeal(c chain.Chain, header *types.BlockHeader, parents []*t return err } - // Resolve the authorization key and check against signers - signer, err := ecrecover(header, d.signatures, c) - if err != nil { - return err - } + signer := "" if height > d.config.MaxSignerCount { var ( @@ -270,6 +238,7 @@ func (d *Dpos) verifySeal(c chain.Chain, header *types.BlockHeader, parents []*t if err != nil { return err } + signer = currentCoinbase.EncodeAddress() parentHeaderExtra := HeaderExtra{} if err = json.Unmarshal(parent.Extra[extraVanity:len(parent.Extra)-extraSeal], &parentHeaderExtra); err != nil { @@ -424,7 +393,6 @@ func (d *Dpos) Finalize(c chain.Chain, header *types.BlockHeader, txs []*bc.Tx) } } if height%d.config.MaxSignerCount == 0 { - //currentHeaderExtra.LoopStartTime = header.Time.Uint64() currentHeaderExtra.LoopStartTime = currentHeaderExtra.LoopStartTime + d.config.Period*d.config.MaxSignerCount // create random signersQueue in currentHeaderExtra by snapshot.Tally currentHeaderExtra.SignerQueue = []string{} @@ -589,7 +557,7 @@ func (d *Dpos) snapshot(c chain.Chain, number uint64, hash bc.Hash, parents []*t if err != nil { return nil, err } - if err := d.VerifyHeader(c, genesis, false); err != nil { + if err := d.VerifySeal(c, genesis); err != nil { return nil, err } diff --git a/consensus/consensus/dpos/signer_queue.go b/consensus/consensus/dpos/signer_queue.go index 5d3d440d..0b070015 100644 --- a/consensus/consensus/dpos/signer_queue.go +++ b/consensus/consensus/dpos/signer_queue.go @@ -85,7 +85,6 @@ func (s *Snapshot) buildTallySlice() TallySlice { } func (s *Snapshot) createSignerQueue() ([]string, error) { - if (s.Number+1)%s.config.MaxSignerCount != 0 || s.Hash != s.HistoryHash[len(s.HistoryHash)-1] { return nil, errCreateSignerQueueNotAllowed } diff --git a/consensus/consensus/dpos/snapshot.go b/consensus/consensus/dpos/snapshot.go index 2d19aff4..43a6a7aa 100644 --- a/consensus/consensus/dpos/snapshot.go +++ b/consensus/consensus/dpos/snapshot.go @@ -8,11 +8,7 @@ import ( "time" lru "github.com/hashicorp/golang-lru" - "github.com/vapor/common" "github.com/vapor/config" - "github.com/vapor/consensus" - "github.com/vapor/crypto" - "github.com/vapor/crypto/ed25519/chainkd" "github.com/vapor/protocol" "github.com/vapor/protocol/bc" "github.com/vapor/protocol/bc/types" @@ -209,18 +205,6 @@ func (s *Snapshot) apply(headers []*types.BlockHeader) (*Snapshot, error) { return nil, err } - xpub := &chainkd.XPub{} - xpub.UnmarshalText(header.Coinbase) - derivedPK := xpub.PublicKey() - pubHash := crypto.Ripemd160(derivedPK) - address, err := common.NewAddressWitnessPubKeyHash(pubHash, &consensus.ActiveNetParams) - if err != nil { - return nil, err - } - if coinbase != address.EncodeAddress() { - return nil, errUnauthorized - } - headerExtra := HeaderExtra{} if err := json.Unmarshal(header.Extra[extraVanity:len(header.Extra)-extraSeal], &headerExtra); err != nil { return nil, err @@ -247,11 +231,8 @@ func (s *Snapshot) apply(headers []*types.BlockHeader) (*Snapshot, error) { // deal the new vote from voter snap.updateSnapshotByVotes(headerExtra.CurrentBlockVotes, header.Height) - // deal the voter which balance modified - //snap.updateSnapshotByMPVotes(headerExtra.ModifyPredecessorVotes) - // deal the snap related with punished - //snap.updateSnapshotForPunish(headerExtra.SignerMissing, header.Height, header.Coinbase) + snap.updateSnapshotForPunish(headerExtra.SignerMissing, header.Height, coinbase) // deal proposals snap.updateSnapshotByProposals(headerExtra.CurrentBlockProposals, header.Height) @@ -303,6 +284,8 @@ func (s *Snapshot) verifyTallyCnt() error { for address, tally := range s.Tally { if targetTally, ok := tallyTarget[address]; ok && targetTally == tally { continue + } else { + return errIncorrectTallyCount } } @@ -370,14 +353,10 @@ func (s *Snapshot) calculateProposalResult(headerHeight uint64) { } case proposalTypeMinerRewardDistributionModify: minerRewardPerThousand = s.Proposals[hashKey].MinerRewardPerThousand - } } - } - } - } func (s *Snapshot) updateSnapshotByProposals(proposals []Proposal, headerHeight uint64) { @@ -388,7 +367,6 @@ func (s *Snapshot) updateSnapshotByProposals(proposals []Proposal, headerHeight } func (s *Snapshot) updateSnapshotForExpired() { - // deal the expired vote var expiredVotes []*Vote for voterAddress, voteNumber := range s.Voters { @@ -404,13 +382,11 @@ func (s *Snapshot) updateSnapshotForExpired() { for _, expiredVote := range expiredVotes { s.Tally[expiredVote.Candidate] -= expiredVote.Stake // TODO - /* - if s.Tally[expiredVote.Candidate] == 0 { - delete(s.Tally, expiredVote.Candidate) - } - delete(s.Votes, expiredVote.Voter) - delete(s.Voters, expiredVote.Voter) - */ + if s.Tally[expiredVote.Candidate] == 0 { + delete(s.Tally, expiredVote.Candidate) + } + delete(s.Votes, expiredVote.Voter) + delete(s.Voters, expiredVote.Voter) } } @@ -422,14 +398,13 @@ func (s *Snapshot) updateSnapshotForExpired() { } // TODO - /* - // remove 0 stake tally - for address, tally := range s.Tally { - if tally <= 0 { - delete(s.Tally, address) - } + // remove 0 stake tally + + for address, tally := range s.Tally { + if tally <= 0 && uint64(len(s.Tally)) > s.config.MaxSignerCount { + delete(s.Tally, address) } - */ + } } func (s *Snapshot) updateSnapshotByConfirmations(confirmations []Confirmation) { @@ -481,18 +456,6 @@ func (s *Snapshot) updateSnapshotByMPVotes(votes []Vote) { } func (s *Snapshot) updateSnapshotForPunish(signerMissing []string, headerNumber uint64, coinbase string) { - // set punished count to half of origin in Epoch - /* - if headerNumber.Uint64()%s.config.Epoch == 0 { - for bePublished := range s.Punished { - if count := s.Punished[bePublished] / 2; count > 0 { - s.Punished[bePublished] = count - } else { - delete(s.Punished, bePublished) - } - } - } - */ // punish the missing signer for _, signerMissing := range signerMissing { if _, ok := s.Punished[signerMissing]; ok { @@ -551,7 +514,6 @@ func (s *Snapshot) isCandidate(address string) bool { // get last block number meet the confirm condition func (s *Snapshot) getLastConfirmedBlockNumber(confirmations []Confirmation) *big.Int { - cpyConfirmations := make(map[uint64][]string) for blockNumber, confirmers := range s.Confirmations { cpyConfirmations[blockNumber] = make([]string, len(confirmers)) @@ -571,7 +533,6 @@ func (s *Snapshot) getLastConfirmedBlockNumber(confirmations []Confirmation) *bi } } if addConfirmation == true { - cpyConfirmations[confirmation.BlockNumber] = append(cpyConfirmations[confirmation.BlockNumber], confirmation.Signer) } } diff --git a/mining/miner/miner.go b/mining/miner/miner.go index f786ce76..518d33fc 100644 --- a/mining/miner/miner.go +++ b/mining/miner/miner.go @@ -45,14 +45,10 @@ type Miner struct { updateNumWorkers chan struct{} quit chan struct{} newBlockCh chan *bc.Hash - Authoritys map[string]string - position uint64 engine engine.Engine } func NewMiner(c *protocol.Chain, accountManager *account.Manager, txPool *protocol.TxPool, newBlockCh chan *bc.Hash, engine engine.Engine) *Miner { - authoritys := make(map[string]string) - var position uint64 dpos, ok := engine.(*dpos.Dpos) if !ok { log.Error("Only the dpos engine was allowed") @@ -68,8 +64,6 @@ func NewMiner(c *protocol.Chain, accountManager *account.Manager, txPool *protoc numWorkers: defaultNumWorkers, updateNumWorkers: make(chan struct{}), newBlockCh: newBlockCh, - Authoritys: authoritys, - position: position, engine: dpos, } } @@ -99,8 +93,6 @@ func (m *Miner) generateProof(block types.Block) (types.Proof, error) { // // It must be run as a goroutine. func (m *Miner) generateBlocks(quit chan struct{}) { - ticker := time.NewTicker(time.Second * hashUpdateSecs) - defer ticker.Stop() out: for { @@ -109,57 +101,47 @@ out: break out default: } - /* - engine, ok := m.engine.(*dpos.Dpos) - if !ok { - log.Error("Only the dpos engine was allowed") - return - } - header := m.chain.BestBlockHeader() - isSeal, err := engine.IsSealer(m.chain, header.Hash(), header, uint64(time.Now().Unix())) - if err != nil { - log.WithFields(log.Fields{"module": module, "error": err}).Error("Determine whether seal is wrong") - continue - } - */ - isSeal := true - if isSeal { - block, err := mining.NewBlockTemplate(m.chain, m.txPool, m.accountManager, m.engine) - if err != nil { - log.Errorf("Mining: failed on create NewBlockTemplate: %v", err) - time.Sleep(3 * time.Second) - continue - } - if block == nil { - time.Sleep(3 * time.Second) - continue - } - block, err = m.engine.Seal(m.chain, block) - if err != nil { - log.Errorf("Seal, %v", err) - continue - } - m.chain.SetConsensusEngine(m.engine) - if isOrphan, err := m.chain.ProcessBlock(block); err == nil { - log.WithFields(log.Fields{ - "height": block.BlockHeader.Height, - "isOrphan": isOrphan, - "tx": len(block.Transactions), - }).Info("Miner processed block") - - blockHash := block.Hash() - m.newBlockCh <- &blockHash - } else { - log.WithField("height", block.BlockHeader.Height).Errorf("Miner fail on ProcessBlock, %v", err) - } + block, err := mining.NewBlockTemplate(m.chain, m.txPool, m.accountManager, m.engine) + if err != nil { + log.Errorf("Mining: failed on create NewBlockTemplate: %v", err) + time.Sleep(1 * time.Second) + continue + } + if block == nil { + time.Sleep(1 * time.Second) + continue + } + block, err = m.engine.Seal(m.chain, block) + if err != nil { + log.Errorf("Seal, %v", err) + continue } - time.Sleep(3 * time.Second) + m.chain.SetConsensusEngine(m.engine) + if isOrphan, err := m.chain.ProcessBlock(block); err == nil { + log.WithFields(log.Fields{ + "height": block.BlockHeader.Height, + "isOrphan": isOrphan, + "tx": len(block.Transactions), + }).Info("Miner processed block") + + blockHash := block.Hash() + m.newBlockCh <- &blockHash + } else { + log.WithField("height", block.BlockHeader.Height).Errorf("Miner fail on ProcessBlock, %v", err) + } + // confirm block + m.sendConfirmTx(block.Height - 1) + time.Sleep(time.Duration(config.CommonConfig.Consensus.Dpos.Period) * time.Second) } m.workerWg.Done() } +func (m *Miner) sendConfirmTx(height uint64) error { + return nil +} + // miningWorkerController launches the worker goroutines that are used to // generate block templates and solve them. It also provides the ability to // dynamically adjust the number of running worker goroutines. diff --git a/mining/mining.go b/mining/mining.go index 59439045..e2a6e671 100644 --- a/mining/mining.go +++ b/mining/mining.go @@ -35,15 +35,7 @@ func createCoinbaseTx(accountManager *account.Manager, amount uint64, blockHeigh address, _ := common.DecodeAddress(config.CommonConfig.Consensus.Dpos.Coinbase, &consensus.ActiveNetParams) redeemContract := address.ScriptAddress() script, _ = vmutil.P2WPKHProgram(redeemContract) - /* - if accountManager == nil { - script, err = vmutil.DefaultCoinbaseProgram() - } else { - script, err = accountManager.GetCoinbaseControlProgram() - arbitrary = append(arbitrary, accountManager.GetCoinbaseArbitrary()...) - } - */ if err != nil { return nil, err } @@ -107,7 +99,6 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager Timestamp: uint64(time.Now().Unix()), BlockCommitment: types.BlockCommitment{}, Coinbase: xpub, - //Extra: make([]byte, 32+65), } if err := engine.Prepare(c, &header); err != nil { @@ -160,10 +151,6 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager } } - if txFee == 0 { - return nil, nil - } - if err := engine.Finalize(c, &header, txEntries[1:]); err != nil { return nil, err } diff --git a/mining/miningpool/miningpool.go b/mining/miningpool/miningpool.go index 4b3ecc55..eecec597 100644 --- a/mining/miningpool/miningpool.go +++ b/mining/miningpool/miningpool.go @@ -8,7 +8,6 @@ import ( log "github.com/sirupsen/logrus" "github.com/vapor/account" - "github.com/vapor/mining" "github.com/vapor/protocol" "github.com/vapor/protocol/bc" "github.com/vapor/protocol/bc/types" @@ -68,15 +67,7 @@ func (m *MiningPool) blockUpdater() { // generateBlock generates a block template to mine func (m *MiningPool) generateBlock() { - m.mutex.Lock() - defer m.mutex.Unlock() - block, err := mining.NewBlockTemplate(m.chain, m.txPool, m.accountManager) - if err != nil { - log.Errorf("miningpool: failed on create NewBlockTemplate: %v", err) - return - } - m.block = block } // GetWork will return a block header for p2p mining diff --git a/netsync/handle.go b/netsync/handle.go index 9ee466e7..d1b15d41 100644 --- a/netsync/handle.go +++ b/netsync/handle.go @@ -394,6 +394,8 @@ func (sm *SyncManager) processMsg(basePeer BasePeer, msgType byte, msg Blockchai case *GetMerkleBlockMessage: sm.handleGetMerkleBlockMsg(peer, msg) + // TODO PBFT消息 + default: log.WithFields(log.Fields{ "module": logModule, diff --git a/protocol/block.go b/protocol/block.go index 1894f68b..d263754f 100644 --- a/protocol/block.go +++ b/protocol/block.go @@ -158,7 +158,7 @@ func (c *Chain) saveBlock(block *types.Block) error { bcBlock := types.MapBlock(block) parent := c.index.GetNode(&block.PreviousBlockHash) - if err := validation.ValidateBlock(bcBlock, parent, block, c, c.engine, c.Authoritys, c.position); err != nil { + if err := validation.ValidateBlock(bcBlock, parent, block, c, c.engine); err != nil { return errors.Sub(ErrBadBlock, err) } if err := c.store.SaveBlock(block, bcBlock.TransactionStatus); err != nil { diff --git a/protocol/protocol.go b/protocol/protocol.go index ff61e185..7bd85188 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -23,11 +23,9 @@ type Chain struct { store Store processBlockCh chan *processBlockMsg - cond sync.Cond - bestNode *state.BlockNode - Authoritys map[string]string - position uint64 - engine engine.Engine + cond sync.Cond + bestNode *state.BlockNode + engine engine.Engine } // NewChain returns a new Chain using store as the underlying storage. @@ -59,14 +57,6 @@ func NewChain(store Store, txPool *TxPool) (*Chain, error) { return c, nil } -func (c *Chain) SetAuthoritys(authoritys map[string]string) { - c.Authoritys = authoritys -} - -func (c *Chain) SetPosition(position uint64) { - c.position = position -} - func (c *Chain) SetConsensusEngine(engine engine.Engine) { c.engine = engine } diff --git a/protocol/validation/block.go b/protocol/validation/block.go index e55e22c0..3f8f522c 100644 --- a/protocol/validation/block.go +++ b/protocol/validation/block.go @@ -69,7 +69,7 @@ func ValidateBlockHeader(b *bc.Block, block *types.Block, parent *state.BlockNod if err := checkBlockTime(b, parent); err != nil { return err } - if err := engine.VerifyHeader(c, &block.BlockHeader, false); err != nil { + if err := engine.VerifySeal(c, &block.BlockHeader); err != nil { return err } @@ -77,23 +77,12 @@ func ValidateBlockHeader(b *bc.Block, block *types.Block, parent *state.BlockNod } // ValidateBlock validates a block and the transactions within. -func ValidateBlock(b *bc.Block, parent *state.BlockNode, block *types.Block, c chain.Chain, engine engine.Engine, authoritys map[string]string, position uint64) error { +func ValidateBlock(b *bc.Block, parent *state.BlockNode, block *types.Block, c chain.Chain, engine engine.Engine) error { startTime := time.Now() if err := ValidateBlockHeader(b, block, parent, c, engine); err != nil { return err } - /* - time.Sleep(3 * time.Second) - // 验证出块人 - controlProgram := hex.EncodeToString(block.Proof.ControlProgram) - xpub := &chainkd.XPub{} - xpub.UnmarshalText([]byte(authoritys[controlProgram])) - msg := block.BlockCommitment.TransactionsMerkleRoot.Bytes() - if !xpub.Verify(msg, block.Proof.Sign) { - return errors.New("Verification signature failed") - } - */ blockGasSum := uint64(0) coinbaseAmount := consensus.BlockSubsidy(b.BlockHeader.Height) b.TransactionStatus = bc.NewTransactionStatus() diff --git a/test/bench_blockchain_test.go b/test/bench_blockchain_test.go index c29746f7..abdb2e07 100644 --- a/test/bench_blockchain_test.go +++ b/test/bench_blockchain_test.go @@ -156,7 +156,7 @@ func InsertChain(chain *protocol.Chain, txPool *protocol.TxPool, txs []*types.Tx } } - block, err := mining.NewBlockTemplate(chain, txPool, nil) + block, err := mining.NewBlockTemplate(chain, txPool, nil, nil) if err != nil { return err } diff --git a/test/block_test_util.go b/test/block_test_util.go index 8b6d2e9b..e609d855 100644 --- a/test/block_test_util.go +++ b/test/block_test_util.go @@ -1,8 +1,6 @@ package test import ( - "encoding/hex" - "github.com/vapor/consensus" "github.com/vapor/crypto" "github.com/vapor/crypto/ed25519/chainkd" @@ -118,20 +116,6 @@ func AppendBlocks(chain *protocol.Chain, num uint64) error { return nil } -func setAuthoritys(chain *protocol.Chain) { - authoritys := make(map[string]string) - xpubStr := "96bc2ad4b1c2db399990c811c4367688cbb7867612bb9d04e4dc7848e425c6395264d3b177a96646bc0ce517ae7fd63504c183ab6d330dea184331a4cf5912d5" - var xpub chainkd.XPub - xpub.UnmarshalText([]byte(xpubStr)) - - pubHash := crypto.Ripemd160(xpub.PublicKey()) - control, _ := vmutil.P2WPKHProgram([]byte(pubHash)) - key := hex.EncodeToString(control) - authoritys[key] = xpub.String() - - chain.SetAuthoritys(authoritys) -} - // SolveAndUpdate solve difficulty and update chain status func SolveAndUpdate(chain *protocol.Chain, block *types.Block) error { _, err := chain.ProcessBlock(block) diff --git a/test/util.go b/test/util.go index b534a42a..3377f126 100644 --- a/test/util.go +++ b/test/util.go @@ -43,7 +43,6 @@ func MockChain(testDB dbm.DB) (*protocol.Chain, *leveldb.Store, *protocol.TxPool txPool := protocol.NewTxPool(store) chain, err := protocol.NewChain(store, txPool) consensus.ActiveNetParams.Signer = "78673764e0ba91a4c5ba9ec0c8c23c69e3d73bf27970e05e0a977e81e13bde475264d3b177a96646bc0ce517ae7fd63504c183ab6d330dea184331a4cf5912d5" - setAuthoritys(chain) return chain, store, txPool, err } diff --git a/tools/monitor_tx/http_client.go b/tools/monitor_tx/http_client.go index edb8336f..0417834a 100644 --- a/tools/monitor_tx/http_client.go +++ b/tools/monitor_tx/http_client.go @@ -20,7 +20,7 @@ type Response struct { } func getPeginInfo() (map[string]string, error) { - resp, err := http.Get("http://127.0.0.1:8000/api/get_pegin_address") + resp, err := http.Get("http://127.0.0.1:8080/api/get_pegin_address") if err != nil { return nil, err } diff --git a/tools/side_chain_tool/consensus.json b/tools/side_chain_tool/consensus.json index b6585cc4..2cb5b93e 100644 --- a/tools/side_chain_tool/consensus.json +++ b/tools/side_chain_tool/consensus.json @@ -6,10 +6,11 @@ "maxSignersCount": 1, "minVoterBalance": 0, "genesisTimestamp": 1524549600, - "coinbase": "vsm1qkm743xmgnvh84pmjchq2s4tnfpgu9ae2f9slep", - "xprv": "a8e281b615809046698fb0b0f2804a36d824d48fa443350f10f1b80649d39e5f1e85cf9855548915e36137345910606cbc8e7dd8497c831dce899ee6ac112445", + "coinbase": "vsm1qy7ml46ehvsny47l7cl76ejeye7ngkvh3tkp7n7", + "xprv": "c0d652077ae5d056c143ef94d0fa2042d9083d13174ae47d88ece000c4cc2d4d7200dba78d5f21e1c3d35b351fbd410b4cf453d7cd425f8d47acec25e8a271e9", "signers": [ - "vsm1qkm743xmgnvh84pmjchq2s4tnfpgu9ae2f9slep" + "vsm1qkm743xmgnvh84pmjchq2s4tnfpgu9ae2f9slep", + "vsm1qy7ml46ehvsny47l7cl76ejeye7ngkvh3tkp7n7" ] } }