Skip to content
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

Implement PrecommitActions interface for Client type #4457

Closed
timwu20 opened this issue Jan 14, 2025 · 0 comments
Closed

Implement PrecommitActions interface for Client type #4457

timwu20 opened this issue Jan 14, 2025 · 0 comments
Assignees

Comments

@timwu20
Copy link
Contributor

timwu20 commented Jan 14, 2025

Issue Summary

Taken from design doc regarding PreCommitActions (link):

PreCommitActions is a trait that allows you to perform registered actions on block import and/or updated finality. The actions are performed before committing to the underlying db.

/// Callback invoked before committing the operations created during block import.
/// This gives the opportunity to perform auxiliary pre-commit actions and optionally
/// enqueue further storage write operations to be atomically performed on commit.
pub type OnImportAction<Block> =
	Box<dyn (Fn(&BlockImportNotification<Block>) -> AuxDataOperations) + Send>;

/// Callback invoked before committing the operations created during block finalization.
/// This gives the opportunity to perform auxiliary pre-commit actions and optionally
/// enqueue further storage write operations to be atomically performed on commit.
pub type OnFinalityAction<Block> =
	Box<dyn (Fn(&FinalityNotification<Block>) -> AuxDataOperations) + Send>;

/// Interface to perform auxiliary actions before committing a block import or
/// finality operation.
pub trait PreCommitActions<Block: BlockT> {
	/// Actions to be performed on block import.
	fn register_import_action(&self, op: OnImportAction<Block>);

	/// Actions to be performed on block finalization.
	fn register_finality_action(&self, op: OnFinalityAction<Block>);
}

For OnImportAction you receive a BlockImportNotification and you're expected to return AuxDataOperations which is already introduced in PR #4405. The AuxStore interface is already introduced and implemented by db.Backend.

The PreCommitActions trait/interface is not used by any BlockState or StorageState functionality. Rather it will be used for future work regarding BEEFY and GRANDPA.

Acceptance Criteria

  • Introduction of PreCommitActions interface
  • Implementation of PreCommitActions interface.
  • Tests

Other Information and useful links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants