Skip to content

Commit d715aec

Browse files
fix: calculate txSeqMetadata in VerifyBlockBody (#667)
1 parent b9d40a8 commit d715aec

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed

ledger/verify_block_body.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func VerifyBlockBody(data string, blockBodyHash string) (bool, error) {
7878
func CalculateBlockBodyHash(txsRaw [][]string) ([]byte, error) {
7979
var txSeqBody []cbor.RawMessage
8080
var txSeqWit []cbor.RawMessage
81-
txSeqMetadata := map[uint64]cbor.RawTag{}
81+
txSeqMetadata := make(map[uint64]interface{}, len(txsRaw))
8282
txSeqNonValid := []uint{}
8383
for index, tx := range txsRaw {
8484
if len(tx) != 3 {
@@ -121,11 +121,18 @@ func CalculateBlockBodyHash(txsRaw [][]string) ([]byte, error) {
121121
auxBytesError.Error(),
122122
)
123123
}
124-
// Cardano use Tag 259 for this when encCbor
125-
// Ref: https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxAuxData.hs#L125
126-
txSeqMetadata[uint64(index)] = cbor.RawTag{
127-
Number: 259, Content: auxBytes,
124+
125+
var auxInterface interface{}
126+
_, auxDecodeError := cbor.Decode(auxBytes, &auxInterface)
127+
if auxDecodeError != nil {
128+
return nil, fmt.Errorf(
129+
"CalculateBlockBodyHash: decode aux tx[%v] error, %v",
130+
index,
131+
auxDecodeError.Error(),
132+
)
128133
}
134+
135+
txSeqMetadata[uint64(index)] = auxInterface
129136
}
130137
// TODO: should form nonValid TX here
131138
}

0 commit comments

Comments
 (0)