Skip to content

Commit

Permalink
feat: Byron block version updates decode support (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
agaffney authored Oct 11, 2024
1 parent 160b264 commit 69fdfa5
Showing 1 changed file with 58 additions and 14 deletions.
72 changes: 58 additions & 14 deletions ledger/byron/byron.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,10 @@ type ByronMainBlockHeader struct {
}
ExtraData struct {
cbor.StructAsArray
BlockVersion struct {
cbor.StructAsArray
Major uint16
Minor uint16
Unknown uint8
}
SoftwareVersion struct {
cbor.StructAsArray
Name string
Unknown uint32
}
Attributes interface{}
ExtraProof common.Blake2b256
BlockVersion ByronBlockVersion
SoftwareVersion ByronSoftwareVersion
Attributes interface{}
ExtraProof common.Blake2b256
}
}

Expand Down Expand Up @@ -422,6 +413,59 @@ func (o ByronTransactionOutput) Utxorpc() *utxorpc.TxOutput {
}
}

type ByronBlockVersion struct {
cbor.StructAsArray
Major uint16
Minor uint16
Unknown uint8
}

type ByronSoftwareVersion struct {
cbor.StructAsArray
Name string
Version uint32
}

type ByronUpdatePayload struct {
cbor.StructAsArray
Proposals []ByronUpdateProposal
Votes []any
}

type ByronUpdateProposal struct {
cbor.DecodeStoreCbor
cbor.StructAsArray
BlockVersion ByronBlockVersion
BlockVersionMod ByronUpdateProposalBlockVersionMod
SoftwareVersion ByronSoftwareVersion
Data any
Attributes any
From []byte
Signature []byte
}

func (p *ByronUpdateProposal) UnmarshalCBOR(data []byte) error {
return p.UnmarshalCbor(data, p)
}

type ByronUpdateProposalBlockVersionMod struct {
cbor.StructAsArray
ScriptVersion []uint16
SlotDuration []uint64
MaxBlockSize []uint64
MaxHeaderSize []uint64
MaxTxSize []uint64
MaxProposalSize []uint64
MpcThd []uint64
HeavyDelThd []uint64
UpdateVoteThd []uint64
UpdateProposalThd []uint64
UpdateImplicit []uint64
SoftForkRule []any
TxFeePolicy []any
UnlockStakeEpoch []uint64
}

type ByronMainBlockBody struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Expand All @@ -434,7 +478,7 @@ type ByronMainBlockBody struct {
}
SscPayload cbor.Value
DlgPayload []interface{}
UpdPayload []interface{}
UpdPayload ByronUpdatePayload
}

func (b *ByronMainBlockBody) UnmarshalCBOR(data []byte) error {
Expand Down

0 comments on commit 69fdfa5

Please sign in to comment.