-
Notifications
You must be signed in to change notification settings - Fork 699
feat: clarity block connection depend on backing store interface #6404
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
base: develop
Are you sure you want to change the base?
feat: clarity block connection depend on backing store interface #6404
Conversation
52e8c4e
to
02ce543
Compare
PR #6365 already has an ephemeral |
This is not an ephemeral WritableMarfStore implementation; it removes the dependency on concrete implementations. |
This is what I have in mind to support using ephemeral storage (I copied your implementation of By removing the dependency to specific implementation, it's easier to add and use different implementation. |
Yes, I understand that. Forgive me if this is asking you to repeat something you may have explained to someone else, but can you provide us with some context on why you want to add a |
You mean In STXER, we do have another overlay implementation for Another reason I prefer trait over |
Hi @bestmike007,
No one is questioning this in principle. What I'm questioning is whether or not the proposed trait in this PR represents the right abstraction for addressing the problem(s) at hand. It's a question we need to answer before merging, because a
Thank you for this; this is useful context. Now with this application and other potential applications in mind, let's look at the trait definition itself: pub trait ClarityBackingStoreTransaction: ClarityBackingStore {
fn rollback_block(self: Box<Self>);
fn rollback_unconfirmed(self: Box<Self>) -> Result<()>;
fn commit_to(self: Box<Self>, final_bhh: &StacksBlockId) -> Result<()>;
fn commit_unconfirmed(self: Box<Self>);
fn commit_mined_block(self: Box<Self>, will_move_to: &StacksBlockId) -> Result<()>;
fn seal(&mut self) -> TrieHash;
} Given this context, I'm not convinced that this represents a useful level of abstraction to represent writes against a Clarity backing store. In general, this abstraction is tightly coupled to implementation decisions in the Stacks node that aren't relevant to these possible applications. Specifically:
That all said, I'm still very interested in helping make it easier for STXER to use its own Clarity storage implementation. We just need to come up with the right abstraction that won't couple STXER to Stacks implementation details :) |
I could be wrong but I'm thinking differently. This trait abstract the abilities that stacks implementation required in order to process blocks and transactions. So it is tightly coupled to stacks implementation decisions, possible applications are not supposed to use it directly, they implement the trait so that they can reuse the logic in stackslib. However, I agree with you that it might not be a useful level of abstraction, functions defined in the trait cover different code paths in the stacks implementation. A specific application might not need to implement all of them based on the usage, for example if I'm not running a miner then I probably don't need to implement |
@bestmike007, is there a link to the comment(s)/discussion? |
A (more robust) alternative is having many smaller traits, each describing one role vs having fewer/bigger header interfaces which are hard to evolve (add/removing, or changing methods tends to break downstream code). |
@moodmosaic we talked on Signal, so no links. @aldur was asking if I had more ideas to improve stacks and the ecosystem, and here's what I responded:
|
I thought about this as well, but |
I tend to keep PRs small, so consider this a small step toward the bigger goal. |
I think I disagree with this -- we have many traits throughout the codebase, and we change them without too much thought as to how it might impact downstream dependencies. While I agree that it may be disruptive to people who depend on those traits, it doesn't seem to have generated much push back when we've done so previously. We could think about changing policies regarding trait changes, but I don't think we need to do that now, nor do I think that we need to evaluate this PR in the context of such a change. Basically: there are already traits in the codebase, we already change them if they don't fit their purpose (or the interface changes), and so I don't think we should apply that standard to this PR.
Yes, I think adding comments to the trait functions would help in these cases, but overall I agree with you about the level of abstraction in this trait: the trait is meant to capture the interface between the VM and the block processing, so of course it will end up pretty closely tied to the implementation we have today. Overall, I'm perfectly happy with the approach this PR has taken so far. If we want to iterate on the trait definition, I think we can do that in follow up PRs and should do so without too much worry about downstream implementors. If it gets to be way too much thrashing, people can complain and then we can come up with a better policy for handling trait changes, but until that happens, I'd rather we have this trait than work through implementations that use enums. |
That's because the principal consumers of these traits have tended to be other modules within
The difference between then and now is that this PR would treat this trait as a public API within That said, I am generally supportive of this goal. I'm just asking that if we are to go down this path, we think carefully about what these well-defined abstractions and interfaces will be, since it won't be just @bestmike007 I can spend some time working with you on this. |
Thanks @jcnelson!
I completely agree — this PR is just a small step in that direction.
That’s a fair point. I’d note that STXER has already implemented the existing That said, I don’t think this trait should be considered a finalized “public API” yet. I agree we should be deliberate about the abstractions. Do you already have a better trait definition (or direction) in mind? |
Description
Previously
ClarityBlockConnection
andClarityReadonlyConnection
are depending on concrete implementation of theClarityBackingStore
trait.In this PR, a
ClarityBackingStoreTransaction
trait is introduced, andClarityBlockConnection
andClarityReadonlyConnection
are changed to depend on interfaces rather than implementations.This will be very helpful to extended use cases to reuse block consensus logic, e.g. implementing an ephemeral
WritableMarfStore
for simulation.Checklist
docs/rpc/openapi.yaml
andrpc-endpoints.md
for v2 endpoints,event-dispatcher.md
for new events)clarity-benchmarking
repobitcoin-tests.yml