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(manager): extract some errors as variables#1793
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
384c12184d724a215404a2285f1a788049671ede23File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package block | ||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| ) | ||
| // These errors are used by Manager. | ||
| var ( | ||
| // ErrNoValidatorsInState is used when no validators/proposers are found in state | ||
| ErrNoValidatorsInState = errors.New("no validators found in state") | ||
| // ErrNotProposer is used when the manager is not a proposer | ||
| ErrNotProposer = errors.New("not a proposer") | ||
| ) | ||
| // SaveBlockError is returned on failure to save block data | ||
| type SaveBlockError struct { | ||
| Err error | ||
| } | ||
| func (e SaveBlockError) Error() string { | ||
| return fmt.Sprintf("failed to save block: %v", e.Err) | ||
| } | ||
| func (e SaveBlockError) Unwrap() error { | ||
| return e.Err | ||
| } | ||
| // SaveBlockResponsesError is returned on failure to save block responses | ||
| type SaveBlockResponsesError struct { | ||
| Err error | ||
| } | ||
| func (e SaveBlockResponsesError) Error() string { | ||
| return fmt.Sprintf("failed to save block responses: %v", e.Err) | ||
| } | ||
| func (e SaveBlockResponsesError) Unwrap() error { | ||
| return e.Err | ||
| } | ||
Eoous marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -78,14 +78,6 @@ var initialBackoff = 100 * time.Millisecond | ||
| // DAIncludedHeightKey is the key used for persisting the da included height in store. | ||
| const DAIncludedHeightKey = "da included height" | ||
| var ( | ||
| // ErrNoValidatorsInState is used when no validators/proposers are found in state | ||
| ErrNoValidatorsInState = errors.New("no validators found in state") | ||
| // ErrNotProposer is used when the manager is not a proposer | ||
| ErrNotProposer = errors.New("not a proposer") | ||
| ) | ||
| // NewHeaderEvent is used to pass header and DA height to headerInCh | ||
| type NewHeaderEvent struct { | ||
| Header *types.SignedHeader | ||
| @@ -705,7 +697,7 @@ func (m *Manager) trySyncNextBlock(ctx context.Context, daHeight uint64) error { | ||
| } | ||
| err = m.store.SaveBlockData(ctx, h, d, &h.Signature) | ||
Eoous marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if err != nil { | ||
| return fmt.Errorf("failed to save block: %w", err) | ||
| return SaveBlockError{err} | ||
Eoous marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| _, _, err = m.executor.Commit(ctx, newState, h, d, responses) | ||
| if err != nil { | ||
| @@ -714,7 +706,7 @@ func (m *Manager) trySyncNextBlock(ctx context.Context, daHeight uint64) error { | ||
| err = m.store.SaveBlockResponses(ctx, hHeight, responses) | ||
Eoous marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if err != nil { | ||
| return fmt.Errorf("failed to save block responses: %w", err) | ||
| return SaveBlockResponsesError{err} | ||
Eoous marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| // Height gets updated | ||
| @@ -1061,7 +1053,7 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| header.Signature = *signature | ||
| err = m.store.SaveBlockData(ctx, header, data, signature) | ||
| if err != nil { | ||
| return err | ||
| return SaveBlockError{err} | ||
| } | ||
| } | ||
| @@ -1108,7 +1100,7 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| // SaveBlock commits the DB tx | ||
| err = m.store.SaveBlockData(ctx, header, data, signature) | ||
| if err != nil { | ||
| return err | ||
| return SaveBlockError{err} | ||
| } | ||
| // Commit the new state and block which writes to disk on the proxy app | ||
| @@ -1122,7 +1114,7 @@ func (m *Manager) publishBlock(ctx context.Context) error { | ||
| // SaveBlockResponses commits the DB tx | ||
| err = m.store.SaveBlockResponses(ctx, headerHeight, responses) | ||
| if err != nil { | ||
| return err | ||
| return SaveBlockResponsesError{err} | ||
| } | ||
| // Update the store height before submitting to the DA layer but after committing to the DB | ||
Uh oh!
There was an error while loading. Please reload this page.