Skip to content

Commit

Permalink
Updates for new heartbeat transaction type support.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmalouf committed Oct 31, 2024
1 parent 6c2ca93 commit 9f36e06
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 8 deletions.
9 changes: 7 additions & 2 deletions protocol/config/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ type ConsensusParams struct {
// occur, extra funds need to be put into the FeeSink. The bonus amount
// decays exponentially.
Bonus BonusPlan

// Heartbeat support
Heartbeat bool
}

// ProposerPayoutRules puts several related consensus parameters in one place. The same
Expand Down Expand Up @@ -1424,7 +1427,7 @@ func initConsensusProtocols() {
vFuture.LogicSigVersion = 11 // When moving this to a release, put a new higher LogicSigVersion here

vFuture.Payouts.Enabled = true
vFuture.Payouts.Percent = 75
vFuture.Payouts.Percent = 50
vFuture.Payouts.GoOnlineFee = 2_000_000 // 2 algos
vFuture.Payouts.MinBalance = 30_000_000_000 // 30,000 algos
vFuture.Payouts.MaxBalance = 70_000_000_000_000 // 70M algos
Expand All @@ -1435,7 +1438,9 @@ func initConsensusProtocols() {

vFuture.Bonus.BaseAmount = 10_000_000 // 10 Algos
// 2.9 sec rounds gives about 10.8M rounds per year.
vFuture.Bonus.DecayInterval = 250_000 // .99^(10.8/0.25) ~ .648. So 35% decay per year
vFuture.Bonus.DecayInterval = 1_000_000 // .99^(10.8M/1M) ~ .897. So ~10% decay per year

vFuture.Heartbeat = true

Consensus[protocol.ConsensusFuture] = vFuture

Expand Down
8 changes: 2 additions & 6 deletions types/basics.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@ const (
ApplicationCallTx TxType = "appl"
// StateProofTx records a state proof
StateProofTx TxType = "stpf"
// HeartbeatTx demonstrates the account is alive
HeartbeatTx TxType = "hb"
)

const masterDerivationKeyLenBytes = 32

// MaxTxGroupSize is max number of transactions in a single group
const MaxTxGroupSize = 16

// LogicSigMaxSize is a max TEAL program size (with args)
const LogicSigMaxSize = 1000

// LogicSigMaxCost is a max execution const of a TEAL program
const LogicSigMaxCost = 20000

// KeyStoreRootSize is the size, in bytes, of keyreg verifier
const KeyStoreRootSize = 64

Expand Down
20 changes: 20 additions & 0 deletions types/heartbeat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package types

// HeartbeatTxnFields captures the fields used for an account to prove it is
// online (really, it proves that an entity with the account's part keys is able
// to submit transactions, so it should be able to propose/vote.)
type HeartbeatTxnFields struct {
_struct struct{} `codec:",omitempty,omitemptyarray"`

// HeartbeatAddress is the account this txn is proving onlineness for.
HbAddress Address `codec:"hbad"`

// HbProof is a signature using HeartbeatAddress's partkey, thereby showing it is online.
HbProof OneTimeSignature `codec:"hbprf"`

// HbSeed must be the block seed for the block before this transaction's
// firstValid. It is supplied in the transaction so that Proof can be
// checked at submit time without a ledger lookup, and must be checked at
// evaluation time for equality with the actual blockseed.
HbSeed Seed `codec:"hbsd"`
}
36 changes: 36 additions & 0 deletions types/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,39 @@ func (lsig LogicSig) Blank() bool {
}
return true
}

/* Classical signatures */
type ed25519Signature [64]byte
type ed25519PublicKey [32]byte

// A OneTimeSignature is a cryptographic signature that is produced a limited
// number of times and provides forward integrity.
//
// Specifically, a OneTimeSignature is generated from an ephemeral secret. After
// some number of messages is signed under a given OneTimeSignatureIdentifier
// identifier, the corresponding secret is deleted. This prevents the
// secret-holder from signing a contradictory message in the future in the event
// of a secret-key compromise.
type OneTimeSignature struct {
// Unfortunately we forgot to mark this struct as omitempty at
// one point, and now it's hard to change if we want to preserve
// encodings.
_struct struct{} `codec:""`

// Sig is a signature of msg under the key PK.
Sig ed25519Signature `codec:"s"`
PK ed25519PublicKey `codec:"p"`

// Old-style signature that does not use proper domain separation.
// PKSigOld is unused; however, unfortunately we forgot to mark it
// `codec:omitempty` and so it appears (with zero value) in certs.
// This means we can't delete the field without breaking catchup.
PKSigOld ed25519Signature `codec:"ps"`

// Used to verify a new-style two-level ephemeral signature.
// PK1Sig is a signature of OneTimeSignatureSubkeyOffsetID(PK, Batch, Offset) under the key PK2.
// PK2Sig is a signature of OneTimeSignatureSubkeyBatchID(PK2, Batch) under the master key (OneTimeSignatureVerifier).
PK2 ed25519PublicKey `codec:"p2"`
PK1Sig ed25519Signature `codec:"p1s"`
PK2Sig ed25519Signature `codec:"p2s"`
}
1 change: 1 addition & 0 deletions types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Transaction struct {
AssetFreezeTxnFields
ApplicationFields
StateProofTxnFields
HeartbeatTxnFields
}

// SignedTxn wraps a transaction and a signature. The encoding of this struct
Expand Down

0 comments on commit 9f36e06

Please sign in to comment.