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: add Shelley protocol parameters support #587

Merged
merged 1 commit into from
Apr 17, 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
46 changes: 45 additions & 1 deletion ledger/shelley.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ type ShelleyTransactionBody struct {
Withdrawals cbor.Value `cbor:"5,keyasint,omitempty"`
Update struct {
cbor.StructAsArray
ProtocolParamUpdates cbor.Value
ProtocolParamUpdates map[Blake2b224]ShelleyProtocolParameterUpdate
Epoch uint64
} `cbor:"6,keyasint,omitempty"`
MetadataHash Blake2b256 `cbor:"7,keyasint,omitempty"`
Expand Down Expand Up @@ -397,6 +397,50 @@ func (t *ShelleyTransaction) Cbor() []byte {
return cborData
}

type ShelleyProtocolParameters struct {
cbor.StructAsArray
MinFeeA uint
MinFeeB uint
MaxBlockBodySize uint
MaxTxSize uint
MaxBlockHeaderSize uint
KeyDeposit uint
PoolDeposit uint
MaxEpoch uint
NOpt uint
A0 *cbor.Rat
Rho *cbor.Rat
Tau *cbor.Rat
Decentralization *cbor.Rat
Nonce *cbor.Rat
ProtocolMajor uint
ProtocolMinor uint
MinUtxoValue uint
}

type ShelleyProtocolParameterUpdate struct {
MinFeeA uint `cbor:"0,keyasint"`
MinFeeB uint `cbor:"1,keyasint"`
MaxBlockBodySize uint `cbor:"2,keyasint"`
MaxTxSize uint `cbor:"3,keyasint"`
MaxBlockHeaderSize uint `cbor:"4,keyasint"`
KeyDeposit uint `cbor:"5,keyasint"`
PoolDeposit uint `cbor:"6,keyasint"`
MaxEpoch uint `cbor:"7,keyasint"`
NOpt uint `cbor:"8,keyasint"`
A0 *cbor.Rat `cbor:"9,keyasint"`
Rho *cbor.Rat `cbor:"10,keyasint"`
Tau *cbor.Rat `cbor:"11,keyasint"`
Decentralization *cbor.Rat `cbor:"12,keyasint"`
Nonce *cbor.Rat `cbor:"13,keyasint"`
ProtocolVersion struct {
cbor.StructAsArray
Major uint
Minor uint
} `cbor:"14,keyasint"`
MinUtxoValue uint `cbor:"15,keyasint"`
}

func NewShelleyBlockFromCbor(data []byte) (*ShelleyBlock, error) {
var shelleyBlock ShelleyBlock
if _, err := cbor.Decode(data, &shelleyBlock); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions protocol/localstatequery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ func (c *Client) GetCurrentProtocolParams() (CurrentProtocolParamsResult, error)
return nil, err
}
return result[0], nil
case ledger.EraIdShelley:
result := []ledger.ShelleyProtocolParameters{}
if err := c.runQuery(query, &result); err != nil {
return nil, err
}
return result[0], nil
default:
result := []any{}
if err := c.runQuery(query, &result); err != nil {
Expand Down