-
Notifications
You must be signed in to change notification settings - Fork 202
/
constants.go
137 lines (106 loc) · 6.19 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package process
import "time"
// BlockHeaderState specifies which is the state of the block header received
type BlockHeaderState int
const (
// BHReceived defines ID of a received block header
BHReceived BlockHeaderState = iota
// BHReceivedTooLate defines ID of a late received block header
BHReceivedTooLate
// BHProcessed defines ID of a processed block header
BHProcessed
// BHProposed defines ID of a proposed block header
BHProposed
// BHNotarized defines ID of a notarized block header
BHNotarized
)
// TransactionType specifies the type of the transaction
type TransactionType int
const (
// MoveBalance defines ID of a payment transaction - moving balances
MoveBalance TransactionType = iota
// SCDeployment defines ID of a transaction to store a smart contract
SCDeployment
// SCInvoking defines ID of a transaction of type smart contract call
SCInvoking
// BuiltInFunctionCall defines ID of a builtin function call
BuiltInFunctionCall
// RelayedTx defines ID of a transaction of type relayed
RelayedTx
// RelayedTxV2 defines the ID of a slim relayed transaction version
RelayedTxV2
// RewardTx defines ID of a reward transaction
RewardTx
// InvalidTransaction defines unknown transaction type
InvalidTransaction
)
// BlockFinality defines the block finality which is used in meta-chain/shards (the real finality in shards is given
// by meta-chain)
const BlockFinality = 1
// MetaBlockValidity defines the block validity which is when checking a metablock
const MetaBlockValidity = 1
// EpochChangeGracePeriod defines the allowed round numbers till the shard has to change the epoch
const EpochChangeGracePeriod = 1
// MaxHeaderRequestsAllowed defines the maximum number of missing cross-shard headers (gaps) which could be requested
// in one round, when node processes a received block
const MaxHeaderRequestsAllowed = 20
// NumTxPerSenderBatchForFillingMiniblock defines the number of transactions to be drawn
// from the transactions pool, for a specific sender, in a single pass.
// Drawing transactions for a miniblock happens in multiple passes, until "MaxItemsInBlock" are drawn.
const NumTxPerSenderBatchForFillingMiniblock = 10
// NonceDifferenceWhenSynced defines the difference between probable highest nonce seen from network and node's last
// committed block nonce, after which, node is considered himself not synced
const NonceDifferenceWhenSynced = 0
// MaxSyncWithErrorsAllowed defines the maximum allowed number of sync with errors,
// before a special action to be applied
const MaxSyncWithErrorsAllowed = 10
// MaxHeadersToRequestInAdvance defines the maximum number of headers which will be requested in advance,
// if they are missing
const MaxHeadersToRequestInAdvance = 20
// RoundModulusTrigger defines a round modulus on which a trigger for an action will be released
const RoundModulusTrigger = 5
// RoundModulusTriggerWhenSyncIsStuck defines a round modulus on which a trigger for an action when sync is stuck will be released
const RoundModulusTriggerWhenSyncIsStuck = 20
// MaxRoundsWithoutCommittedBlock defines the maximum rounds to wait for a new block to be committed,
// before a special action to be applied
const MaxRoundsWithoutCommittedBlock = 10
// MinForkRound represents the minimum fork round set by a notarized header received
const MinForkRound = uint64(0)
// MaxMetaNoncesBehind defines the maximum difference between the current meta block nonce and the processed meta block
// nonce before a shard is considered stuck
const MaxMetaNoncesBehind = 15
// MaxMetaNoncesBehindForGlobalStuck defines the maximum difference between the current meta block nonce and the processed
// meta block nonce for any shard, where the chain is considered stuck and enters recovery
const MaxMetaNoncesBehindForGlobalStuck = 30
// MaxShardNoncesBehind defines the maximum difference between the current shard block nonce and the last notarized
// shard block nonce by meta, before meta is considered stuck
const MaxShardNoncesBehind = 15
// MaxRoundsWithoutNewBlockReceived defines the maximum number of rounds to wait for a new block to be received,
// before a special action to be applied
const MaxRoundsWithoutNewBlockReceived = 10
// MaxMetaHeadersAllowedInOneShardBlock defines the maximum number of meta headers allowed to be included in one shard block
const MaxMetaHeadersAllowedInOneShardBlock = 50
// MaxShardHeadersAllowedInOneMetaBlock defines the maximum number of shard headers allowed to be included in one meta block
const MaxShardHeadersAllowedInOneMetaBlock = 60
// MinShardHeadersFromSameShardInOneMetaBlock defines the minimum number of shard headers from the same shard,
// which would be included in one meta block if they are available
const MinShardHeadersFromSameShardInOneMetaBlock = 10
// MaxNumOfTxsToSelect defines the maximum number of transactions that should be selected from the cache
const MaxNumOfTxsToSelect = 30000
// MaxGasBandwidthPerBatchPerSender defines the maximum gas bandwidth that should be selected for a sender per batch from the cache
const MaxGasBandwidthPerBatchPerSender = 5000000
// MaxRoundsToKeepUnprocessedMiniBlocks defines the maximum number of rounds for which unprocessed miniblocks are kept in pool
// TODO extract this in configs (EN-11896)
const MaxRoundsToKeepUnprocessedMiniBlocks = 300
// MaxRoundsToKeepUnprocessedTransactions defines the maximum number of rounds for which unprocessed transactions are kept in pool
// TODO extract this in configs (EN-11896)
const MaxRoundsToKeepUnprocessedTransactions = 300
// MaxHeadersToWhitelistInAdvance defines the maximum number of headers whose miniblocks will be whitelisted in advance
const MaxHeadersToWhitelistInAdvance = 300
// MaxGasFeeHigherFactorAccepted defines the maximum higher factor of gas fee put inside a transaction compared with
// the real gas used, after which the transaction will be considered an attack and all the gas will be consumed and
// nothing will be refunded to the sender
const MaxGasFeeHigherFactorAccepted = 10
// TimeDurationMultiplierForProcessBlockWhenSync represents the constant that will be multiplied with the round duration
// when considering the maximum available time window for block processing when syncing blocks
const TimeDurationMultiplierForProcessBlockWhenSync = time.Duration(2)