-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add da submission data and result query
- Loading branch information
fiamma-builder
committed
Oct 30, 2024
1 parent
b5a72a8
commit 9132c54
Showing
10 changed files
with
3,431 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
: ${CHAIN_ID:="fiamma-testnet-1"} | ||
: ${NODE:="http://127.0.0.1:26657"} | ||
: ${PROOF_FILE:=../../prover_examples/bitvm/proof.bitvm} | ||
: ${PUBLIC_INPUT_FILE:=../../prover_examples/bitvm/public_input.bitvm} | ||
: ${VK_FILE:=../../prover_examples/bitvm/vk.bitvm} | ||
: ${NAMESPACE:="TEST"} | ||
: ${PROOF_SYSTEM:="GROTH16_BN254_BITVM"} | ||
: ${DATA_LOCATION:="FIAMMA"} | ||
|
||
NEW_NAMESPACE=$(echo -n $NAMESPACE | xxd -p) | ||
|
||
NEW_PROOF_SYSTEM=$(echo -n $PROOF_SYSTEM | xxd -p) | ||
|
||
NEW_PROOF=$(xxd -p -c 256 $PROOF_FILE | tr -d '\n') | ||
|
||
NEW_PUBLIC_INPUT=$(xxd -p -c 256 $PUBLIC_INPUT_FILE | tr -d '\n') | ||
|
||
NEW_VK=$(xxd -p -c 256 $VK_FILE | tr -d '\n') | ||
|
||
NEW_DATA_LOCATION=$(echo -n $DATA_LOCATION | xxd -p) | ||
|
||
# Concatenate the proof, public input, and vk | ||
allDataHex="${NEW_NAMESPACE}${NEW_PROOF_SYSTEM}${NEW_PROOF}${NEW_PUBLIC_INPUT}${NEW_VK}${NEW_DATA_LOCATION}" | ||
|
||
proof_id=$(echo -n "$allDataHex" | xxd -r -p | sha256sum | awk '{print $1}') | ||
|
||
fiammad query zkpverify get-da-submission-data $proof_id --node $NODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
: ${CHAIN_ID:="fiamma-testnet-1"} | ||
: ${NODE:="http://127.0.0.1:26657"} | ||
: ${PROOF_FILE:=../../prover_examples/bitvm/proof.bitvm} | ||
: ${PUBLIC_INPUT_FILE:=../../prover_examples/bitvm/public_input.bitvm} | ||
: ${VK_FILE:=../../prover_examples/bitvm/vk.bitvm} | ||
: ${NAMESPACE:="TEST"} | ||
: ${PROOF_SYSTEM:="GROTH16_BN254_BITVM"} | ||
: ${DATA_LOCATION:="FIAMMA"} | ||
|
||
NEW_NAMESPACE=$(echo -n $NAMESPACE | xxd -p) | ||
|
||
NEW_PROOF_SYSTEM=$(echo -n $PROOF_SYSTEM | xxd -p) | ||
|
||
NEW_PROOF=$(xxd -p -c 256 $PROOF_FILE | tr -d '\n') | ||
|
||
NEW_PUBLIC_INPUT=$(xxd -p -c 256 $PUBLIC_INPUT_FILE | tr -d '\n') | ||
|
||
NEW_VK=$(xxd -p -c 256 $VK_FILE | tr -d '\n') | ||
|
||
NEW_DATA_LOCATION=$(echo -n $DATA_LOCATION | xxd -p) | ||
|
||
# Concatenate the proof, public input, and vk | ||
allDataHex="${NEW_NAMESPACE}${NEW_PROOF_SYSTEM}${NEW_PROOF}${NEW_PUBLIC_INPUT}${NEW_VK}${NEW_DATA_LOCATION}" | ||
|
||
proof_id=$(echo -n "$allDataHex" | xxd -r -p | sha256sum | awk '{print $1}') | ||
|
||
fiammad query zkpverify get-da-submission-result $proof_id --node $NODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
"encoding/hex" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/fiamma-chain/fiamma/x/zkpverify/types" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
func (k Keeper) DaSubmissionData(goCtx context.Context, req *types.QueryDaSubmissionDataRequest) (*types.QueryDaSubmissionDataResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid request") | ||
} | ||
|
||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
proofId, err := hex.DecodeString(req.ProofId) | ||
if err != nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid proof id") | ||
} | ||
|
||
data, found := k.GetDASubmissionData(ctx, proofId) | ||
if !found { | ||
return nil, status.Error(codes.NotFound, "da submission data not found") | ||
} | ||
|
||
return &types.QueryDaSubmissionDataResponse{ | ||
DaSubmissionData: &data, | ||
}, nil | ||
} | ||
|
||
func (k Keeper) DaSubmissionResult(goCtx context.Context, req *types.QueryDaSubmissionResultRequest) (*types.QueryDaSubmissionResultResponse, error) { | ||
if req == nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid request") | ||
} | ||
|
||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
proofId, err := hex.DecodeString(req.ProofId) | ||
if err != nil { | ||
return nil, status.Error(codes.InvalidArgument, "invalid proof id") | ||
} | ||
|
||
result, found := k.GetDASubmissionResult(ctx, proofId) | ||
if !found { | ||
return nil, status.Error(codes.NotFound, "da submission result not found") | ||
} | ||
|
||
return &types.QueryDaSubmissionResultResponse{ | ||
DaSubmissionResult: &result, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.