-
Notifications
You must be signed in to change notification settings - Fork 97
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 ADR05 (Handlers validation and execution separation) #221
Comments
Maybe I'm missing something, but how does separating validation and execution work with the common cases of how IBC is used today (cc @avahowell)? Specifically, it's common to create a transaction that (1) updates a client and then (2) relays a message that was included in the newly updated state. If validation and execution are completely separate, with all validation checks occurring prior to any execution checks, than it's not possible to do this, because the message in (2) has to be validated against the client state prior to executing (1), which will fail validation. Avoiding this means either (a) splitting client updates and relayed messages into separate transactions, and coordinating with the block proposer to correctly order them within the block, or [more likely] (b) adding an additional 1-block latency for relayed IBC messages. In Penumbra, we actually started with a state model that fully separated validation and execution, but ended up moving away from it because it didn't work with our IBC implementation for this reason, so I'm curious if there's a solution we missed. (We now have a three-phase execution model, with |
This indeed won't work; you always need to run the validation and execution before moving on to the next message/transaction. The only architecture we know of today that makes use of this distinction is Namada. For each transaction in the block, they:
|
Yes, that's what I meant, sorry, I should have phrased it more clearly as "with all validation checks (for a specific transaction) occurring prior to any execution (for that specific transaction).
We also make use of this architecture in Penumbra to do parallel checks, but your comment highlights the key difference, which is that we perform validation prior to execution, and they perform validation after execution. Running validation after execution rather than before does seem like a solution to this problem, so that answers my question, thanks! |
Now I'm confused!
Do you assume a model where a transaction holds many messages (similar to how the SDK does it? Note that Namada has only one message per transaction. The mental model I was using here was "one message per transaction". So when you say:
I think of this as 2 "transactions". In your case, it would be: first run all the validation checks for the Hence, in this model, for what IBC is concerned, either validation or execution could be run first without affecting correctness (since our validation functions don't look at what execution did). The reason Namada does it like that is roughly that execution is actually untrusted code, and so they want to make sure that execution actually did the right thing (in a separate validity predicate). Or am I missing something? |
@plafer impl validator<Ctx: RouterContext> {
pub fn validate(&self, ctx: &mut Ctx) -> Result<(), Error>;
}
impl executor<Ctx: RouterContext> {
pub fn execute(&self, ctx: &mut Ctx) -> Result<(), Error>;
}
// consider it for MsgCreateClient
impl validator<MockContext> for MsgCreateClient {...}
impl executor<MockContext> for MsgCreateClient {...} It looks more modular, maintainable, and extensible if it works! (please direct me to the places if I am missing something. tnx) |
Closing as done, even though we didn't implement the host-based API. If we think it is still relevant, we can implement it in the future. |
Summary
Complete ADR05 implementation -> adr-005-handlers-redesign.md
ValidationContext
andExecutionContext
for clients (ICS-2) #240ValidationContext
andExecutionContext
for connections (ICS-3) #251ValidationContext
andExecutionContext
for channels (ICS-4) #252For Admin Use
The text was updated successfully, but these errors were encountered: