|
1 | 1 | package config |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "maps" |
4 | 5 | "time" |
5 | 6 |
|
6 | 7 | "github.com/algorand/go-algorand-sdk/v2/protocol" |
@@ -558,6 +559,12 @@ type ConsensusParams struct { |
558 | 559 | // available. This parameters can be removed and assumed true after the |
559 | 560 | // first consensus release in which it is set true. |
560 | 561 | EnableInnerClawbackWithoutSenderHolding bool |
| 562 | + |
| 563 | + // AppSizeUpdates allows application update transactions to change |
| 564 | + // the extra-program-pages and global schema sizes. Since it enables newly |
| 565 | + // legal transactions, this parameter can be removed and assumed true after |
| 566 | + // the first consensus release in which it is set true. |
| 567 | + AppSizeUpdates bool |
561 | 568 | } |
562 | 569 |
|
563 | 570 | // ProposerPayoutRules puts several related consensus parameters in one place. The same |
@@ -669,6 +676,42 @@ type ConsensusProtocols map[protocol.ConsensusVersion]ConsensusParams |
669 | 676 | // consensus protocol. |
670 | 677 | var Consensus ConsensusProtocols |
671 | 678 |
|
| 679 | +// DeepCopy creates a deep copy of a consensus protocols map. |
| 680 | +func (cp ConsensusProtocols) DeepCopy() ConsensusProtocols { |
| 681 | + staticConsensus := make(ConsensusProtocols) |
| 682 | + for consensusVersion, consensusParams := range cp { |
| 683 | + // recreate the ApprovedUpgrades map since we don't want to modify the original one. |
| 684 | + consensusParams.ApprovedUpgrades = maps.Clone(consensusParams.ApprovedUpgrades) |
| 685 | + staticConsensus[consensusVersion] = consensusParams |
| 686 | + } |
| 687 | + return staticConsensus |
| 688 | +} |
| 689 | + |
| 690 | +// Merge merges a configurable consensus on top of the existing consensus protocol and return |
| 691 | +// a new consensus protocol without modify any of the incoming structures. |
| 692 | +func (cp ConsensusProtocols) Merge(configurableConsensus ConsensusProtocols) ConsensusProtocols { |
| 693 | + staticConsensus := cp.DeepCopy() |
| 694 | + |
| 695 | + for consensusVersion, consensusParams := range configurableConsensus { |
| 696 | + if consensusParams.ApprovedUpgrades == nil { |
| 697 | + // if we were provided with an empty ConsensusParams, delete the existing reference to this consensus version |
| 698 | + for cVer, cParam := range staticConsensus { |
| 699 | + if cVer == consensusVersion { |
| 700 | + delete(staticConsensus, cVer) |
| 701 | + } else { |
| 702 | + // delete upgrade to deleted version |
| 703 | + delete(cParam.ApprovedUpgrades, consensusVersion) |
| 704 | + } |
| 705 | + } |
| 706 | + } else { |
| 707 | + // need to add/update entry |
| 708 | + staticConsensus[consensusVersion] = consensusParams |
| 709 | + } |
| 710 | + } |
| 711 | + |
| 712 | + return staticConsensus |
| 713 | +} |
| 714 | + |
672 | 715 | // initConsensusProtocols defines the consensus protocol values and how values change across different versions of the protocol. |
673 | 716 | // |
674 | 717 | // These are the only valid and tested consensus values and transitions. Other settings are not tested and may lead to unexpected behavior. |
@@ -1331,6 +1374,8 @@ func initConsensusProtocols() { |
1331 | 1374 |
|
1332 | 1375 | vFuture.LogicSigVersion = 13 // When moving this to a release, put a new higher LogicSigVersion here |
1333 | 1376 |
|
| 1377 | + vFuture.AppSizeUpdates = true |
| 1378 | + |
1334 | 1379 | Consensus[protocol.ConsensusFuture] = vFuture |
1335 | 1380 |
|
1336 | 1381 | // vAlphaX versions are an separate series of consensus parameters and versions for alphanet |
|
0 commit comments