-
Notifications
You must be signed in to change notification settings - Fork 224
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
Time
values are not always formatted correctly, causing the light client to sometimes return malformed light blocks
#774
Comments
romac
changed the title
Jan 7, 2021
Time
values are not formatted properly, causing the light client to return malformed light blocksTime
values are not always formatted correctly, causing the light client to someties return malformed light blocks
romac
changed the title
Jan 7, 2021
Time
values are not always formatted correctly, causing the light client to someties return malformed light blocksTime
values are not always formatted correctly, causing the light client to sometimes return malformed light blocks
5 tasks
This glitch was not caught by the Rust light client because light blocks are verified before they are stored in the light store (at which point they are serialized and the glitch occurs). On the other hand, the light client always fetches a block from the light store before returning it upon successful verification. |
thanethomson
added a commit
that referenced
this issue
Jan 9, 2021
Mainly focuses on fixing #774. Signed-off-by: Thane Thomson <connect@thanethomson.com>
thanethomson
added a commit
that referenced
this issue
Jan 11, 2021
* Release v0.17.1 Mainly focuses on fixing #774. Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update release date in CHANGELOG Signed-off-by: Thane Thomson <connect@thanethomson.com> * Fix year It is 2021, even though it may not feel like it. Signed-off-by: Thane Thomson <connect@thanethomson.com> * Update release date for v0.17.1 Signed-off-by: Thane Thomson <connect@thanethomson.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ancazamfir recently discovered that the Rust relayer would sometimes send malformed light blocks to the chain, eg. in a ClientUpdate message. The chain would then fail with the following error:
It appears that light blocks sometimes get corrupted when stored and retrieved from the LightStore, specifically the
signed_header.header.time
field:Because this field is part of the hash of the header, the chain would then compute a different hash than the commit's
last_block_id_hash
, yielding the error above.The problem stems from the custom
serde
serializer forTime
values, which is used byserde_cbor
to encode the light blocks as a byte array before storing them in thesled
-backed light store.I have tracked this to the custom RFC3339 formatter which we use to format
tendermint::Time
viatendermint_proto::serializers::timestamp::Timestamp
.This function incorrectly trims the leading zeros of the nanoseconds digits, which would break the
Time
-> String ->Time
roundtrip.For example, the date "2021-01-06T21:50:58.067816Z" is serialized as "2021-01-06T21:50:58.67816Z", which then decodes to "2021-01-06T21:50:58.678160Z", shifting the leading zero to the end.
This explains why this error pops up non-deterministically, as it requires a light block whose time would feature one or more zeros in its subseconds digits for the formatting to break.
The text was updated successfully, but these errors were encountered: