Skip to content

Commit

Permalink
Merge branch 'release/v2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Algo-devops-service committed Dec 15, 2023
2 parents fcc30ce + b666698 commit 5fd2c1c
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 23 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# v2.4.0

<!-- Release notes generated using configuration in .github/release.yml at release/v2.4.0 -->

## What's Changed
### Enhancements
* protocol: Add block hash to state proof's LightBlockHeader by @zeldovich in https://github.com/algorand/go-algorand-sdk/pull/589
* Consensus Config: Add period 0 deadline timeout parameter to consensus params. by @gmalouf in https://github.com/algorand/go-algorand-sdk/pull/618
* Consensus: Update consensus files for v39 along with types sync. by @gmalouf in https://github.com/algorand/go-algorand-sdk/pull/621
### Other
* Regenerate code with the latest specification file (b5adad95) by @github-actions in https://github.com/algorand/go-algorand-sdk/pull/620

## New Contributors
* @zeldovich made their first contribution in https://github.com/algorand/go-algorand-sdk/pull/589

**Full Changelog**: https://github.com/algorand/go-algorand-sdk/compare/v2.3.0...v2.4.0

# v2.3.0

## What's Changed
Expand Down
10 changes: 10 additions & 0 deletions client/v2/common/models/simulation_transaction_exec_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ type SimulationTransactionExecTrace struct {
// a clear state program.
ClearStateProgramTrace []SimulationOpcodeTraceUnit `json:"clear-state-program-trace,omitempty"`

// ClearStateRollback if true, indicates that the clear state program failed and
// any persistent state changes it produced should be reverted once the program
// exits.
ClearStateRollback bool `json:"clear-state-rollback,omitempty"`

// ClearStateRollbackError the error message explaining why the clear state program
// failed. This field will only be populated if clear-state-rollback is true and
// the failure was due to an execution error.
ClearStateRollbackError string `json:"clear-state-rollback-error,omitempty"`

// InnerTrace an array of SimulationTransactionExecTrace representing the execution
// trace of any inner transactions executed.
InnerTrace []SimulationTransactionExecTrace `json:"inner-trace,omitempty"`
Expand Down
91 changes: 86 additions & 5 deletions protocol/config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ type ConsensusParams struct {
// time for nodes to wait for block proposal headers for period = 0, value should be configured to suit best case
// critical path
AgreementFilterTimeoutPeriod0 time.Duration
// Duration of the second agreement step for period=0, value should be configured to suit best case critical path
AgreementDeadlineTimeoutPeriod0 time.Duration

FastRecoveryLambda time.Duration // time between fast recovery attempts

Expand Down Expand Up @@ -400,6 +402,11 @@ type ConsensusParams struct {
// their account balances.
StateProofExcludeTotalWeightWithRewards bool

// StateProofBlockHashInLightHeader specifies that the LightBlockHeader
// committed to by state proofs should contain the BlockHash of each
// block, instead of the seed.
StateProofBlockHashInLightHeader bool

// EnableAssetCloseAmount adds an extra field to the ApplyData. The field contains the amount of the remaining
// asset that were sent to the close-to address.
EnableAssetCloseAmount bool
Expand Down Expand Up @@ -581,6 +588,42 @@ var MaxAvailableAppProgramLen int
// to be taken offline, that would be proposed to be taken offline.
var MaxProposedExpiredOnlineAccounts int

// MaxAppTotalArgLen is the maximum number of bytes across all arguments of an application
// max sum([len(arg) for arg in txn.ApplicationArgs])
var MaxAppTotalArgLen int

// MaxAssetNameBytes is the maximum asset name length in bytes
var MaxAssetNameBytes int

// MaxAssetUnitNameBytes is the maximum asset unit name length in bytes
var MaxAssetUnitNameBytes int

// MaxAssetURLBytes is the maximum asset URL length in bytes
var MaxAssetURLBytes int

// MaxAppBytesValueLen is the maximum length of a bytes value used in an application's global or
// local key/value store
var MaxAppBytesValueLen int

// MaxAppBytesKeyLen is the maximum length of a key used in an application's global or local
// key/value store
var MaxAppBytesKeyLen int

// StateProofTopVoters is a bound on how many online accounts get to
// participate in forming the state proof, by including the
// top StateProofTopVoters accounts (by normalized balance) into the
// vector commitment.
var StateProofTopVoters int

// MaxTxnBytesPerBlock determines the maximum number of bytes
// that transactions can take up in a block. Specifically,
// the sum of the lengths of encodings of each transaction
// in a block must not exceed MaxTxnBytesPerBlock.
var MaxTxnBytesPerBlock int

// MaxAppTxnForeignApps is the max number of foreign apps per txn across all consensus versions
var MaxAppTxnForeignApps int

func checkSetMax(value int, curMax *int) {
if value > *curMax {
*curMax = value
Expand Down Expand Up @@ -618,6 +661,19 @@ func checkSetAllocBounds(p ConsensusParams) {
checkSetMax(p.MaxAppProgramLen, &MaxLogCalls)
checkSetMax(p.MaxInnerTransactions*p.MaxTxGroupSize, &MaxInnerTransactionsPerDelta)
checkSetMax(p.MaxProposedExpiredOnlineAccounts, &MaxProposedExpiredOnlineAccounts)

// These bounds are exported to make them available to the msgp generator for calculating
// maximum valid message size for each message going across the wire.
checkSetMax(p.MaxAppTotalArgLen, &MaxAppTotalArgLen)
checkSetMax(p.MaxAssetNameBytes, &MaxAssetNameBytes)
checkSetMax(p.MaxAssetUnitNameBytes, &MaxAssetUnitNameBytes)
checkSetMax(p.MaxAssetURLBytes, &MaxAssetURLBytes)
checkSetMax(p.MaxAppBytesValueLen, &MaxAppBytesValueLen)
checkSetMax(p.MaxAppKeyLen, &MaxAppBytesKeyLen)
checkSetMax(int(p.StateProofTopVoters), &StateProofTopVoters)
checkSetMax(p.MaxTxnBytesPerBlock, &MaxTxnBytesPerBlock)

checkSetMax(p.MaxAppTxnForeignApps, &MaxAppTxnForeignApps)
}

// DeepCopy creates a deep copy of a consensus protocols map.
Expand Down Expand Up @@ -662,6 +718,9 @@ func (cp ConsensusProtocols) Merge(configurableConsensus ConsensusProtocols) Con
return staticConsensus
}

// initConsensusProtocols defines the consensus protocol values and how values change across different versions of the protocol.
//
// These are the only valid and tested consensus values and transitions. Other settings are not tested and may lead to unexpected behavior.
func initConsensusProtocols() {
// WARNING: copying a ConsensusParams by value into a new variable
// does not copy the ApprovedUpgrades map. Make sure that each new
Expand Down Expand Up @@ -702,8 +761,9 @@ func initConsensusProtocols() {
DownCommitteeSize: 10000,
DownCommitteeThreshold: 7750,

AgreementFilterTimeout: 4 * time.Second,
AgreementFilterTimeoutPeriod0: 4 * time.Second,
AgreementFilterTimeout: 4 * time.Second,
AgreementFilterTimeoutPeriod0: 4 * time.Second,
AgreementDeadlineTimeoutPeriod0: Protocol.BigLambda + Protocol.SmallLambda,

FastRecoveryLambda: 5 * time.Minute,

Expand Down Expand Up @@ -1234,13 +1294,34 @@ func initConsensusProtocols() {
// for the sake of future manual calculations, we'll round that down a bit :
v37.ApprovedUpgrades[protocol.ConsensusV38] = 10000

v39 := v38
v39.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}

v39.LogicSigVersion = 10
v39.EnableLogicSigCostPooling = true

v39.AgreementDeadlineTimeoutPeriod0 = 4 * time.Second

v39.DynamicFilterTimeout = true

v39.StateProofBlockHashInLightHeader = true

// For future upgrades, round times will likely be shorter so giving ourselves some buffer room
v39.MaxUpgradeWaitRounds = 250000

Consensus[protocol.ConsensusV39] = v39

// v38 can be upgraded to v39, with an update delay of 7d:
// 157000 = (7 * 24 * 60 * 60 / 3.3 round times currently)
// but our current max is 150000 so using that :
v38.ApprovedUpgrades[protocol.ConsensusV39] = 150000

// ConsensusFuture is used to test features that are implemented
// but not yet released in a production protocol version.
vFuture := v38
vFuture := v39
vFuture.ApprovedUpgrades = map[protocol.ConsensusVersion]uint64{}

vFuture.LogicSigVersion = 10 // When moving this to a release, put a new higher LogicSigVersion here
vFuture.EnableLogicSigCostPooling = true
vFuture.LogicSigVersion = 11 // When moving this to a release, put a new higher LogicSigVersion here

Consensus[protocol.ConsensusFuture] = vFuture

Expand Down
8 changes: 7 additions & 1 deletion protocol/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ const ConsensusV38 = ConsensusVersion(
"https://github.com/algorandfoundation/specs/tree/abd3d4823c6f77349fc04c3af7b1e99fe4df699f",
)

// ConsensusV39 enables dynamic filter timeouts, a deadline timeout of 4 seconds,
// TEAL v10 logicSig opcode budget pooling along with elliptic curve ops on some pairing friendly curves.
const ConsensusV39 = ConsensusVersion(
"https://github.com/algorandfoundation/specs/tree/925a46433742afb0b51bb939354bd907fa88bf95",
)

// ConsensusFuture is a protocol that should not appear in any production
// network, but is used to test features before they are released.
const ConsensusFuture = ConsensusVersion(
Expand Down Expand Up @@ -224,7 +230,7 @@ const ConsensusVAlpha5 = ConsensusVersion("alpha5")

// ConsensusCurrentVersion is the latest version and should be used
// when a specific version is not provided.
const ConsensusCurrentVersion = ConsensusV38
const ConsensusCurrentVersion = ConsensusV39

// Error is used to indicate that an unsupported protocol has been detected.
type Error ConsensusVersion
Expand Down
2 changes: 1 addition & 1 deletion types/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type ApplicationCallTxnFields struct {

ApplicationID AppIndex `codec:"apid"`
OnCompletion OnCompletion `codec:"apan"`
ApplicationArgs [][]byte `codec:"apaa,allocbound=encodedMaxApplicationArgs"`
ApplicationArgs [][]byte `codec:"apaa,allocbound=encodedMaxApplicationArgs,maxtotalbytes=config.MaxAppTotalArgLen"`
Accounts []Address `codec:"apat,allocbound=encodedMaxAccounts"`
ForeignApps []AppIndex `codec:"apfa,allocbound=encodedMaxForeignApps"`
ForeignAssets []AssetIndex `codec:"apas,allocbound=encodedMaxForeignAssets"`
Expand Down
6 changes: 3 additions & 3 deletions types/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ type AssetParams struct {

// UnitName specifies a hint for the name of a unit of
// this asset.
UnitName string `codec:"un"`
UnitName string `codec:"un,allocbound=config.MaxAssetUnitNameBytes"`

// AssetName specifies a hint for the name of the asset.
AssetName string `codec:"an"`
AssetName string `codec:"an,allocbound=config.MaxAssetNameBytes"`

// URL specifies a URL where more information about the asset can be
// retrieved
URL string `codec:"au"`
URL string `codec:"au,allocbound=config.MaxAssetURLBytes"`

// MetadataHash specifies a commitment to some unspecified asset
// metadata. The format of this metadata is up to the application.
Expand Down
15 changes: 5 additions & 10 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type (
TimeStamp int64 `codec:"ts"`

// Genesis ID to which this block belongs.
GenesisID string `codec:"gen"`
GenesisID string `codec:"gen,allocbound=config.MaxGenesisIDLen"`

// Genesis hash to which this block belongs.
GenesisHash Digest `codec:"gh"`
Expand Down Expand Up @@ -79,14 +79,9 @@ type (
UpgradeState
UpgradeVote

// TxnCounter counts the number of transactions committed in the
// ledger, from the time at which support for this feature was
// introduced.
//
// Specifically, TxnCounter is the number of the next transaction
// that will be committed after this block. It is 0 when no
// transactions have ever been committed (since TxnCounter
// started being supported).
// TxnCounter is the number of the next transaction that will be
// committed after this block. Genesis blocks can start at either
// 0 or 1000, depending on a consensus parameter (AppForbidLowResources).
TxnCounter uint64 `codec:"tc"`

// StateProofTracking tracks the status of the state proofs, potentially
Expand Down Expand Up @@ -205,7 +200,7 @@ type (
// A Block contains the Payset and metadata corresponding to a given Round.
Block struct {
BlockHeader
Payset Payset `codec:"txns"`
Payset Payset `codec:"txns,maxtotalbytes=config.MaxTxnBytesPerBlock"`
}

// A Payset represents a common, unforgeable, consistent, ordered set of SignedTxn objects.
Expand Down
3 changes: 2 additions & 1 deletion types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ type Account struct {
Status byte `codec:"onl"`
MicroAlgos uint64 `codec:"algo"`
VoteID [32]byte `codec:"vote"`
SelectionID [32]byte `codec:"sel"`
StateProofID [64]byte `codec:"stprf"`
SelectionID [32]byte `codec:"sel"`
VoteFirstValid uint64 `codec:"voteFst"`
VoteLastValid uint64 `codec:"voteLst"`
VoteKeyDilution uint64 `codec:"voteKD"`
}
Expand Down
1 change: 1 addition & 0 deletions types/lightBlockHeader.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type LightBlockHeader struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

Seed Seed `codec:"0"`
BlockHash Digest `codec:"1"`
RoundNumber Round `codec:"r"`
GenesisHash Digest `codec:"gh"`
Sha256TxnCommitment Digest `codec:"tc,allocbound=Sha256Size"`
Expand Down
5 changes: 3 additions & 2 deletions types/statedelta.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ type LedgerStateDelta struct {
// new block header; read-only
Hdr *BlockHeader

// next round for which we expect a state proof.
// zero if no state proof is expected.
// StateProofNext represents modification on StateProofNextRound field in the block header. If the block contains
// a valid state proof transaction, this field will contain the next round for state proof.
// otherwise it will be set to 0.
StateProofNext Round

// previous block timestamp
Expand Down

0 comments on commit 5fd2c1c

Please sign in to comment.