Concordium / concordium-node

The main concordium node implementation.
GNU Affero General Public License v3.0
45 stars 22 forks source link

BlockInfo: Milliseconds precision. #360

Closed MilkywayPirate closed 2 years ago

MilkywayPirate commented 2 years ago

block receive and block arrive timestamps currently only have precision in seconds which is too coarse, in particular it is not currently useful for calculating block execution timings.

Instead they should provide milliseconds precision.

abizjak commented 2 years ago

It is actually a bit more subtle than that. For non-finalized blocks you get nanosecond precision.

For finalized blocks that are not the last finalized blocks you get the rounded value.

Example with the same block

./cc --grpc-ip concordiumwalletnode.com raw GetBlockInfo c9e52e111a48077859b60e52e0cba02b3fe3e0ca4f7fa78b724f9207da0e5819
{
    "transactionsSize": 0,
    "blockParent": "7e38db30a44582e81d8904fb2305068ed1a9114586aa336c38a38a1585cfc97b",
    "eraBlockHeight": 1137341,
    "blockHash": "c9e52e111a48077859b60e52e0cba02b3fe3e0ca4f7fa78b724f9207da0e5819",
    "finalized": true,
    "genesisIndex": 2,
    "blockStateHash": "912460677cb2eee13ba245648478b8e8f078c515649c5cadb81f88309ab6968e",
    "blockArriveTime": "2022-05-25T06:00:38.484953269Z",
    "blockReceiveTime": "2022-05-25T06:00:38.477717229Z",
    "transactionCount": 0,
    "transactionEnergyCost": 0,
    "blockSlot": 46238536,
    "blockLastFinalized": "70d8d5c14fda56a068fc00a13be58e9b64b0b577b4732100e3e07f2b7d313f27",
    "blockSlotTime": "2022-05-25T06:00:37.75Z",
    "blockHeight": 2986128,
    "blockBaker": 5
}
➜  concordium-client git:(main) ✗ ./cc --grpc-ip concordiumwalletnode.com raw GetBlockInfo c9e52e111a48077859b60e52e0cba02b3fe3e0ca4f7fa78b724f9207da0e5819
{
    "transactionsSize": 0,
    "blockParent": "7e38db30a44582e81d8904fb2305068ed1a9114586aa336c38a38a1585cfc97b",
    "eraBlockHeight": 1137341,
    "blockHash": "c9e52e111a48077859b60e52e0cba02b3fe3e0ca4f7fa78b724f9207da0e5819",
    "finalized": true,
    "genesisIndex": 2,
    "blockStateHash": "912460677cb2eee13ba245648478b8e8f078c515649c5cadb81f88309ab6968e",
    "blockArriveTime": "2022-05-25T06:00:38Z",
    "blockReceiveTime": "2022-05-25T06:00:38Z",
    "transactionCount": 0,
    "transactionEnergyCost": 0,
    "blockSlot": 46238536,
    "blockLastFinalized": "70d8d5c14fda56a068fc00a13be58e9b64b0b577b4732100e3e07f2b7d313f27",
    "blockSlotTime": "2022-05-25T06:00:37.75Z",
    "blockHeight": 2986128,
    "blockBaker": 5
}

What we need to change is how the BasicBlockPointerData is stored so that serialization of the time stores it either in milliseconds or more fine-grained. This can easily be done without breaking backwards compatibility of the LMDB database or any migration.

abizjak commented 2 years ago

This is a duplicate of https://github.com/Concordium/concordium-node/issues/99