github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/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 // DefaultTransactionExpiryBuffer is the default buffer time between a transaction being ingested by a 25 // collection node and being included in a collection and block. 26 const DefaultTransactionExpiryBuffer = 30 27 28 // DefaultMaxTransactionGasLimit is the default maximum value for the transaction gas limit. 29 const DefaultMaxTransactionGasLimit = 9999 30 31 // DefaultMaxTransactionByteSize is the default maximum transaction byte size. (~1.5MB) 32 const DefaultMaxTransactionByteSize = 1_500_000 33 34 // DefaultMaxCollectionByteSize is the default maximum value for a collection byte size. 35 const DefaultMaxCollectionByteSize = 3_000_000 // ~3MB. This is should always be higher than the limit on single tx size. 36 37 // DefaultMaxCollectionTotalGas is the default maximum value for total gas allowed to be included in a collection. 38 const DefaultMaxCollectionTotalGas = 10_000_000 // 10M 39 40 // DefaultMaxCollectionSize is the default maximum number of transactions allowed inside a collection. 41 const DefaultMaxCollectionSize = 100 42 43 // DefaultValueLogGCWaitDuration is the default wait duration before we repeatedly call the badger value log GC. 44 const DefaultValueLogGCWaitDuration time.Duration = 10 * time.Minute 45 46 // DefaultRequiredApprovalsForSealConstruction is the default number of approvals required to construct a candidate seal 47 // for subsequent inclusion in block. 48 // when set to 1, it requires at least 1 approval to build a seal 49 // when set to 0, it can build seal without any approval 50 const DefaultRequiredApprovalsForSealConstruction = uint(1) 51 52 // DefaultRequiredApprovalsForSealValidation is the default number of approvals that should be 53 // present and valid for each chunk. Setting this to 0 will disable counting of chunk approvals 54 // this can be used temporarily to ease the migration to new chunk based sealing. 55 // TODO: 56 // - This value will result in consensus not depending on verification at all for sealing (no approvals required) 57 // - Full protocol should be +2/3 of all currently authorized verifiers. 58 const DefaultRequiredApprovalsForSealValidation = 0 59 60 // DefaultChunkAssignmentAlpha is the default number of verifiers that should be 61 // assigned to each chunk. 62 const DefaultChunkAssignmentAlpha = 3 63 64 // DefaultEmergencySealingActive is a flag which indicates when emergency sealing is active, this is a temporary measure 65 // to make fire fighting easier while seal & verification is under development. 66 const DefaultEmergencySealingActive = false 67 68 // threshold for re-requesting approvals: min height difference between the latest finalized block 69 // and the block incorporating a result 70 const DefaultApprovalRequestsThreshold = uint64(10) 71 72 // DomainTagLength is set to 32 bytes. 73 // 74 // Signatures on Flow that needs to be scoped to a certain domain need to 75 // have the same length in order to avoid tag collision issues, when prefixing the 76 // message to sign. 77 const DomainTagLength = 32 78 79 const TransactionTagString = "FLOW-V0.0-transaction" 80 81 // TransactionDomainTag is the prefix of all signed transaction payloads. 82 // 83 // The tag is the string `TransactionTagString` encoded as UTF-8 bytes, 84 // right padded to a total length of 32 bytes. 85 var TransactionDomainTag = paddedDomainTag(TransactionTagString) 86 87 // paddedDomainTag padds string tags to form the actuatl domain separation tag used for signing 88 // and verifiying. 89 // 90 // A domain tag is encoded as UTF-8 bytes, right padded to a total length of 32 bytes. 91 func paddedDomainTag(s string) [DomainTagLength]byte { 92 var tag [DomainTagLength]byte 93 94 if len(s) > DomainTagLength { 95 panic(fmt.Sprintf("domain tag %s cannot be longer than %d characters", s, DomainTagLength)) 96 } 97 98 copy(tag[:], s) 99 100 return tag 101 } 102 103 // EstimatedComputationPerMillisecond is the approximate number of computation units that can be performed in a millisecond. 104 // this was calibrated during the Variable Transaction Fees: Execution Effort FLIP https://github.com/onflow/flow/pull/753 105 const EstimatedComputationPerMillisecond = 9999.0 / 200.0 106 107 // NormalizedExecutionTimePerComputationUnit returns the normalized time per computation unit 108 // If the computation estimation is correct (as per the FLIP https://github.com/onflow/flow/pull/753) the value should be 1. 109 // If the value is greater than 1, the computation estimation is too low; we are underestimating transaction complexity (and thus undercharging). 110 // If the value is less than 1, the computation estimation is too high; we are overestimating transaction complexity (and thus overcharging). 111 func NormalizedExecutionTimePerComputationUnit(execTime time.Duration, computationUsed uint64) float64 { 112 if computationUsed == 0 { 113 return 0 114 } 115 116 return (float64(execTime.Milliseconds()) / float64(computationUsed)) * EstimatedComputationPerMillisecond 117 }