Skip to content

Commit

Permalink
drop support for old-style Merkle txn root commitment (algorand#1883)
Browse files Browse the repository at this point in the history
This PR removes support for the Merkle transaction commitments that we used a long time ago (well before mainnet launch).
  • Loading branch information
zeldovich authored Feb 4, 2021
1 parent fb18ce7 commit d5097d3
Show file tree
Hide file tree
Showing 37 changed files with 138 additions and 2,068 deletions.
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 @@ -348,6 +347,20 @@ type ConsensusParams struct {
EnableAssetCloseAmount bool
}

// 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 @@ -622,7 +635,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

0 comments on commit d5097d3

Please sign in to comment.