@@ -51,7 +51,6 @@ import (
5151 "github.com/ethereum/go-ethereum/params"
5252 "github.com/ethereum/go-ethereum/rlp"
5353 "github.com/ethereum/go-ethereum/rpc"
54- "time"
5554)
5655
5756const NumOfMasternodes = 99
@@ -202,56 +201,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
202201 return
203202 }
204203 if _ , authorized := snap .Signers [eth .etherbase ]; authorized {
205- // double validation
206- m2 , err := getM2 (snap , eth , block )
207- if err != nil {
208- log .Error ("Fail to validate M2 condition for imported block" , "error" , err )
209- return
210- }
211- if eth .etherbase != m2 {
212- // firstly, look into pending txPool
213- pendingMap , err := eth .txPool .Pending ()
214- if err != nil {
215- log .Error ("Fail to get txPool pending" , "err" , err )
216- //reset pendingMap
217- pendingMap = map [common.Address ]types.Transactions {}
218- }
219- txsSentFromM2 := pendingMap [m2 ]
220- if len (txsSentFromM2 ) > 0 {
221- for _ , tx := range txsSentFromM2 {
222- if tx .To ().String () == common .BlockSigners {
223- if err := contracts .CreateTransactionSign (chainConfig , eth .txPool , eth .accountManager , block , chainDb ); err != nil {
224- log .Error ("Fail to create tx sign for imported block" , "error" , err )
225- return
226- }
227- return
228- }
229- }
230- }
231- //then wait until signTx from m2 comes into txPool
232- txCh := make (chan core.TxPreEvent , txChanSize )
233- subEvent := eth .txPool .SubscribeTxPreEvent (txCh )
234- G:
235- select {
236- case event := <- txCh :
237- from , err := eth .txPool .GetSender (event .Tx )
238- if (err == nil ) && (event .Tx .To ().String () == common .BlockSigners ) && (from == m2 ) {
239- if err := contracts .CreateTransactionSign (chainConfig , eth .txPool , eth .accountManager , block , chainDb ); err != nil {
240- log .Error ("Fail to create tx sign for imported block" , "error" , err )
241- return
242- }
243- return
244- }
245- //timeout 10s
246- case <- time .After (time .Duration (10 ) * time .Second ):
247- break G
248- }
249- subEvent .Unsubscribe ()
250- } else if err := contracts .CreateTransactionSign (chainConfig , eth .txPool , eth .accountManager , block , chainDb ); err != nil {
204+ if err := contracts .CreateTransactionSign (chainConfig , eth .txPool , eth .accountManager , block , chainDb ); err != nil {
251205 log .Error ("Fail to create tx sign for imported block" , "error" , err )
252206 return
253207 }
254- // end of double validation
255208 }
256209 }
257210 eth .protocolManager .fetcher .SetImportedHook (importedHook )
@@ -342,25 +295,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
342295 return eth , nil
343296}
344297
345- func getM2 (snap * posv.Snapshot , eth * Ethereum , block * types.Block ) (common.Address , error ) {
346- epoch := eth .chainConfig .Posv .Epoch
347- no := block .NumberU64 ()
348- cpNo := no
349- if no % epoch != 0 {
350- cpNo = no - (no % epoch )
351- }
352- cpBlk := eth .blockchain .GetBlockByNumber (cpNo )
353- m , err := contracts .GetM1M2FromCheckpointBlock (cpBlk )
354- if err != nil {
355- return common.Address {}, err
356- }
357- m1 , err := posv .WhoIsCreator (snap , block .Header ())
358- if err != nil {
359- return common.Address {}, err
360- }
361- return m [m1 ], nil
362- }
363-
364298func makeExtraData (extra []byte ) []byte {
365299 if len (extra ) == 0 {
366300 // create default extradata
0 commit comments