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

drop support for old-style Merkle txn root commitment #1883

Merged
merged 7 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ type ConsensusParams struct {
FastRecoveryLambda time.Duration // time between fast recovery attempts
FastPartitionRecovery bool // set when fast partition recovery is enabled

// commit to payset using a hash of entire payset,
// instead of txid merkle tree
PaysetCommitFlat bool
// how to commit to the payset: flat or merkle tree
PaysetCommit PaysetCommitType

MaxTimestampIncrement int64 // maximum time between timestamps on successive blocks

Expand Down Expand Up @@ -344,6 +343,20 @@ type ConsensusParams struct {
CompactCertSecKQ uint64
}

// PaysetCommitType enumerates possible ways for the block header to commit to
// the set of transactions in the block.
type PaysetCommitType int

const (
// PaysetCommitUnsupported is the zero value, reflecting the fact
// that some early protocols used a Merkle tree to commit to the
// transactions in a way that we no longer support.
PaysetCommitUnsupported PaysetCommitType = iota

// PaysetCommitFlat hashes the entire payset array.
PaysetCommitFlat
)

// ConsensusProtocols defines a set of supported protocol versions and their
// corresponding parameters.
type ConsensusProtocols map[protocol.ConsensusVersion]ConsensusParams
Expand Down Expand Up @@ -618,7 +631,7 @@ func initConsensusProtocols() {
// v11 introduces SignedTxnInBlock.
v11 := v10
v11.SupportSignedTxnInBlock = true
v11.PaysetCommitFlat = true
v11.PaysetCommit = PaysetCommitFlat
v11.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}
Consensus[protocol.ConsensusV11] = v11

Expand Down
12 changes: 6 additions & 6 deletions config/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import (
func TestConsensusParams(t *testing.T) {
for proto, params := range Consensus {
// Our implementation of Payset.Commit() assumes that
// SupportSignedTxnInBlock implies PaysetCommitFlat.
if params.SupportSignedTxnInBlock && !params.PaysetCommitFlat {
t.Errorf("Protocol %s: SupportSignedTxnInBlock without PaysetCommitFlat", proto)
// SupportSignedTxnInBlock implies not PaysetCommitUnsupported.
if params.SupportSignedTxnInBlock && params.PaysetCommit == PaysetCommitUnsupported {
t.Errorf("Protocol %s: SupportSignedTxnInBlock with PaysetCommitUnsupported", proto)
}

// ApplyData requires PaysetCommitFlat.
if params.ApplyData && !params.PaysetCommitFlat {
t.Errorf("Protocol %s: ApplyData without PaysetCommitFlat", proto)
// ApplyData requires not PaysetCommitUnsupported.
if params.ApplyData && params.PaysetCommit == PaysetCommitUnsupported {
t.Errorf("Protocol %s: ApplyData with PaysetCommitUnsupported", proto)
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions crypto/merkle/README

This file was deleted.

26 changes: 0 additions & 26 deletions crypto/merkle/common.go

This file was deleted.

46 changes: 0 additions & 46 deletions crypto/merkle/hashers/tree_hasher.go

This file was deleted.

Loading