-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactor BlockHeader #228
Refactor BlockHeader #228
Conversation
794fdc7
to
ecd2939
Compare
ecd2939
to
dae65a3
Compare
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 don't mind this change but we need an upgrade path that is not a panic due to the changed encoding. We can't stable release renterd
(or any node software really) with the new core consensus if every update of the core dependency potentially causes a panic and requires manual user interaction.
I'm not sure I follow. Do you mean that this change breaks existing v2 testnets? Or that SiaFoundation/coreutils#116 breaks existing |
I think the primary concern is that a few other recent PRs broke existing We do currently have a problem in the apps that use the coreutils chain db where we can't release an update without requiring manual intervention on the consensus database. It's been a particular pain on our test nodes that auto update 😅. That probably doesn't need to be tackled in either of these open PR, but it will need to be solved in a follow up at some point soon as we're looking to push out v2.0.0 EoY.
|
It does look like we'll break syncing on Anagami since the V2BlockHeader encoding is changing, but I think that's acceptable. |
Fair, I have been pretty cavalier about consensus changes lately. 😅 I'll try to rein it in as we approach release. And yeah, changes to network stuff are less bothersome, since they'll resolve themselves once enough people update. |
This unifies v1 and v2 block headers and promotes
BlockHeader
fromgateway
totypes
. It also changes how V2 block IDs are computed.I had previously omitted the
ParentID
from the v2 block "header," because it is incorporated into theCommitment
field (via the hash of the parentconsensus.State
). This left the first 32 bytes of the 80-byte hash preimage unused, so I filled them with a distinguisher string.However, after reflecting on how headers are actually used in the Syncer, I think it's better to include the
ParentID
after all, even if it's slightly redundant and not strictly necessary. Here's my reasoning, in the form of a dialogue:ParentID
, you could check that it matched your current block before abandoning it.ParentID
doesn't prevent this class of attack, because the purported block could be invalid for other reasons that aren't detectable from the header alone. For example, it could have missing signatures. Moreover, this attack requires the attacker to expend a lot of hashrate; why wouldn't they use that hashrate to mine a valid block instead?ParentID
is different! You don't need to expend a lot of hashrate mining a purposefully-invalid block; instead, you can reuse the header of a recently-mined block. That header will (probably) still have sufficient proof-of-work to meet the current target, so it will pass the initial validation check.ParentID
anyway. We weren't using that space anyway (but we need to preserve it, for miner compatibility), it's occasionally useful, and you don't need to twist your brain into knots convincing yourself that the system is still secure without it.