From f3a59f9aebb986a70cf27f668c420b75314e4e42 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Krieger Date: Mon, 22 Jan 2024 10:18:27 -0300 Subject: [PATCH] fix(cli): fix proof in readerclient --- pkg/readerclient/proof.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/readerclient/proof.go b/pkg/readerclient/proof.go index 4a07121f2..ba6543183 100644 --- a/pkg/readerclient/proof.go +++ b/pkg/readerclient/proof.go @@ -36,7 +36,7 @@ type Proof struct { OutputHashesInEpochSiblings []hexutil.Bytes `json:"outputHashesInEpochSiblings"` // Data that allows the validity proof to be contextualized within submitted claims, // given as a payload in Ethereum hex binary format, starting with '0x' - Context string `json:"context"` + Context hexutil.Bytes `json:"context"` } func newProof( @@ -84,7 +84,10 @@ func newProof( for _, hash := range outputHashInOutputHashesSiblings { tempHash, err := hexutil.Decode(hash) if err != nil { - return nil, fmt.Errorf("failed to decode MachineStateHash to bytes: %v", err) + return nil, fmt.Errorf( + "failed to decode outputHashInOutputHashesSiblings to bytes: %v", + err, + ) } outputHashOutputSiblings = append(outputHashOutputSiblings, tempHash) @@ -93,11 +96,20 @@ func newProof( for _, hash := range outputHashesInEpochSiblings { tempHash, err := hexutil.Decode(hash) if err != nil { - return nil, fmt.Errorf("failed to decode MachineStateHash to bytes: %v", err) + return nil, fmt.Errorf( + "failed to decode outputHashesInEpochSiblings to bytes: %v", + err, + ) } - outputHashEpochSiblings = append(outputHashOutputSiblings, tempHash) + outputHashEpochSiblings = append(outputHashEpochSiblings, tempHash) } + + contextBytes, err := hexutil.Decode(context) + if err != nil { + return nil, fmt.Errorf("failed to decode Context to bytes: %v", err) + } + proof := Proof{ inputIndexWithinEpoch, outputIndexWithinInput, @@ -107,7 +119,7 @@ func newProof( machineHash, outputHashOutputSiblings, outputHashEpochSiblings, - context, + contextBytes, } return &proof, err