- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.4k
fix(miner): ignore lastWork when selecting the best mining candidate + tests #12659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Closed
      
      
    
  
     Closed
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            7 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      e1a0572
              
                fix(miner): ignore lastWork when selecting the best mining candidate
              
              
                Stebalien c80f32d
              
                fix(miner): continue mining if we fail to submit a block
              
              
                Stebalien 4404614
              
                [WIP] test: checkpoint to a fork
              
              
                Stebalien 065df6a
              
                fix(miner): check the slash filter with the correct parent height
              
              
                Stebalien d5a45ba
              
                fix(exchange): avoid adding ourselves as an exchange peer
              
              
                Stebalien 475eda5
              
                fix(hello): submit new blocks from peers even if we're at genesis
              
              
                Stebalien 8d4a555
              
                `make gen`
              
              
                masih File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package itests | ||
|  | ||
| import ( | ||
| "context" | ||
| "testing" | ||
| "time" | ||
|  | ||
| "github.com/stretchr/testify/require" | ||
|  | ||
| "github.com/filecoin-project/go-state-types/abi" | ||
|  | ||
| "github.com/filecoin-project/lotus/chain/types" | ||
| "github.com/filecoin-project/lotus/itests/kit" | ||
| ) | ||
|  | ||
| func TestCheckpointFork(t *testing.T) { | ||
| ctx := context.Background() | ||
|  | ||
| blocktime := 100 * time.Millisecond | ||
|  | ||
| nopts := []kit.NodeOpt{kit.WithAllSubsystems(), kit.ThroughRPC()} | ||
| var n1, n2 kit.TestFullNode | ||
| var m1, m2 kit.TestMiner | ||
| ens := kit.NewEnsemble(t, kit.MockProofs()). | ||
| FullNode(&n1, nopts...). | ||
| FullNode(&n2, nopts...). | ||
| Miner(&m1, &n1, nopts...). | ||
| Miner(&m2, &n1, nopts...).Start() | ||
|  | ||
| // Start 2 of them. | ||
| ens.InterconnectAll().BeginMining(blocktime) | ||
|  | ||
| { | ||
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||
| n1.WaitTillChain(ctx, kit.HeightAtLeast(abi.ChainEpoch(5))) | ||
| cancel() | ||
| } | ||
|  | ||
| // Wait till both participate in a single tipset. | ||
| var target *types.TipSet | ||
| { | ||
| // find the first tipset where two miners mine a block. | ||
| ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) | ||
| target = n1.WaitTillChain(ctx, func(ts *types.TipSet) bool { | ||
| return len(ts.Blocks()) == 2 | ||
| }) | ||
| cancel() | ||
| } | ||
|  | ||
| // Wait till we've moved on from that tipset. | ||
| targetHeight := target.Height() + 10 | ||
| n1.WaitTillChain(ctx, kit.HeightAtLeast(targetHeight)) | ||
| n2.WaitTillChain(ctx, kit.HeightAtLeast(targetHeight)) | ||
|  | ||
| // Forcibly sync to this fork tipset. | ||
| forkTs, err := types.NewTipSet(target.Blocks()[:1]) | ||
| require.NoError(t, err) | ||
| require.NoError(t, n2.SyncCheckpoint(ctx, forkTs.Key())) | ||
| require.NoError(t, n1.SyncCheckpoint(ctx, forkTs.Key())) | ||
|  | ||
| // See if we can start making progress again! | ||
| newHead := n1.WaitTillChain(ctx, kit.HeightAtLeast(targetHeight)) | ||
| forkTs2, err := n1.ChainGetTipSetByHeight(ctx, forkTs.Height(), newHead.Key()) | ||
| require.NoError(t, err) | ||
| require.True(t, forkTs.Equals(forkTs2)) | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|  | @@ -132,13 +132,11 @@ func (hs *Service) HandleStream(s inet.Stream) { | |||
| return | ||||
| } | ||||
|  | ||||
| if ts.TipSet().Height() > 0 { | ||||
| hs.h.ConnManager().TagPeer(s.Conn().RemotePeer(), "fcpeer", 10) | ||||
| hs.h.ConnManager().TagPeer(s.Conn().RemotePeer(), "fcpeer", 10) | ||||
|  | ||||
| // don't bother informing about genesis | ||||
| log.Debugf("Got new tipset through Hello: %s from %s", ts.Cids(), s.Conn().RemotePeer()) | ||||
| hs.syncer.InformNewHead(s.Conn().RemotePeer(), ts) | ||||
| } | ||||
| // don't bother informing about genesis | ||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
        Suggested change
       
 | ||||
| log.Debugf("Got new tipset through Hello: %s from %s", ts.Cids(), s.Conn().RemotePeer()) | ||||
| hs.syncer.InformNewHead(s.Conn().RemotePeer(), ts) | ||||
| } | ||||
|  | ||||
| func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error { | ||||
|  | ||||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.