Skip to content

Commit

Permalink
feat: support for Conway protocol parameter updates
Browse files Browse the repository at this point in the history
Fixes #592
  • Loading branch information
agaffney committed Jul 17, 2024
1 parent d0eef33 commit 94c1fdf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
51 changes: 50 additions & 1 deletion ledger/conway.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,55 @@ func (b *ConwayTransactionBody) Donation() uint64 {
return b.TxDonation
}

type ConwayProtocolParameters struct {
BabbageProtocolParameters
PoolVotingThresholds PoolVotingThresholds
DRepVotingThresholds DRepVotingThresholds
MinCommitteeSize uint
CommitteeTermLimit uint64
GovActionValidityPeriod uint64
GovActionDeposit uint64
DRepDeposit uint64
DRepInactivityPeriod uint64
MinFeeRefScriptCostPerByte *cbor.Rat
}

type ConwayProtocolParameterUpdate struct {
BabbageProtocolParameterUpdate
PoolVotingThresholds PoolVotingThresholds `cbor:"25,keyasint"`
DRepVotingThresholds DRepVotingThresholds `cbor:"26,keyasint"`
MinCommitteeSize uint `cbor:"27,keyasint"`
CommitteeTermLimit uint64 `cbor:"28,keyasint"`
GovActionValidityPeriod uint64 `cbor:"29,keyasint"`
GovActionDeposit uint64 `cbor:"30,keyasint"`
DRepDeposit uint64 `cbor:"31,keyasint"`
DRepInactivityPeriod uint64 `cbor:"32,keyasint"`
MinFeeRefScriptCostPerByte *cbor.Rat `cbor:"33,keyasint"`
}

type PoolVotingThresholds struct {
cbor.StructAsArray
MotionNoConfidence cbor.Rat
CommitteeNormal cbor.Rat
CommitteeNoConfidence cbor.Rat
HardForkInitiation cbor.Rat
SecurityRelevantParameterVotingThreshold cbor.Rat
}

type DRepVotingThresholds struct {
cbor.StructAsArray
MotionNoConfidence cbor.Rat
CommitteeNormal cbor.Rat
CommitteeNoConfidence cbor.Rat
UpdateConstitution cbor.Rat
HardForkInitiation cbor.Rat
PPNetworkGroup cbor.Rat
PPEconomicGroup cbor.Rat
PPTechnicalGroup cbor.Rat
PPGovGroup cbor.Rat
TreasureWithdrawal cbor.Rat
}

// VotingProcedures is a convenience type to avoid needing to duplicate the full type definition everywhere
type VotingProcedures map[*Voter]map[*GovActionId]VotingProcedure

Expand Down Expand Up @@ -265,7 +314,7 @@ type ParameterChangeGovAction struct {
cbor.StructAsArray
Type uint
ActionId *GovActionId
ParamUpdate BabbageProtocolParameterUpdate // TODO: use Conway params update type
ParamUpdate ConwayProtocolParameterUpdate
PolicyHash []byte
}

Expand Down
12 changes: 7 additions & 5 deletions protocol/localstatequery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
QueryTypeShelleyCurrentProtocolParams,
)
switch currentEra {
case ledger.EraIdConway:
result := []ledger.ConwayProtocolParameters{}
if err := c.runQuery(query, &result); err != nil {
return nil, err
}
return result[0], nil
case ledger.EraIdBabbage:
result := []ledger.BabbageProtocolParameters{}
if err := c.runQuery(query, &result); err != nil {
Expand Down Expand Up @@ -379,11 +385,7 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
}
return result[0], nil
default:
result := []any{}
if err := c.runQuery(query, &result); err != nil {
return nil, err
}
return result[0], nil
return nil, fmt.Errorf("unknown era ID: %d", currentEra)
}
}

Expand Down

0 comments on commit 94c1fdf

Please sign in to comment.