github.com/onflow/flow-go@v0.33.17/model/flow/constants.go (about)

     1  package flow
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  // GenesisTime defines the timestamp of the genesis block.
     9  var GenesisTime = time.Date(2018, time.December, 19, 22, 32, 30, 42, time.UTC)
    10  
    11  // DefaultProtocolVersion is the default protocol version, indicating none was
    12  // explicitly set during bootstrapping.
    13  const DefaultProtocolVersion uint = 0
    14  
    15  // DefaultTransactionExpiry is the default expiry for transactions, measured in blocks.
    16  // The default value is equivalent to 10 minutes for a 1-second block time.
    17  //
    18  // Let E by the transaction expiry. If a transaction T specifies a reference
    19  // block R with height H, then T may be included in any block B where:
    20  // * R<-*B - meaning B has R as an ancestor, and
    21  // * R.height < B.height <= R.height+E
    22  const DefaultTransactionExpiry = 10 * 60
    23  
    24  // ExtraBlocksInRootSealingSegment is the default number of extra blocks to be included
    25  // in the the root sealing segment.
    26  // "- 10" is to be backward compatible, since some dynamically bootstrapped execution nodes
    27  // are using previously generated root snapshot which has about 6-7 blocks less than DefaultTransactionExpiry
    28  // number of extra blocks in the sealing segment.
    29  const ExtraBlocksInRootSealingSegment = DefaultTransactionExpiry - 10
    30  
    31  // DefaultTransactionExpiryBuffer is the default buffer time between a transaction being ingested by a
    32  // collection node and being included in a collection and block.
    33  const DefaultTransactionExpiryBuffer = 30
    34  
    35  // DefaultMaxTransactionGasLimit is the default maximum value for the transaction gas limit.
    36  const DefaultMaxTransactionGasLimit = 9999
    37  
    38  // EstimatedComputationPerMillisecond is the approximate number of computation units that can be performed in a millisecond.
    39  // this was calibrated during the Variable Transaction Fees: Execution Effort FLIP https://github.com/onflow/flow/pull/753
    40  const EstimatedComputationPerMillisecond = 9999.0 / 200.0
    41  
    42  // DefaultMaxTransactionByteSize is the default maximum transaction byte size. (~1.5MB)
    43  const DefaultMaxTransactionByteSize = 1_500_000
    44  
    45  // DefaultMaxCollectionByteSize is the default maximum value for a collection byte size.
    46  const DefaultMaxCollectionByteSize = 3_000_000 // ~3MB. This is should always be higher than the limit on single tx size.
    47  
    48  // DefaultMaxCollectionTotalGas is the default maximum value for total gas allowed to be included in a collection.
    49  const DefaultMaxCollectionTotalGas = 10_000_000 // 10M
    50  
    51  // DefaultMaxCollectionSize is the default maximum number of transactions allowed inside a collection.
    52  const DefaultMaxCollectionSize = 100
    53  
    54  // DefaultValueLogGCWaitDuration is the default wait duration before we repeatedly call the badger value log GC.
    55  const DefaultValueLogGCWaitDuration time.Duration = 10 * time.Minute
    56  
    57  // DefaultRequiredApprovalsForSealConstruction is the default number of approvals required to construct a candidate seal
    58  // for subsequent inclusion in block.
    59  // when set to 1, it requires at least 1 approval to build a seal
    60  // when set to 0, it can build seal without any approval
    61  const DefaultRequiredApprovalsForSealConstruction = uint(1)
    62  
    63  // DefaultRequiredApprovalsForSealValidation is the default number of approvals that should be
    64  // present and valid for each chunk. Setting this to 0 will disable counting of chunk approvals
    65  // this can be used temporarily to ease the migration to new chunk based sealing.
    66  // TODO:
    67  //   - This value will result in consensus not depending on verification at all for sealing (no approvals required)
    68  //   - Full protocol should be +2/3 of all currently authorized verifiers.
    69  const DefaultRequiredApprovalsForSealValidation = 0
    70  
    71  // DefaultChunkAssignmentAlpha is the default number of verifiers that should be
    72  // assigned to each chunk.
    73  const DefaultChunkAssignmentAlpha = 3
    74  
    75  // DefaultEmergencySealingActive is a flag which indicates when emergency sealing is active, this is a temporary measure
    76  // to make fire fighting easier while seal & verification is under development.
    77  const DefaultEmergencySealingActive = false
    78  
    79  // threshold for re-requesting approvals: min height difference between the latest finalized block
    80  // and the block incorporating a result
    81  const DefaultApprovalRequestsThreshold = uint64(10)
    82  
    83  // DomainTagLength is set to 32 bytes.
    84  //
    85  // Signatures on Flow that needs to be scoped to a certain domain need to
    86  // have the same length in order to avoid tag collision issues, when prefixing the
    87  // message to sign.
    88  const DomainTagLength = 32
    89  
    90  const TransactionTagString = "FLOW-V0.0-transaction"
    91  
    92  // TransactionDomainTag is the prefix of all signed transaction payloads.
    93  //
    94  // The tag is the string `TransactionTagString` encoded as UTF-8 bytes,
    95  // right padded to a total length of 32 bytes.
    96  var TransactionDomainTag = paddedDomainTag(TransactionTagString)
    97  
    98  // paddedDomainTag padds string tags to form the actuatl domain separation tag used for signing
    99  // and verifiying.
   100  //
   101  // A domain tag is encoded as UTF-8 bytes, right padded to a total length of 32 bytes.
   102  func paddedDomainTag(s string) [DomainTagLength]byte {
   103  	var tag [DomainTagLength]byte
   104  
   105  	if len(s) > DomainTagLength {
   106  		panic(fmt.Sprintf("domain tag %s cannot be longer than %d characters", s, DomainTagLength))
   107  	}
   108  
   109  	copy(tag[:], s)
   110  
   111  	return tag
   112  }