Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 276
refactor: remove commit type#1739
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
36fc73b
Remove commit type
Manav-Aggarwal 2c8f23f
update name
Manav-Aggarwal d7ef588
Modify sig to signature
Manav-Aggarwal 3fb7cd7
Update store and store test
Manav-Aggarwal 4e683f3
Update commit to signature in docs
Manav-Aggarwal e650dab
Update GetCommit to GetSignature
Manav-Aggarwal e8313a7
Update signature back to sig and update store method comments
Manav-Aggarwal f4ba23f
Resolve Javed's comments
Manav-Aggarwal 33eb05b
Resolve all comments
Manav-Aggarwal a0bfe8d
Revert signaturePrefix for backwards compatibility
Manav-Aggarwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -526,7 +526,7 @@ func (m *Manager) trySyncNextBlock(ctx context.Context, daHeight uint64) error { | ||
| // if call to applyBlock fails, we halt the node, see https://github.com/cometbft/cometbft/pull/496 | ||
| panic(fmt.Errorf("failed to ApplyBlock: %w", err)) | ||
| } | ||
| err = m.store.SaveBlock(ctx, b, &b.SignedHeader.Commit) | ||
| err = m.store.SaveBlock(ctx, b, &b.SignedHeader.Signature) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to save block: %w", err) | ||
| } | ||
| @@ -738,16 +738,15 @@ func getRemainingSleep(start time.Time, interval, defaultSleep time.Duration) ti | ||
| return sleepDuration | ||
| } | ||
| func (m *Manager) getCommit(header types.Header) (*types.Commit, error) { | ||
| func (m *Manager) getSignature(header types.Header) (*types.Signature, error) { | ||
| // note: for compatibility with tendermint light client | ||
| consensusVote := header.MakeCometBFTVote() | ||
| sign, err := m.sign(consensusVote) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &types.Commit{ | ||
| Signatures: []types.Signature{sign}, | ||
| }, nil | ||
| signature := types.Signature(sign) | ||
| return &signature, nil | ||
| } | ||
| func (m *Manager) publishBlock(ctx context.Context) error { | ||
| @@ -766,17 +765,17 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| } | ||
| var ( | ||
| lastCommit *types.Commit | ||
| lastSignature *types.Signature | ||
| lastHeaderHash types.Hash | ||
| err error | ||
| ) | ||
| height := m.store.Height() | ||
| newHeight := height + 1 | ||
| // this is a special case, when first block is produced - there is no previous commit | ||
| if newHeight == uint64(m.genesis.InitialHeight) { | ||
| lastCommit = &types.Commit{} | ||
| lastSignature = &types.Signature{} | ||
| } else { | ||
| lastCommit, err = m.store.GetCommit(ctx, height) | ||
| lastSignature, err = m.store.GetSignature(ctx, height) | ||
| if err != nil { | ||
| return fmt.Errorf("error while loading last commit: %w", err) | ||
| } | ||
| @@ -788,7 +787,7 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| } | ||
| var block *types.Block | ||
| var commit *types.Commit | ||
| var signature *types.Signature | ||
| // Check if there's an already stored block at a newer height | ||
| // If there is use that instead of creating a new block | ||
| @@ -802,14 +801,14 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| if err != nil { | ||
Manav-Aggarwal marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return fmt.Errorf("failed to load extended commit for height %d: %w", height, err) | ||
| } | ||
| block, err = m.createBlock(newHeight, lastCommit, lastHeaderHash, extendedCommit) | ||
| block, err = m.createBlock(newHeight, lastSignature, lastHeaderHash, extendedCommit) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| m.logger.Debug("block info", "num_tx", len(block.Data.Txs)) | ||
| /* | ||
| here we set the SignedHeader.DataHash, and SignedHeader.Commit as a hack | ||
| here we set the SignedHeader.DataHash, and SignedHeader.Signature as a hack | ||
| to make the block pass ValidateBasic() when it gets called by applyBlock on line 681 | ||
| these values get overridden on lines 687-698 after we obtain the IntermediateStateRoots. | ||
| */ | ||
| @@ -821,14 +820,14 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| block.SignedHeader.Validators = m.getLastStateValidators() | ||
| block.SignedHeader.ValidatorHash = block.SignedHeader.Validators.Hash() | ||
| commit, err = m.getCommit(block.SignedHeader.Header) | ||
| signature, err = m.getSignature(block.SignedHeader.Header) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| // set the commit to current block's signed header | ||
| block.SignedHeader.Commit = *commit | ||
| err = m.store.SaveBlock(ctx, block, commit) | ||
| // set the signature to current block's signed header | ||
| block.SignedHeader.Signature = *signature | ||
| err = m.store.SaveBlock(ctx, block, signature) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| @@ -848,7 +847,7 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| return err | ||
| } | ||
| commit, err = m.getCommit(block.SignedHeader.Header) | ||
| signature, err = m.getSignature(block.SignedHeader.Header) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| @@ -857,8 +856,8 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| return err | ||
| } | ||
| // set the commit to current block's signed header | ||
| block.SignedHeader.Commit = *commit | ||
| // set the signature to current block's signed header | ||
| block.SignedHeader.Signature = *signature | ||
| // Validate the created block before storing | ||
| if err := m.executor.Validate(m.lastState, block); err != nil { | ||
| return fmt.Errorf("failed to validate block: %w", err) | ||
| @@ -872,7 +871,7 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| m.blockCache.setSeen(blockHash) | ||
| // SaveBlock commits the DB tx | ||
| err = m.store.SaveBlock(ctx, block, commit) | ||
| err = m.store.SaveBlock(ctx, block, signature) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| @@ -1144,10 +1143,10 @@ func (m *Manager) getLastBlockTime() time.Time { | ||
| return m.lastState.LastBlockTime | ||
| } | ||
| func (m *Manager) createBlock(height uint64, lastCommit *types.Commit, lastHeaderHash types.Hash, extendedCommit abci.ExtendedCommitInfo) (*types.Block, error) { | ||
| func (m *Manager) createBlock(height uint64, lastSignature *types.Signature, lastHeaderHash types.Hash, extendedCommit abci.ExtendedCommitInfo) (*types.Block, error) { | ||
| m.lastStateMtx.RLock() | ||
| defer m.lastStateMtx.RUnlock() | ||
| return m.executor.CreateBlock(height, lastCommit, extendedCommit, lastHeaderHash, m.lastState) | ||
| return m.executor.CreateBlock(height, lastSignature, extendedCommit, lastHeaderHash, m.lastState) | ||
| } | ||
| func (m *Manager) applyBlock(ctx context.Context, block *types.Block) (types.State, *abci.ResponseFinalizeBlock, error) { | ||
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
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
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 |
|---|---|---|
| @@ -93,7 +93,7 @@ func (e *BlockExecutor) InitChain(genesis *cmtypes.GenesisDoc) (*abci.ResponseIn | ||
| } | ||
| // CreateBlock reaps transactions from mempool and builds a block. | ||
| func (e *BlockExecutor) CreateBlock(height uint64, lastCommit *types.Commit, lastExtendedCommit abci.ExtendedCommitInfo, lastHeaderHash types.Hash, state types.State) (*types.Block, error) { | ||
| func (e *BlockExecutor) CreateBlock(height uint64, lastSignature *types.Signature, lastExtendedCommit abci.ExtendedCommitInfo, lastHeaderHash types.Hash, state types.State) (*types.Block, error) { | ||
| maxBytes := state.ConsensusParams.Block.MaxBytes | ||
| emptyMaxBytes := maxBytes == -1 | ||
| if emptyMaxBytes { | ||
| @@ -128,7 +128,7 @@ func (e *BlockExecutor) CreateBlock(height uint64, lastCommit *types.Commit, las | ||
| LastResultsHash: state.LastResultsHash, | ||
| ProposerAddress: e.proposerAddress, | ||
| }, | ||
| Commit: *lastCommit, | ||
| Signature: *lastSignature, | ||
| }, | ||
| Data: types.Data{ | ||
| Txs: toRollkitTxs(mempoolTxs), | ||
| @@ -169,7 +169,8 @@ func (e *BlockExecutor) CreateBlock(height uint64, lastCommit *types.Commit, las | ||
| } | ||
| block.Data.Txs = toRollkitTxs(txl) | ||
| block.SignedHeader.LastCommitHash = lastCommit.GetCommitHash(&block.SignedHeader.Header, e.proposerAddress) | ||
| // Note: This is hash of an ABCI type commit equivalent of the last signature in the signed header. | ||
| block.SignedHeader.LastCommitHash = lastSignature.GetCommitHash(&block.SignedHeader.Header, e.proposerAddress) | ||
Manav-Aggarwal marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| block.SignedHeader.LastHeaderHash = lastHeaderHash | ||
| return block, nil | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.