Skip to content

Commit

Permalink
fix: calculate txSeqMetadata in VerifyBlockBody (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
huynq-smartosc authored Jul 11, 2024
1 parent b9d40a8 commit d715aec
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ledger/verify_block_body.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func VerifyBlockBody(data string, blockBodyHash string) (bool, error) {
func CalculateBlockBodyHash(txsRaw [][]string) ([]byte, error) {
var txSeqBody []cbor.RawMessage
var txSeqWit []cbor.RawMessage
txSeqMetadata := map[uint64]cbor.RawTag{}
txSeqMetadata := make(map[uint64]interface{}, len(txsRaw))
txSeqNonValid := []uint{}
for index, tx := range txsRaw {
if len(tx) != 3 {
Expand Down Expand Up @@ -121,11 +121,18 @@ func CalculateBlockBodyHash(txsRaw [][]string) ([]byte, error) {
auxBytesError.Error(),
)
}
// Cardano use Tag 259 for this when encCbor
// Ref: https://github.com/IntersectMBO/cardano-ledger/blob/master/eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxAuxData.hs#L125
txSeqMetadata[uint64(index)] = cbor.RawTag{
Number: 259, Content: auxBytes,

var auxInterface interface{}
_, auxDecodeError := cbor.Decode(auxBytes, &auxInterface)
if auxDecodeError != nil {
return nil, fmt.Errorf(
"CalculateBlockBodyHash: decode aux tx[%v] error, %v",
index,
auxDecodeError.Error(),
)
}

txSeqMetadata[uint64(index)] = auxInterface
}
// TODO: should form nonValid TX here
}
Expand Down
Loading

0 comments on commit d715aec

Please sign in to comment.