Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 276
chore: minor deduplication#3139
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
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
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 |
|---|---|---|
| @@ -55,6 +55,7 @@ linters: | ||
| gosec: | ||
| excludes: | ||
| - G115 | ||
| - G118 | ||
| revive: | ||
| rules: | ||
| - name: package-comments | ||
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 |
|---|---|---|
| @@ -349,17 +349,16 @@ func (s *Submitter) processDAInclusionLoop() { | ||
| return | ||
| } | ||
| // Persist DA included height before advancing in-memory state | ||
| if err := putUint64Metadata(s.ctx, s.store, store.DAIncludedHeightKey, nextHeight); err != nil { | ||
| s.logger.Error().Err(err).Uint64("height", nextHeight).Msg("failed to persist DA included height") | ||
| break | ||
| } | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // Update DA included height | ||
| s.SetDAIncludedHeight(nextHeight) | ||
| currentDAIncluded = nextHeight | ||
| // Persist DA included height | ||
| bz := make([]byte, 8) | ||
| binary.LittleEndian.PutUint64(bz, nextHeight) | ||
| if err := s.store.SetMetadata(s.ctx, store.DAIncludedHeightKey, bz); err != nil { | ||
| s.logger.Error().Err(err).Uint64("height", nextHeight).Msg("failed to persist DA included height") | ||
| } | ||
| // Delete height cache for that height | ||
| // This can only be performed after the height has been persisted to store | ||
| s.cache.DeleteHeight(nextHeight) | ||
| @@ -415,6 +414,13 @@ func (s *Submitter) initializeDAIncludedHeight(ctx context.Context) error { | ||
| return nil | ||
| } | ||
| // putUint64Metadata encodes val as 8-byte little-endian and writes it to the store. | ||
| func putUint64Metadata(ctx context.Context, st store.Store, key string, val uint64) error { | ||
| bz := make([]byte, 8) | ||
| binary.LittleEndian.PutUint64(bz, val) | ||
| return st.SetMetadata(ctx, key, bz) | ||
| } | ||
| // sendCriticalError sends a critical error to the error channel without blocking | ||
| func (s *Submitter) sendCriticalError(err error) { | ||
| if s.errorCh != nil { | ||
| @@ -431,41 +437,33 @@ func (s *Submitter) sendCriticalError(err error) { | ||
| func (s *Submitter) setNodeHeightToDAHeight(ctx context.Context, height uint64, data *types.Data, genesisInclusion bool) error { | ||
| dataHash := data.DACommitment() | ||
| headerDaHeightBytes := make([]byte, 8) | ||
| daHeightForHeader, ok := s.cache.GetHeaderDAIncludedByHeight(height) | ||
| if !ok { | ||
| return fmt.Errorf("header for height %d not found in cache", height) | ||
| } | ||
| binary.LittleEndian.PutUint64(headerDaHeightBytes, daHeightForHeader) | ||
| if err := s.store.SetMetadata(ctx, store.GetHeightToDAHeightHeaderKey(height), headerDaHeightBytes); err != nil { | ||
| if err := putUint64Metadata(ctx, s.store, store.GetHeightToDAHeightHeaderKey(height), daHeightForHeader); err != nil { | ||
| return err | ||
| } | ||
| genesisDAIncludedHeight := daHeightForHeader | ||
| dataDaHeightBytes := make([]byte, 8) | ||
| // For empty transactions, use the same DA height as the header | ||
| if bytes.Equal(dataHash, common.DataHashForEmptyTxs) { | ||
| binary.LittleEndian.PutUint64(dataDaHeightBytes, daHeightForHeader) | ||
| } else { | ||
| // For empty transactions, use the same DA height as the header. | ||
| dataDAHeight := daHeightForHeader | ||
| if !bytes.Equal(dataHash, common.DataHashForEmptyTxs) { | ||
| daHeightForData, ok := s.cache.GetDataDAIncludedByHeight(height) | ||
| if !ok { | ||
| return fmt.Errorf("data for height %d not found in cache", height) | ||
| } | ||
| binary.LittleEndian.PutUint64(dataDaHeightBytes, daHeightForData) | ||
| dataDAHeight = daHeightForData | ||
| // if data posted before header, use data da included height for genesis da height | ||
| genesisDAIncludedHeight = min(daHeightForData, genesisDAIncludedHeight) | ||
| } | ||
| if err := s.store.SetMetadata(ctx, store.GetHeightToDAHeightDataKey(height), dataDaHeightBytes); err != nil { | ||
| if err := putUint64Metadata(ctx, s.store, store.GetHeightToDAHeightDataKey(height), dataDAHeight); err != nil { | ||
| return err | ||
| } | ||
| if genesisInclusion { | ||
| genesisDAIncludedHeightBytes := make([]byte, 8) | ||
| binary.LittleEndian.PutUint64(genesisDAIncludedHeightBytes, genesisDAIncludedHeight) | ||
| if err := s.store.SetMetadata(ctx, store.GenesisDAHeightKey, genesisDAIncludedHeightBytes); err != nil { | ||
| if err := putUint64Metadata(ctx, s.store, store.GenesisDAHeightKey, genesisDAIncludedHeight); err != nil { | ||
| return err | ||
| } | ||
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.