Skip to content
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

[Messages] Reception and confirmation times #267

Closed

Conversation

odesenfans
Copy link
Contributor

Added two new fields to the messages collection. We now store
the initial time of reception of a message in the reception_time
field, and the earliest on-chain confirmation time in
the confirmation_time field.

These fields will be used to order messages more precisely/securely
and to compute metrics, for example the propagation time of a message
on the network.

The time field of messages is now deprecated, as it is defined
by users and not signed. If you need the user time, use content.time.

@odesenfans
Copy link
Contributor Author

Depends on #265.

odesenfans and others added 10 commits September 26, 2022 14:20
Problem: web wallets do not allow signing raw messages. Instead,
they require binary payloads in a specific format.

Solution: support Micheline-style signatures, i.e. signatures
supported by wallets like Beacon.

Users can now use Micheline or raw signatures by specifying
the `signature.signingType` field to "micheline" or "raw".
By default, "raw" is assumed.

Co-authored-by: Mike Hukiewitz <70762838+MHHukiewitz@users.noreply.github.com>
Problem: if an invalid message somehow managed to reach
the pending message collection, the message would be retried
indefinitely logging exceptions on each run.

Solution: drop invalid messages.
Problem: some dependencies were missing from the requirements, and
letting pip sort it out led to dependency conflicts.

Solution: add the dependencies to setup.cfg.
Problem: the "/api/v0/posts.json" endpoint returns a 500 error
because of an invalid parameter being used in a function
(an attempt to remove the MongoDB object ID from the endpoint).

Solution: remove the object ID directly in the aggregate query.

Added a simple test to verify that the endpoint is at least working
a little bit.
Problem: the /api/v0/aggregates/{address}.json endpoint was not
tested enough.

Solution: add tests.
Use a Pydantic model instead of manual validation.
We now store the entire context of the transaction in the confirmations
array of messages. This means that two additional fields are now
preserved: the transaction block timestamp and the publisher.

As we need to re-fetch this data from chain data, a new migration
script resets the chain height to re-process all transactions.
We reset the confirmation status of all messages to unconfirmed
and deleted their confirmations array to let the node automatically
migrate to the new format.

Renamed some fields of the `TxContext` class in order to use
the same format in all DB collections and to avoid a breaking
change in the messages confirmation format.
Added two new fields to the messages collection. We now store
the initial time of reception of a message in the `reception_time`
field, and the earliest on-chain confirmation time in
the `confirmation_time` field.

These fields will be used to order messages more precisely/securely
and to compute metrics, for example the propagation time of a message
on the network.

The `time` field of messages is now deprecated, as it is defined
by users and not signed. If you need the user time, use `content.time`.
@hoh hoh self-requested a review October 13, 2022 14:21
@odesenfans odesenfans marked this pull request as ready for review October 13, 2022 14:21
@odesenfans odesenfans assigned hoh and unassigned odesenfans Oct 13, 2022
tests/chains/test_confirmation.py Show resolved Hide resolved
try:
updates[k].update(v)
except KeyError:
updates[k] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is just merging dictionaries ?

updates.update(confirmation_updates)

https://docs.python.org/3/library/stdtypes.html#dict.update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's merging two dicts of dicts. Could be written a bit cleaner, maybe.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Yes, there should be a cleaner way. Else at least a dedicated testable function to do just that.

@odesenfans
Copy link
Contributor Author

Integrated in work on Postgres.

@odesenfans odesenfans closed this Apr 24, 2023
@odesenfans odesenfans deleted the od-introduce-new-time-fields branch April 24, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants