-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
StateProofTracking
to the BlockHeader
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace AlgoSdk | ||
{ | ||
public interface IStateProofTrackingData | ||
{ | ||
/// <summary> | ||
/// StateProofVotersCommitment is the root of a vector commitment containing the | ||
/// online accounts that will help sign a state proof. The | ||
/// VC root, and the state proof, happen on blocks that | ||
/// are a multiple of ConsensusParams.StateProofRounds. For blocks | ||
/// that are not a multiple of ConsensusParams.StateProofRounds, | ||
/// this value is zero. | ||
/// </summary> | ||
byte[] StateProofVotersCommitment { get; set; } | ||
|
||
/// <summary> | ||
/// StateProofOnlineTotalWeight is the total number of microalgos held by the online accounts | ||
/// during the StateProof round (or zero, if the merkle root is zero - no commitment for StateProof voters). | ||
/// This is intended for computing the threshold of votes to expect from StateProofVotersCommitment. | ||
/// </summary> | ||
MicroAlgos StateProofOnlineTotalWeight { get; set; } | ||
|
||
/// <summary> | ||
/// StateProofNextRound is the next round for which we will accept | ||
/// a StateProof transaction. | ||
/// </summary> | ||
ulong StateProofNextRound { get; set; } | ||
} | ||
|
||
/// <summary> | ||
/// StateProofTrackingData tracks the status of state proofs. | ||
/// </summary> | ||
[AlgoApiObject] | ||
[Serializable] | ||
public partial struct StateProofTrackingData | ||
: IStateProofTrackingData | ||
, IEquatable<StateProofTrackingData> | ||
{ | ||
[SerializeField] | ||
[Tooltip("StateProofVotersCommitment is the root of a vector commitment containing the " + | ||
"online accounts that will help sign a state proof. The " + | ||
"VC root, and the state proof, happen on blocks that " + | ||
"are a multiple of ConsensusParams.StateProofRounds. For blocks " + | ||
"that are not a multiple of ConsensusParams.StateProofRounds, " + | ||
"this value is zero.")] | ||
private byte[] stateProofVotersCommitment; | ||
|
||
[SerializeField] | ||
[Tooltip("StateProofOnlineTotalWeight is the total number of microalgos held by the online accounts " + | ||
"during the StateProof round (or zero, if the merkle root is zero - no commitment for StateProof voters). " + | ||
"This is intended for computing the threshold of votes to expect from StateProofVotersCommitment.")] | ||
private MicroAlgos stateProofOnlineTotalWeight; | ||
|
||
[SerializeField] | ||
[Tooltip("StateProofNextRound is the next round for which we will accept a StateProof transaction.")] | ||
private ulong stateProofNextRound; | ||
|
||
/// <inehritdoc /> | ||
[AlgoApiField("v")] | ||
public byte[] StateProofVotersCommitment | ||
{ | ||
get => stateProofVotersCommitment; | ||
set => stateProofVotersCommitment = value; | ||
} | ||
|
||
/// <inehritdoc /> | ||
[AlgoApiField("t")] | ||
public MicroAlgos StateProofOnlineTotalWeight | ||
{ | ||
get => stateProofOnlineTotalWeight; | ||
set => stateProofOnlineTotalWeight = value; | ||
} | ||
|
||
/// <inehritdoc /> | ||
[AlgoApiField("n")] | ||
public ulong StateProofNextRound | ||
{ | ||
get => stateProofNextRound; | ||
set => stateProofNextRound = value; | ||
} | ||
|
||
public bool Equals(StateProofTrackingData other) | ||
{ | ||
return ArrayComparer.Equals(StateProofVotersCommitment, other.StateProofVotersCommitment) | ||
&& StateProofOnlineTotalWeight.Equals(other.StateProofOnlineTotalWeight) | ||
&& StateProofNextRound.Equals(other.StateProofNextRound) | ||
; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
|
||
namespace AlgoSdk | ||
{ | ||
[AlgoApiObject] | ||
[Serializable] | ||
public partial struct StateProofTrackingDataMap | ||
: IEquatable<StateProofTrackingDataMap> | ||
{ | ||
[AlgoApiField("0")] | ||
public StateProofTrackingData StateProofBasicData; | ||
|
||
public StateProofTrackingData this[StateProofType type] | ||
{ | ||
get | ||
{ | ||
switch (type) | ||
{ | ||
case StateProofType.StateProofBasic: | ||
return StateProofBasicData; | ||
default: | ||
throw new System.NotSupportedException(type.ToString()); | ||
} | ||
} | ||
set | ||
{ | ||
switch (type) | ||
{ | ||
case StateProofType.StateProofBasic: | ||
StateProofBasicData = value; | ||
break; | ||
default: | ||
throw new System.NotSupportedException(type.ToString()); | ||
} | ||
} | ||
} | ||
|
||
public bool Equals(StateProofTrackingDataMap other) | ||
{ | ||
return StateProofBasicData.Equals(other.StateProofBasicData); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace AlgoSdk | ||
{ | ||
public enum StateProofType : byte | ||
{ | ||
StateProofBasic = 0, | ||
NumStateProofTypes = 1, | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// Runtime Version:4.0.30319.42000 | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
namespace AlgoSdk | ||
{ | ||
|
||
|
||
public partial struct StateProofTrackingData | ||
{ | ||
|
||
private static bool @__generated__IsValid = StateProofTrackingData.@__generated__InitializeAlgoApiFormatters(); | ||
|
||
private static bool @__generated__InitializeAlgoApiFormatters() | ||
{ | ||
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.StateProofTrackingData>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.StateProofTrackingData>(false).Assign("v", (AlgoSdk.StateProofTrackingData x) => x.StateProofVotersCommitment, (ref AlgoSdk.StateProofTrackingData x, System.Byte[] value) => x.StateProofVotersCommitment = value, AlgoSdk.ArrayComparer<System.Byte>.Instance).Assign("t", (AlgoSdk.StateProofTrackingData x) => x.StateProofOnlineTotalWeight, (ref AlgoSdk.StateProofTrackingData x, AlgoSdk.MicroAlgos value) => x.StateProofOnlineTotalWeight = value).Assign("n", (AlgoSdk.StateProofTrackingData x) => x.StateProofNextRound, (ref AlgoSdk.StateProofTrackingData x, System.UInt64 value) => x.StateProofNextRound = value)); | ||
return true; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// Runtime Version:4.0.30319.42000 | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
namespace AlgoSdk | ||
{ | ||
|
||
|
||
public partial struct StateProofTrackingDataMap | ||
{ | ||
|
||
private static bool @__generated__IsValid = StateProofTrackingDataMap.@__generated__InitializeAlgoApiFormatters(); | ||
|
||
private static bool @__generated__InitializeAlgoApiFormatters() | ||
{ | ||
AlgoSdk.AlgoApiFormatterLookup.Add<AlgoSdk.StateProofTrackingDataMap>(new AlgoSdk.AlgoApiObjectFormatter<AlgoSdk.StateProofTrackingDataMap>(false).Assign("0", (AlgoSdk.StateProofTrackingDataMap x) => x.StateProofBasicData, (ref AlgoSdk.StateProofTrackingDataMap x, AlgoSdk.StateProofTrackingData value) => x.StateProofBasicData = value)); | ||
return true; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.