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: Byron block version updates decode support #754

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
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