-
Notifications
You must be signed in to change notification settings - Fork 586
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
imp: remove timestamp
from consensusState
and query contract to retrieve it
#4034
imp: remove timestamp
from consensusState
and query contract to retrieve it
#4034
Conversation
…om-consensusstate-and-query-contract-to-retrieve-it
type metadataQueryResponse struct { | ||
contractResult | ||
GenesisMetadata []clienttypes.GenesisMetadata `json:"genesis_metadata"` | ||
} | ||
|
||
type timestampAtHeightQueryResponse struct { | ||
contractResult | ||
Timestamp uint64 `json:"timestamp"` | ||
} | ||
|
||
type CheckForMisbehaviourExecuteResult struct { | ||
contractResult | ||
FoundMisbehaviour bool `json:"found_misbehaviour"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these types for the different query results that we obtain.
} | ||
|
||
// wasmQuery queries the contract with the given payload and writes the result to output. | ||
func wasmQuery[T ContractResult](ctx sdk.Context, clientStore sdk.KVStore, cs *ClientState, payload any) (T, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this function (which is very similar to call
above) to wrap the query call to the contract. Since the query (still to be added) to return the timestamp at a certain height (with payload of type timestampAtHeightQueryResponse
) might return an error if there's no consensus at that given height, I thought that we can also check the result and wrap the error if there's any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to named this function like this and not query
, because query
conflicted with another function defined in a package in the SDK that is also in scope. I will probably rename call
above to wasmExecute
, for consistency.
…om-consensusstate-and-query-contract-to-retrieve-it
@@ -24,15 +22,11 @@ func (cs ConsensusState) ClientType() string { | |||
|
|||
// GetTimestamp returns block time in nanoseconds of the header that created consensus state. | |||
func (cs ConsensusState) GetTimestamp() uint64 { | |||
return cs.Timestamp | |||
return 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we query the contract in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the idea is that we will mark this function as deprecated, since it is only used in the light clients, so it doesn't need to be part of the ConsensusState
interface. In the meantime, until we remove it, we will just return 0.
* Use hasConsensusState instead of GetConsensusState.
* Use wasmQuery for the rest of the query functions. --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
…om-consensusstate-and-query-contract-to-retrieve-it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving my approval, left some suggestions 👍
type ( | ||
timestampAtHeightInnerPayload struct { | ||
Height exported.Height `json:"height"` | ||
} | ||
timestampAtHeightPayload struct { | ||
TimestampAtHeight timestampAtHeightInnerPayload `json:"timestamp_at_height"` | ||
} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also superseded by #4133, right?
I'd like to not use type
blocks, e.g.:
type (
someType struct {}
someOtherType struct {}
)
instead:
type someType struct {}
type someOtherType struct {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my own understanding: what's wrong with type
blocks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chatton doesn't like them! 😆
I think I have similar feelings!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I don't want to get @chatton angry, so...
|
||
// wasmQuery queries the contract with the given payload and writes the result to output. | ||
func wasmQuery[T ContractResult](ctx sdk.Context, clientStore sdk.KVStore, cs *ClientState, payload any) (T, error) { | ||
var output T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this output
, result
, or response
?
I see these three different terms being used interchangeably in a lot of places, we be good to standardise on one.
I'm happy enough with result
/ ContractResult
, response
or ContractResponse
is also fine imo! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some renaming.
Timestamp uint64 `json:"timestamp"` | ||
} | ||
|
||
type checkForMisbehaviourExecuteResult struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be checkForMisbehaviourReponse
or? how come the different naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed as well.
type statusQueryResponse struct { | ||
contractResult | ||
Status exported.Status `json:"status"` | ||
} | ||
|
||
type metadataQueryResponse struct { | ||
contractResult | ||
GenesisMetadata []clienttypes.GenesisMetadata `json:"genesis_metadata"` | ||
} | ||
|
||
type timestampAtHeightQueryResponse struct { | ||
contractResult | ||
Timestamp uint64 `json:"timestamp"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #4133 all the contract payload types are in msgs.go right? Should these be included alongside them?
Even tho they are unexported, would be nice to have basic godocs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add them in #4133.
* Add linting for 08-wasm. * Go mod tidy. * Please the linter.
* add 08-wasm global store key * Update client_state.go * Update modules/light-clients/08-wasm/types/vm.go Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com> --------- Co-authored-by: Jim Fasarakis-Hilliard <d.f.hilliard@gmail.com>
…om-consensusstate-and-query-contract-to-retrieve-it
Description
Still work in progress, since we need new versions of the contracts supporting the query to get the timestamp at a certain height. Tests are expected to fail.
closes: #3957
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.