Skip to content

Commit 72d6cdb

Browse files
authored
feat: support for Conway protocol parameter updates (#673)
Fixes #592
1 parent ce14827 commit 72d6cdb

File tree

2 files changed

+57
-6
lines changed

2 files changed

+57
-6
lines changed

ledger/conway.go

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,55 @@ func (b *ConwayTransactionBody) Donation() uint64 {
206206
return b.TxDonation
207207
}
208208

209+
type ConwayProtocolParameters struct {
210+
BabbageProtocolParameters
211+
PoolVotingThresholds PoolVotingThresholds
212+
DRepVotingThresholds DRepVotingThresholds
213+
MinCommitteeSize uint
214+
CommitteeTermLimit uint64
215+
GovActionValidityPeriod uint64
216+
GovActionDeposit uint64
217+
DRepDeposit uint64
218+
DRepInactivityPeriod uint64
219+
MinFeeRefScriptCostPerByte *cbor.Rat
220+
}
221+
222+
type ConwayProtocolParameterUpdate struct {
223+
BabbageProtocolParameterUpdate
224+
PoolVotingThresholds PoolVotingThresholds `cbor:"25,keyasint"`
225+
DRepVotingThresholds DRepVotingThresholds `cbor:"26,keyasint"`
226+
MinCommitteeSize uint `cbor:"27,keyasint"`
227+
CommitteeTermLimit uint64 `cbor:"28,keyasint"`
228+
GovActionValidityPeriod uint64 `cbor:"29,keyasint"`
229+
GovActionDeposit uint64 `cbor:"30,keyasint"`
230+
DRepDeposit uint64 `cbor:"31,keyasint"`
231+
DRepInactivityPeriod uint64 `cbor:"32,keyasint"`
232+
MinFeeRefScriptCostPerByte *cbor.Rat `cbor:"33,keyasint"`
233+
}
234+
235+
type PoolVotingThresholds struct {
236+
cbor.StructAsArray
237+
MotionNoConfidence cbor.Rat
238+
CommitteeNormal cbor.Rat
239+
CommitteeNoConfidence cbor.Rat
240+
HardForkInitiation cbor.Rat
241+
SecurityRelevantParameterVotingThreshold cbor.Rat
242+
}
243+
244+
type DRepVotingThresholds struct {
245+
cbor.StructAsArray
246+
MotionNoConfidence cbor.Rat
247+
CommitteeNormal cbor.Rat
248+
CommitteeNoConfidence cbor.Rat
249+
UpdateConstitution cbor.Rat
250+
HardForkInitiation cbor.Rat
251+
PPNetworkGroup cbor.Rat
252+
PPEconomicGroup cbor.Rat
253+
PPTechnicalGroup cbor.Rat
254+
PPGovGroup cbor.Rat
255+
TreasureWithdrawal cbor.Rat
256+
}
257+
209258
// VotingProcedures is a convenience type to avoid needing to duplicate the full type definition everywhere
210259
type VotingProcedures map[*Voter]map[*GovActionId]VotingProcedure
211260

@@ -316,7 +365,7 @@ type ParameterChangeGovAction struct {
316365
cbor.StructAsArray
317366
Type uint
318367
ActionId *GovActionId
319-
ParamUpdate BabbageProtocolParameterUpdate // TODO: use Conway params update type
368+
ParamUpdate ConwayProtocolParameterUpdate
320369
PolicyHash []byte
321370
}
322371

protocol/localstatequery/client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
348348
QueryTypeShelleyCurrentProtocolParams,
349349
)
350350
switch currentEra {
351+
case ledger.EraIdConway:
352+
result := []ledger.ConwayProtocolParameters{}
353+
if err := c.runQuery(query, &result); err != nil {
354+
return nil, err
355+
}
356+
return result[0], nil
351357
case ledger.EraIdBabbage:
352358
result := []ledger.BabbageProtocolParameters{}
353359
if err := c.runQuery(query, &result); err != nil {
@@ -379,11 +385,7 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
379385
}
380386
return result[0], nil
381387
default:
382-
result := []any{}
383-
if err := c.runQuery(query, &result); err != nil {
384-
return nil, err
385-
}
386-
return result[0], nil
388+
return nil, fmt.Errorf("unknown era ID: %d", currentEra)
387389
}
388390
}
389391

0 commit comments

Comments
 (0)