-
Notifications
You must be signed in to change notification settings - Fork 55
/
ProtocolParameters.ts
154 lines (132 loc) · 4.42 KB
/
ProtocolParameters.ts
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import * as Crypto from '@cardano-sdk/crypto';
import { EpochNo, Slot } from './Block';
import { Fraction } from '.';
import { PlutusLanguageVersion } from './Script';
/* eslint-disable no-use-before-define */
export interface ProtocolVersion {
major: number;
minor: number;
patch?: number;
}
/**
* Cost models are a way to provide predictable pricing for script execution by specifying
* how much each OP costs in terms of memory and CPU steps.
*/
export type CostModel = Array<number>;
/**
* Each language version can have a different set of OP costs. CostModels is a map of
* plutus language version to its defined cost.
*/
export type CostModels = Map<PlutusLanguageVersion, CostModel>;
export interface Prices {
memory: number;
steps: number;
}
export interface ExUnits {
memory: number;
steps: number;
}
export interface ValidityInterval {
invalidBefore?: Slot;
invalidHereafter?: Slot;
}
export interface TxFeePolicy {
coefficient: string;
constant: number;
}
export interface SoftforkRule {
initThreshold: string;
minThreshold: string;
decrementThreshold: string;
}
type ProtocolParametersByron = {
heavyDlgThreshold: string;
maxBlockSize: number;
maxHeaderSize: number;
maxProposalSize: number;
maxTxSize: number;
mpcThreshold: string;
scriptVersion: number;
slotDuration: number;
unlockStakeEpoch: number;
updateProposalThreshold: string;
updateProposalTimeToLive: number;
updateVoteThreshold: string;
txFeePolicy: TxFeePolicy;
softforkRule: SoftforkRule;
};
type NewProtocolParamsInShelley = {
minFeeCoefficient: number;
minFeeConstant: number;
maxBlockBodySize: number;
maxBlockHeaderSize: number;
stakeKeyDeposit: number;
poolDeposit: number | null;
poolRetirementEpochBound: number;
desiredNumberOfPools: number;
poolInfluence: string;
monetaryExpansion: string;
treasuryExpansion: string;
decentralizationParameter: string;
minUtxoValue: number;
minPoolCost: number;
extraEntropy: 'neutral' | string;
protocolVersion: ProtocolVersion;
};
type ShelleyProtocolParams = Pick<ProtocolParametersByron, 'maxTxSize'> & NewProtocolParamsInShelley;
type NewProtocolParamsInAlonzo = {
coinsPerUtxoWord: number;
maxValueSize: number;
collateralPercentage: number;
maxCollateralInputs: number;
costModels: CostModels;
prices: Prices;
maxExecutionUnitsPerTransaction: ExUnits;
maxExecutionUnitsPerBlock: ExUnits;
};
type AlonzoProtocolParams = Omit<ShelleyProtocolParams, 'minUtxoValue'> & NewProtocolParamsInAlonzo;
type NewProtocolParamsInBabbage = {
coinsPerUtxoByte: number;
};
// coinsPerUtxoWord was replaced by coinsPerUtxoByte and extraEntropy was deprecated.
type BabbageProtocolParameters = Omit<AlonzoProtocolParams, 'coinsPerUtxoWord' | 'extraEntropy'> &
NewProtocolParamsInBabbage;
// Voting thresholds
export interface PoolVotingThresholds {
motionNoConfidence: Fraction;
committeeNormal: Fraction;
committeeNoConfidence: Fraction;
hardForkInitiation: Fraction;
securityRelevantParamVotingThreshold: Fraction;
}
export interface DelegateRepresentativeThresholds
extends Omit<PoolVotingThresholds, 'securityRelevantParamVotingThreshold'> {
updateConstitution: Fraction;
ppNetworkGroup: Fraction;
ppEconomicGroup: Fraction;
ppTechnicalGroup: Fraction;
ppGovernanceGroup: Fraction;
treasuryWithdrawal: Fraction;
}
type NewProtocolParamsInConway = {
poolVotingThresholds: PoolVotingThresholds;
dRepVotingThresholds: DelegateRepresentativeThresholds;
minCommitteeSize: number;
committeeTermLimit: EpochNo;
governanceActionValidityPeriod: EpochNo;
governanceActionDeposit: number;
dRepDeposit: number;
dRepInactivityPeriod: EpochNo;
minFeeRefScriptCostPerByte: string;
};
type ConwayProtocolParameters = BabbageProtocolParameters & NewProtocolParamsInConway;
export type ProtocolParameters = ConwayProtocolParameters;
// Even tho extraEntropy was deprecated on babbage era, and protocolVersion was deprecated in conway era,
// they are still present in the ProtocolParametersUpdate structure since this structure is backward compatible with all eras.
export type ProtocolParametersUpdate = Partial<ProtocolParameters & Pick<AlonzoProtocolParams, 'extraEntropy'>>;
export type GenesisDelegateKeyHash = Crypto.Hash28ByteBase16;
export type ProposedProtocolParameterUpdates = Map<GenesisDelegateKeyHash, ProtocolParametersUpdate>;
export type Update = {
epoch: EpochNo;
proposedProtocolParameterUpdates: ProposedProtocolParameterUpdates;
};