-
Notifications
You must be signed in to change notification settings - Fork 19
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] Preserve original message time #254
[Messages] Preserve original message time #254
Conversation
Can you detail the inversion of order and its consequences ? |
@hoh done, updated the description. |
Mhh... The idea here is that the user specified time can't be trusted for message ordering. While the block inclusion order is in essence set in stone. |
I thought about that, but as long as the time field is signed, it just represents the ordering desires of the user. The user can then mess with his own data, but not much besides that (at the moment). IMO we should keep track of both times: the time represents the order desired by the user, and the confirmation time can be used to detect malicious intent (ex: a message with a time field way in the past appearing in a recent block). This solution at least avoids the introduction of a nonce/sequence ID, which can be a bit impractical. |
The issue is that we use that time in queries ordering... Also across multiple users. |
I wasn’t aware this kind of mechanism was in place for the staking rewards,
I see the issue. That being said, inverting user messages is also gonna be
an issue.
Several ideas to mitigate this:
* keep both values around, keep them semantically different. We could
separate the message.time field in a « user time » and a « rx time »
fields. The rx time could then be set to the CCN time when the message
arrives and to the block time once it is confirmed. This way we keep all
the info around, even after a FORGET (we currently lose the user time on
FORGET). Aggregates can then use this rx time.
* propagate the confirmed/unconfirmed nature of messages when using
aggregates. Ex: an aggregate using an unconfirmed message should be marked
as « unconfirmed » until all the messages it uses are confirmed.
* for aggregates targeting a single address, we can use the user time field
directly.
|
Fixed an issue where the CCN would overwrite the original "time" field of the message by the time at which the message is confirmed on-chain. This issue could result in inversions of order between messages if two consecutive messages arrive in the opposite order on the node in charge of confirming messages. Added a migration script to reset the message time field using the content.time field. The migration script does not update forgotten messages as their content is null. The extra effort to update these messages is not worth it given that it requires to parse the whole chain data history for a few tens of messages.
44a6c60
to
a450a14
Compare
So, here's my plan on the topic.
This is not high-priority at the moment though, so I see it more as a background discussion. What do you think @moshemalawach @hoh? |
Shouldn't we use the timestamp of the chain block instead of the timestamp of when the message was received by the node in that case ? That is not only set in stone but difficult to lie on. I am especially thinking about when multiple CCNs will write on chains. This would give:
When time may not be falsified, we should use Regarding the user creation time for forgotten messages, I think we should not save it. Deleted content is deleted content, and we have other timestamps we can use when needed. |
After discussion with @odesenfans , the idea would be to:
|
Regarding the implementation, I think it will make more sense if we merge
|
We may not want to expose the |
Replaced by #267. |
Fixed an issue where the CCN would overwrite the original "time"
field of the message by the time at which the message is confirmed
on-chain. This issue could result in inversions of order between
messages if two consecutive messages arrive in the opposite order
on the node in charge of confirming messages.
Example: A user sends two messages at time T and T+1.
If these messages are processed in a different order because of
a different routing on the network, the node in charge of pushing
data on-chain could receive the message sent at T+1 before
receiving the message T. This CCN could then end up publishing
the message sent at T+1 in on-chain block B and the message
sent at T in block B+1. On reception of the TX, the CCNs would
then overwrite the time field with the timestamp of the block,
inverting the order intended by the user.
Added a migration script to reset the message time field using
the content.time field. The migration script does not update
forgotten messages as their content is null. The extra effort
to update these messages is not worth it given that it requires
to parse the whole chain data history for a few tens of messages.