Cosmos-sdk: Allow Client State modifications via VerifyXYZ functions

Created on 11 May 2020  Â·  4Comments  Â·  Source: cosmos/cosmos-sdk

Summary


Verification functions need to be able modify ClientState in order to things like replay protection in the case of 06 solo machine

Problem Definition


Currently the ClientState interfaces only return an error so any modification to ClientState won't be persisted outside of the Verify function.

Proposal


VerifyXYZ functions should have the return signature (ClientState, error) and the verify functions in /03-connection/keeper/verify.go should call SetClientState before returning the error.

Should SetClientState still be called if the error retrieved is not nil. This would just be for debugging purposes, what would be more useful?


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned

Most helpful comment

I undrestand why this is necessary. Because we need to update the clientstate of solo machine after each successful signature verification to modify the sequence.

But it feels wrong from an interface level, to have the verify functions be stateful.

I wonder if there's a way to prevent a replay of the verify function for solo machines without making the verify interfaces stateful. @cwgoes

All 4 comments

I undrestand why this is necessary. Because we need to update the clientstate of solo machine after each successful signature verification to modify the sequence.

But it feels wrong from an interface level, to have the verify functions be stateful.

I wonder if there's a way to prevent a replay of the verify function for solo machines without making the verify interfaces stateful. @cwgoes

I wonder if there's a way to prevent a replay of the verify function for solo machines without making the verify interfaces stateful. @cwgoes

Hmm, not that I can think of that doesn't require a lot of additional functions (it would be possible to separate the verify functions into state changes & verifications which are stateless, but this would double the number of functions).

We can change the names to reflect the statefulness though, maybe "verifyXYZAndUpdateState" or "statefulVerifyXYZ"?

We can change the names to reflect the statefulness though, maybe "verifyXYZAndUpdateState" or "statefulVerifyXYZ"?

I don't think we need to rename functions as long as we document that client states can be stateful.

closed via #6202

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ValarDragon picture ValarDragon  Â·  3Comments

ValarDragon picture ValarDragon  Â·  3Comments

fedekunze picture fedekunze  Â·  3Comments

rigelrozanski picture rigelrozanski  Â·  3Comments

jackzampolin picture jackzampolin  Â·  3Comments