Skip to content

Commit

Permalink
fix: match submitted ext with block ext properly (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRampey authored May 6, 2024
1 parent 894d104 commit 4432ff9
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions availda/availda.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,35 @@ out:
var extIndex int
for idx, e := range block.Block.Extrinsics {
// Look for our submitted extrinsic in the block
if ext.Signature.Signature.AsEcdsa.Hex() == e.Signature.Signature.AsEcdsa.Hex() {
extBytes, err := json.Marshal(ext)
if err != nil {
continue
}
extBytes = []byte(strings.Trim(string(extBytes), "\""))

eBytes, err := json.Marshal(e)
if err != nil {
continue
}
eBytes = []byte(strings.Trim(string(eBytes), "\""))
if string(extBytes) == string(eBytes) {
extIndex = idx
resp, err := http.Post(a.config.HttpApiURL, "application/json",
strings.NewReader(fmt.Sprintf("{\"id\":1,\"jsonrpc\":\"2.0\",\"method\":\"kate_queryDataProofV2\",\"params\":[%d, \"%#x\"]}", idx+1, blockHash))) //nolint: noctx
if err != nil {
return nil, nil, fmt.Errorf("cannot post query request", err)
break
}
data, err := io.ReadAll(resp.Body)
if err != nil {
return nil, nil, fmt.Errorf("cannot read body", err)
break
}
err = resp.Body.Close()
if err != nil {
return nil, nil, fmt.Errorf("cannot close body", err)
break
}
err = json.Unmarshal(data, &dataProofResp)
if err != nil {
return nil, nil, fmt.Errorf("cannot unmarshal data proof: %w", err)
break
}

if dataProofResp.Result.DataProof.Leaf == fmt.Sprintf("%#x", batchHash) {
Expand Down

0 comments on commit 4432ff9

Please sign in to comment.