Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for Conway protocol parameter updates #673

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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