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

[refactor]: remove signatures from blocks #4384

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mversic
Copy link
Contributor

@mversic mversic commented Mar 25, 2024

Description

  • remove signatures from blocks stored on chain
    Signatures are transient and only applicable during consensus. Since blocks in a blockchain are tied together via block hashes, keeping block signatures after consensus is not only superfluous but also creates issues when replaying blocks when topology has changed (related to How to update peer's blockstore when the whole topology changed #4145)
  • removed consensus_estimation from block header - it was unused
  • removed event_recommendations from block - it was unused

Future work

  • Following this PR, block sync protocol should be modified to prevent syncing with malicious peers. This can be done with not too much overhead

Checklist

  • I've read CONTRIBUTING.md
  • I've used the standard signed-off commit format (or will squash just before merging)
  • All applicable CI checks pass (or I promised to make them pass later)
  • (optional) I've written unit tests for the code changes
  • I replied to all comments after code review, marking all implemented changes with thumbs up

Signed-off-by: Marin Veršić <marin.versic101@gmail.com>
@github-actions github-actions bot added Refactor Improvement to overall code quality iroha2-dev The re-implementation of a BFT hyperledger in RUST labels Mar 25, 2024
Copy link
Contributor

@Erigara Erigara left a comment

Choose a reason for hiding this comment

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

I don't think we can get rid of storing block's signatures.
Because this way we forcing a new peer who is joining the network to trust that blocks are valid without ability to verify that.

Since blocks in a blockchain are tied together via block hashes

Without signatures malicious peer can provide any blockchain sequence it want.

@mversic
Copy link
Contributor Author

mversic commented Mar 25, 2024

I don't think we can get rid of storing block's signatures, because otherwise we force peer who is joining network to trust that blocks are valid.

Since blocks in a blockchain are tied together via block hashes

Without signatures malicious peer can provide any blockchain sequence it want.

yes, but that's only a matter of block sync as I mentioned in the description. This can be taken care of like this:

  1. new node joins the network
  2. new node broadcasts request to get hash of the next block to all peers
  3. it collects responses and is now confident in what the next block is (every response is signed by the corresponding peer)
  4. sends a request to one of the peers to get the actual block
  5. validates that hash of the block is as expected
  6. applies the block

or some more optimized version of this

@mversic
Copy link
Contributor Author

mversic commented Mar 25, 2024

@Erigara the point is that node needs to contact the network, not just one peer when doing block sync because it cannot trust one node. So it asks the network what the hash of the next block is before requesting next block via block sync

@Erigara
Copy link
Contributor

Erigara commented Mar 25, 2024

This makes block synchronization much more complex.

And also vulnerable to cases where suppose that only one peer left of the whole topology for some reason.

With signatures (and initial set of peers) we still have an ability to check that blocks are valid, without them there is no way.

@mversic
Copy link
Contributor Author

mversic commented Mar 25, 2024

This makes block synchronization much more complex.

somewhat more complex. This is why block sync should be avoided if possible. This change shouldn't increase network traffic by a noticeable amount (just circling some extra hashes)

And also vulnerable to cases where suppose that only one peer left of the whole topology for some reason.

even in the current implementation this lone peer could put anything in the signature set and compromise the blockchain. Note that genesis_private_key only signs genesis transactions, it doesn't sign genesis block. Genesis block is signed by a peer so we have to trust this peer to put correct signatures in the block.

With signatures (and initial set of peers) we still have an ability to check that blocks are valid, without them there is no way.

this is not true again, or true only superficially. As in the previous example, new peer has to trust the peer it's connecting to because that peer can manipulate signatures of the genesis block. With the current approach, new peer trusts the one peer from trusted_peers it connects to. With new approach at least this trust is dispersed among all peers of the trusted_peers set.

@Erigara
Copy link
Contributor

Erigara commented Mar 25, 2024

even in the current implementation this lone peer could put anything in the signature set and compromise the blockchain. Note that genesis_private_key only signs genesis transactions, it doesn't sign genesis block. Genesis block is signed by a peer so we have to trust this peer to put correct signatures in the block.

Good point.
I didn't say that current implementation is flawless (far from that).
So current vector of attack is to replace committed_topology of genesis block with only this peer.
Then this peer can produce any block he wants.
Afaik this could be fixed by signing genesis block and inclusion of initial topology public keys into genesis (maybe just inserting them as ISIs?).

After that malicious peer can't mess up with topology because every inclusion or deletion of peer is recorded within transactions ((Un)Register<Peer>).

somewhat more complex. This is why block sync should be avoided if possible. This change shouldn't increase network traffic by a noticeable amount (just circling some extra hashes)

Agree about noticeable amount. I'm more concerned about implementing quorum algorithm for that.

or true only superficially

Yeah, this example is kinda handcrafted but i want to be extra-careful when talking about compromising the whole chain.

All in all i'm suggesting to investigate this question more deeply.
Maybe removal of signatures is fine and i'm just extra cautious.

@mversic
Copy link
Contributor Author

mversic commented Mar 26, 2024

Afaik this could be fixed by signing genesis block and inclusion of initial topology public keys into genesis (maybe just inserting them as ISIs?).

this seems like it would do the trick, except that we should make sure genesis consists of exactly 1 transaction so that the peer submitting genesis cannot remove or reorder any

All in all i'm suggesting to investigate this question more deeply. Maybe removal of signatures is fine and i'm just extra cautious.

ofc. I'd like this to be thoroughly considered. I'm not that convinced myself

@nxsaken nxsaken changed the base branch from iroha2-dev to main April 16, 2024 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iroha2-dev The re-implementation of a BFT hyperledger in RUST Refactor Improvement to overall code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants