From c2b115cd5218a0bc0066ad31c2e3b63e229c6acb Mon Sep 17 00:00:00 2001 From: marston Date: Tue, 5 Dec 2023 16:46:54 -0500 Subject: [PATCH 1/2] state transactions and proofs for file data complete --- proto/canine_chain/storage/oracle.proto | 22 + proto/canine_chain/storage/tx.proto | 27 + x/storage/handler.go | 7 +- x/storage/keeper/msg_server_oracle.go | 104 ++ x/storage/keeper/msg_server_oracle_test.go | 130 ++ x/storage/keeper/oracle.go | 157 +++ x/storage/types/file_deal.go | 27 +- x/storage/types/key_oracle.go | 31 + x/storage/types/message_oracle.go | 104 ++ x/storage/types/oracle.pb.go | 778 ++++++++++++ x/storage/types/tx.pb.go | 1275 ++++++++++++++++++-- x/storage/utils/trees.go | 42 +- 12 files changed, 2561 insertions(+), 143 deletions(-) create mode 100644 proto/canine_chain/storage/oracle.proto create mode 100644 x/storage/keeper/msg_server_oracle.go create mode 100644 x/storage/keeper/msg_server_oracle_test.go create mode 100644 x/storage/keeper/oracle.go create mode 100644 x/storage/types/key_oracle.go create mode 100644 x/storage/types/message_oracle.go create mode 100644 x/storage/types/oracle.pb.go diff --git a/proto/canine_chain/storage/oracle.proto b/proto/canine_chain/storage/oracle.proto new file mode 100644 index 000000000..99a99e9be --- /dev/null +++ b/proto/canine_chain/storage/oracle.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package canine_chain.storage; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + +option go_package = "github.com/jackalLabs/canine-chain/x/storage/types"; + + +message OracleRequest { + string requester = 1; + bytes merkle = 2; // file identifier that we want + int64 chunk = 3; // the chunk we want to have accessible on chain + cosmos.base.v1beta1.Coin bid = 4 [ (gogoproto.nullable) = false ]; +} + +message OracleEntry { + string owner = 1; + bytes merkle = 2; // file identifier that we want + int64 chunk = 3; // the chunk we want to have accessible on chain + bytes data = 4; // the data from the file +} \ No newline at end of file diff --git a/proto/canine_chain/storage/tx.proto b/proto/canine_chain/storage/tx.proto index b08600e61..cfa58146d 100644 --- a/proto/canine_chain/storage/tx.proto +++ b/proto/canine_chain/storage/tx.proto @@ -1,6 +1,9 @@ syntax = "proto3"; package canine_chain.storage; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + option go_package = "github.com/jackalLabs/canine-chain/x/storage/types"; service Msg { @@ -21,6 +24,10 @@ service Msg { rpc Attest(MsgAttest) returns (MsgAttestResponse); rpc RequestReportForm(MsgRequestReportForm) returns (MsgRequestReportFormResponse); rpc Report(MsgReport) returns (MsgReportResponse); + + // oracle stuff + rpc RequestChunk(MsgRequestChunk) returns (MsgRequestChunkResponse); + rpc FulfillRequest(MsgFulfillRequest) returns (MsgFulfillRequestResponse); } message MsgPostFile { @@ -168,3 +175,23 @@ message MsgReport { } message MsgReportResponse {} + +message MsgRequestChunk { + string creator = 1; + bytes merkle = 2; + int64 chunk = 3; + cosmos.base.v1beta1.Coin bid = 4 [ (gogoproto.nullable) = false ]; +} + +message MsgRequestChunkResponse {} + +message MsgFulfillRequest { + string creator = 1; + string requester = 2; + bytes merkle = 3; + int64 chunk = 4; + bytes data = 5; + bytes hash_list = 6; +} + +message MsgFulfillRequestResponse {} \ No newline at end of file diff --git a/x/storage/handler.go b/x/storage/handler.go index 7a21aceff..9efbad804 100644 --- a/x/storage/handler.go +++ b/x/storage/handler.go @@ -44,7 +44,6 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgBuyStorage: res, err := msgServer.BuyStorage(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgAddClaimer: res, err := msgServer.AddProviderClaimer(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) @@ -63,6 +62,12 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgReport: res, err := msgServer.Report(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgRequestChunk: + res, err := msgServer.RequestChunk(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgFulfillRequest: + res, err := msgServer.FulfillRequest(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/storage/keeper/msg_server_oracle.go b/x/storage/keeper/msg_server_oracle.go new file mode 100644 index 000000000..98a83984d --- /dev/null +++ b/x/storage/keeper/msg_server_oracle.go @@ -0,0 +1,104 @@ +package keeper + +import ( + "context" + "encoding/hex" + + "github.com/jackalLabs/canine-chain/v3/x/storage/utils" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerr "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/jackalLabs/canine-chain/v3/x/storage/types" +) + +func MakeAddress() (sdk.AccAddress, error) { + oracleAddressString := "storage_oracle" + oracleAddressHex := hex.EncodeToString([]byte(oracleAddressString)) + return sdk.AccAddressFromHex(oracleAddressHex) +} + +func (k msgServer) RequestChunk(goCtx context.Context, msg *types.MsgRequestChunk) (*types.MsgRequestChunkResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + bid := msg.Bid + bidAsCoins := sdk.NewCoins(bid) + + creatorAddress, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, sdkerr.Wrapf(err, "cannot get address from %s", msg.Creator) + } + + oracleAddress, err := MakeAddress() + if err != nil { + return nil, sdkerr.Wrap(err, "could not make oracle address") + } + + err = k.bankkeeper.SendCoinsFromAccountToModule(ctx, creatorAddress, types.ModuleName, bidAsCoins) + if err != nil { + return nil, sdkerr.Wrap(err, "user does not have enough coins") + } + err = k.bankkeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, oracleAddress, bidAsCoins) + if err != nil { + return nil, sdkerr.Wrap(err, "somehow the module itself ate all our coins, we need to fail here") + } + + req := types.OracleRequest{ + Requester: msg.Creator, + Merkle: msg.Merkle, + Chunk: msg.Chunk, + Bid: bid, + } + + k.SetOracleRequest(ctx, req) + + return &types.MsgRequestChunkResponse{}, nil +} + +func (k msgServer) FulfillRequest(goCtx context.Context, msg *types.MsgFulfillRequest) (*types.MsgFulfillRequestResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + verified := utils.VerifyProof(msg.Merkle, msg.HashList, msg.Chunk, msg.Data) + if !verified { + return nil, sdkerr.Wrap(sdkerr.ErrUnauthorized, "cannot verify data against merkle") + } + + req, found := k.GetOracleRequest(ctx, msg.Requester, msg.Merkle, msg.Chunk) + if !found { + return nil, sdkerr.Wrap(sdkerr.ErrNotFound, "cannot find oracle request") + } + + bid := req.Bid + bidAsCoins := sdk.NewCoins(bid) + + oracleAddress, err := MakeAddress() + if err != nil { + return nil, sdkerr.Wrap(err, "could not make oracle address") + } + creatorAddress, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, sdkerr.Wrapf(err, "could not make user address from %s", msg.Creator) + } + + err = k.bankkeeper.SendCoinsFromAccountToModule(ctx, oracleAddress, types.ModuleName, bidAsCoins) + if err != nil { + return nil, sdkerr.Wrap(err, "oracle somehow does not have enough coins") + } + err = k.bankkeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, creatorAddress, bidAsCoins) + if err != nil { + return nil, sdkerr.Wrap(err, "somehow the module itself ate all our coins, we need to fail here") + } + + entry := types.OracleEntry{ + Owner: msg.Requester, + Merkle: msg.Merkle, + Chunk: msg.Chunk, + Data: msg.Data, + } + + k.SetOracleEntry(ctx, entry) + + k.RemoveOracleRequest(ctx, msg.Requester, msg.Merkle, msg.Chunk) + + return &types.MsgFulfillRequestResponse{}, nil +} diff --git a/x/storage/keeper/msg_server_oracle_test.go b/x/storage/keeper/msg_server_oracle_test.go new file mode 100644 index 000000000..ceffe1abb --- /dev/null +++ b/x/storage/keeper/msg_server_oracle_test.go @@ -0,0 +1,130 @@ +package keeper_test + +import ( + "bytes" + "crypto/sha256" + "encoding/json" + "fmt" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/jackalLabs/canine-chain/v3/testutil" + "github.com/jackalLabs/canine-chain/v3/x/storage/keeper" + "github.com/jackalLabs/canine-chain/v3/x/storage/types" + "github.com/jackalLabs/canine-chain/v3/x/storage/utils" + + "github.com/stretchr/testify/require" +) + +func TestMakeAddress(t *testing.T) { + address, err := keeper.MakeAddress() + require.NoError(t, err) + t.Log(address.String()) +} + +func (suite *KeeperTestSuite) TestRequestAndFulfillOracle() { + suite.SetupSuite() + msgSrvr, k, ctx := setupMsgServer(suite) + + replicaFileData := []byte("this is test data for a tree I will be testing against. BLOCKCHAIN AND STORAGE NETWORK DELIVERING ON-CHAIN ACCESS TO DATA STORAGE EVERYWHERE.") + fileData := []byte("this is test data for a tree I will be testing against. BLOCKCHAIN AND STORAGE NETWORK DELIVERING ON-CHAIN ACCESS TO DATA STORAGE EVERYWHERE.") + buf := bytes.NewBuffer(fileData) + var chunkSize int64 = 2 + tree, _, _, err := utils.BuildJustTree(buf, chunkSize) + suite.Require().NoError(err) + + suite.T().Log(tree.Data) + + testAddresses, err := testutil.CreateTestAddresses("cosmos", 3) + suite.Require().NoError(err) + + testAccount := testAddresses[0] + testOracleAccount := testAddresses[2] + depoAccount := testAddresses[1] + + coins := sdk.NewCoins(sdk.NewCoin("ujkl", sdk.NewInt(100000000000))) // Send some coins to their account + testAcc, _ := sdk.AccAddressFromBech32(testAccount) + err = suite.bankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, testAcc, coins) + suite.Require().NoError(err) + + suite.storageKeeper.SetParams(suite.ctx, types.Params{ + DepositAccount: depoAccount, + ProofWindow: 50, + ChunkSize: chunkSize, + PriceFeed: "jklprice", + MissesToBurn: 3, + MaxContractAgeInBlocks: 100, + PricePerTbPerMonth: 8, + CollateralPrice: 2, + CheckWindow: 10, + }) + + testMerkle := tree.Root() + var chunk int64 = 10 + index := chunk * chunkSize + chunkData := replicaFileData[index : index+chunkSize] + + h := sha256.New() + _, err = h.Write([]byte(fmt.Sprintf("%d%x", chunk, chunkData))) + suite.Require().NoError(err) + + c := h.Sum(nil) + + proof, err := tree.GenerateProof(c, 0) + suite.Require().NoError(err) + jproof, err := json.Marshal(*proof) + suite.Require().NoError(err) + + bid, err := sdk.ParseCoinNormalized("500ujkl") + suite.Require().NoError(err) + + requestChunkMessage := types.MsgRequestChunk{ + Creator: testAccount, + Merkle: testMerkle, + Chunk: chunk, + Bid: bid, + } + + _, err = msgSrvr.RequestChunk(ctx, &requestChunkMessage) + suite.Require().NoError(err) + + _, found := k.GetOracleRequest(suite.ctx, testAccount, testMerkle, chunk) + suite.Require().True(found) + + fulfillMessage := types.MsgFulfillRequest{ + Creator: testOracleAccount, + Requester: testAccount, + Merkle: testMerkle, + Chunk: chunk, + Data: chunkData, + HashList: jproof, + } + + _, err = msgSrvr.FulfillRequest(ctx, &fulfillMessage) + suite.Require().NoError(err) + + _, found = k.GetOracleRequest(suite.ctx, testAccount, testMerkle, chunk) + suite.Require().False(found) + + _, found = k.GetOracleEntry(suite.ctx, testAccount, testMerkle, chunk) + suite.Require().True(found) + + all := k.GetAllOracleEntries(suite.ctx) + for _, entry := range all { + suite.T().Log(entry.String()) + } + + tAcc, err := sdk.AccAddressFromBech32(testAccount) + suite.Require().NoError(err) + + oAcc, err := sdk.AccAddressFromBech32(testOracleAccount) + suite.Require().NoError(err) + + bal := suite.bankKeeper.GetBalance(suite.ctx, oAcc, "ujkl") + suite.Require().Equal(int64(500), bal.Amount.Int64()) + + bal = suite.bankKeeper.GetBalance(suite.ctx, tAcc, "ujkl") + suite.Require().Equal(int64(100000000000-500), bal.Amount.Int64()) + + suite.reset() +} diff --git a/x/storage/keeper/oracle.go b/x/storage/keeper/oracle.go new file mode 100644 index 000000000..4c1d944d0 --- /dev/null +++ b/x/storage/keeper/oracle.go @@ -0,0 +1,157 @@ +//nolint:all +package keeper + +import ( + "bytes" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/jackalLabs/canine-chain/v3/x/storage/types" +) + +// SetOracleRequest set a specific oracle request in the store from its index +func (k Keeper) SetOracleRequest(ctx sdk.Context, req types.OracleRequest) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleRequestKey)) + b := k.cdc.MustMarshal(&req) + store.Set(types.RequestKey( + req.Requester, + req.Merkle, + req.Chunk, + ), b) +} + +// GetOracleRequest returns an oracle request from its index +func (k Keeper) GetOracleRequest( + ctx sdk.Context, + owner string, + merkle []byte, + chunk int64, +) (val types.OracleRequest, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleRequestKey)) + + b := store.Get(types.RequestKey( + owner, + merkle, + chunk, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveOracleRequest removes a activeDeals from the store +func (k Keeper) RemoveOracleRequest( + ctx sdk.Context, + owner string, + merkle []byte, + chunk int64, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleRequestKey)) + store.Delete(types.RequestKey( + owner, + merkle, + chunk, + )) +} + +// GetAllOracleRequests returns all oracle requests +func (k Keeper) GetAllOracleRequests(ctx sdk.Context) (list []types.OracleRequest) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleRequestKey)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.OracleRequest + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// SetOracleEntry set a specific oracle entry in the store from its index +func (k Keeper) SetOracleEntry(ctx sdk.Context, req types.OracleEntry) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleEntryKey)) + b := k.cdc.MustMarshal(&req) + store.Set(types.EntryKey( + req.Owner, + req.Merkle, + req.Chunk, + ), b) +} + +// GetOracleEntry returns an oracle entry from its index +func (k Keeper) GetOracleEntry( + ctx sdk.Context, + owner string, + merkle []byte, + chunk int64, +) (val types.OracleEntry, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleEntryKey)) + + b := store.Get(types.EntryKey( + owner, + merkle, + chunk, + )) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveOracleEntry removes a activeDeals from the store +func (k Keeper) RemoveOracleEntry( + ctx sdk.Context, + owner string, + merkle []byte, + chunk int64, +) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleEntryKey)) + store.Delete(types.EntryKey( + owner, + merkle, + chunk, + )) +} + +// GetAllOracleEntries returns all oracle entries +func (k Keeper) GetAllOracleEntries(ctx sdk.Context) (list []types.OracleEntry) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleEntryKey)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.OracleEntry + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// GetGeneralOracleEntry returns the first oracle entry matching the merkle and chunk +func (k Keeper) GetGeneralOracleEntry(ctx sdk.Context, merkle []byte, chunk int64) (*types.OracleEntry, error) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.OracleEntryKey)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val *types.OracleEntry + k.cdc.MustUnmarshal(iterator.Value(), val) + if bytes.Equal(val.Merkle, merkle) && val.Chunk == chunk { + return val, nil + } + } + + return nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "cannot find the oracle entry with merkle: %x and chunk %d", merkle, chunk) +} diff --git a/x/storage/types/file_deal.go b/x/storage/types/file_deal.go index 13397becc..0d105039c 100644 --- a/x/storage/types/file_deal.go +++ b/x/storage/types/file_deal.go @@ -1,40 +1,19 @@ package types import ( - "crypto/sha256" - "encoding/json" "fmt" - "io" "strings" + "github.com/jackalLabs/canine-chain/v3/x/storage/utils" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerror "github.com/cosmos/cosmos-sdk/types/errors" "github.com/tendermint/tendermint/libs/rand" - "github.com/wealdtech/go-merkletree/v2" - "github.com/wealdtech/go-merkletree/v2/sha3" ) // VerifyProof checks whether a proof is valid against a file func (f *UnifiedFile) VerifyProof(proofData []byte, chunk int64, item []byte) bool { - h := sha256.New() - _, err := io.WriteString(h, fmt.Sprintf("%d%x", chunk, item)) - if err != nil { - return false - } - hashName := h.Sum(nil) - - var proof merkletree.Proof // unmarshal proof - err = json.Unmarshal(proofData, &proof) - if err != nil { - return false - } - - verified, err := merkletree.VerifyProofUsing(hashName, false, &proof, [][]byte{f.Merkle}, sha3.New512()) - if err != nil { - return false - } - - return verified + return utils.VerifyProof(f.Merkle, proofData, chunk, item) } func (f *UnifiedFile) AddProver(ctx sdk.Context, k ProofLoader, prover string) *FileProof { diff --git a/x/storage/types/key_oracle.go b/x/storage/types/key_oracle.go new file mode 100644 index 000000000..f803b1306 --- /dev/null +++ b/x/storage/types/key_oracle.go @@ -0,0 +1,31 @@ +package types + +import ( + "encoding/binary" + "fmt" +) + +var _ binary.ByteOrder + +const ( + OracleRequestKey = "OracleRequest/value/" + OracleEntryKey = "OracleEntry/value/" +) + +// RequestKey returns the store key to retrieve an oracle request from the index fields ordered by merkle +func RequestKey( + owner string, + merkle []byte, + chunk int64, +) []byte { + return []byte(fmt.Sprintf("%x/%d/%s/", merkle, chunk, owner)) +} + +// EntryKey returns the store key to retrieve an oracle entry from the index fields ordered by merkle +func EntryKey( + owner string, + merkle []byte, + chunk int64, +) []byte { + return []byte(fmt.Sprintf("%x/%d/%s/", merkle, chunk, owner)) +} diff --git a/x/storage/types/message_oracle.go b/x/storage/types/message_oracle.go new file mode 100644 index 000000000..f6a8c8b33 --- /dev/null +++ b/x/storage/types/message_oracle.go @@ -0,0 +1,104 @@ +package types + +import ( + fmt "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/bech32" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + TypeMsgRequestChunk = "request_oracle_chunk" + TypeMsgFulfillRequest = "fulfill_oracle_request" +) + +var ( + _ sdk.Msg = &MsgRequestChunk{} + _ sdk.Msg = &MsgFulfillRequest{} +) + +func NewMsgRequestChunk(creator string, merkle []byte, chunk int64, bid sdk.Coin) *MsgRequestChunk { + return &MsgRequestChunk{ + Creator: creator, + Merkle: merkle, + Chunk: chunk, + Bid: bid, + } +} + +func (msg *MsgRequestChunk) Route() string { + return RouterKey +} + +func (msg *MsgRequestChunk) Type() string { + return TypeMsgRequestChunk +} + +func (msg *MsgRequestChunk) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgRequestChunk) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgRequestChunk) ValidateBasic() error { + prefix, _, err := bech32.DecodeAndConvert(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + if prefix != AddressPrefix { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator prefix (%s)", fmt.Errorf("%s is not a valid prefix here. Expected `jkl`", prefix)) + } + + return nil +} + +func NewMsgFulfillRequest(creator string, merkle []byte, requester string, chunk int64, data []byte) *MsgFulfillRequest { + return &MsgFulfillRequest{ + Creator: creator, + Merkle: merkle, + Requester: requester, + Chunk: chunk, + Data: data, + } +} + +func (msg *MsgFulfillRequest) Route() string { + return RouterKey +} + +func (msg *MsgFulfillRequest) Type() string { + return TypeMsgFulfillRequest +} + +func (msg *MsgFulfillRequest) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgFulfillRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgFulfillRequest) ValidateBasic() error { + prefix, _, err := bech32.DecodeAndConvert(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + if prefix != AddressPrefix { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator prefix (%s)", fmt.Errorf("%s is not a valid prefix here. Expected `jkl`", prefix)) + } + + return nil +} diff --git a/x/storage/types/oracle.pb.go b/x/storage/types/oracle.pb.go new file mode 100644 index 000000000..f874e81da --- /dev/null +++ b/x/storage/types/oracle.pb.go @@ -0,0 +1,778 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: canine_chain/storage/oracle.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type OracleRequest struct { + Requester string `protobuf:"bytes,1,opt,name=requester,proto3" json:"requester,omitempty"` + Merkle []byte `protobuf:"bytes,2,opt,name=merkle,proto3" json:"merkle,omitempty"` + Chunk int64 `protobuf:"varint,3,opt,name=chunk,proto3" json:"chunk,omitempty"` + Bid types.Coin `protobuf:"bytes,4,opt,name=bid,proto3" json:"bid"` +} + +func (m *OracleRequest) Reset() { *m = OracleRequest{} } +func (m *OracleRequest) String() string { return proto.CompactTextString(m) } +func (*OracleRequest) ProtoMessage() {} +func (*OracleRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_bee5b363fbde19aa, []int{0} +} +func (m *OracleRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleRequest.Merge(m, src) +} +func (m *OracleRequest) XXX_Size() int { + return m.Size() +} +func (m *OracleRequest) XXX_DiscardUnknown() { + xxx_messageInfo_OracleRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleRequest proto.InternalMessageInfo + +func (m *OracleRequest) GetRequester() string { + if m != nil { + return m.Requester + } + return "" +} + +func (m *OracleRequest) GetMerkle() []byte { + if m != nil { + return m.Merkle + } + return nil +} + +func (m *OracleRequest) GetChunk() int64 { + if m != nil { + return m.Chunk + } + return 0 +} + +func (m *OracleRequest) GetBid() types.Coin { + if m != nil { + return m.Bid + } + return types.Coin{} +} + +type OracleEntry struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` + Merkle []byte `protobuf:"bytes,2,opt,name=merkle,proto3" json:"merkle,omitempty"` + Chunk int64 `protobuf:"varint,3,opt,name=chunk,proto3" json:"chunk,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *OracleEntry) Reset() { *m = OracleEntry{} } +func (m *OracleEntry) String() string { return proto.CompactTextString(m) } +func (*OracleEntry) ProtoMessage() {} +func (*OracleEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_bee5b363fbde19aa, []int{1} +} +func (m *OracleEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OracleEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_OracleEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *OracleEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_OracleEntry.Merge(m, src) +} +func (m *OracleEntry) XXX_Size() int { + return m.Size() +} +func (m *OracleEntry) XXX_DiscardUnknown() { + xxx_messageInfo_OracleEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_OracleEntry proto.InternalMessageInfo + +func (m *OracleEntry) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *OracleEntry) GetMerkle() []byte { + if m != nil { + return m.Merkle + } + return nil +} + +func (m *OracleEntry) GetChunk() int64 { + if m != nil { + return m.Chunk + } + return 0 +} + +func (m *OracleEntry) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func init() { + proto.RegisterType((*OracleRequest)(nil), "canine_chain.storage.OracleRequest") + proto.RegisterType((*OracleEntry)(nil), "canine_chain.storage.OracleEntry") +} + +func init() { proto.RegisterFile("canine_chain/storage/oracle.proto", fileDescriptor_bee5b363fbde19aa) } + +var fileDescriptor_bee5b363fbde19aa = []byte{ + // 311 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xc1, 0x4e, 0xf2, 0x40, + 0x14, 0x85, 0x3b, 0x3f, 0xfc, 0x24, 0x0c, 0xb8, 0x69, 0x88, 0xa9, 0xc4, 0x8c, 0x95, 0x55, 0x37, + 0xce, 0x04, 0x7c, 0x03, 0x8c, 0x3b, 0x12, 0x93, 0x2e, 0xdd, 0x98, 0xe9, 0x70, 0x53, 0x2a, 0x30, + 0x17, 0x67, 0x06, 0x95, 0x97, 0x30, 0x3e, 0x16, 0x4b, 0x96, 0xae, 0x8c, 0x81, 0x17, 0x31, 0xed, + 0x34, 0xe8, 0xd6, 0xdd, 0x39, 0x37, 0xe7, 0xde, 0x7c, 0xb9, 0x87, 0x5e, 0x2a, 0xa9, 0x0b, 0x0d, + 0x0f, 0x6a, 0x26, 0x0b, 0x2d, 0xac, 0x43, 0x23, 0x73, 0x10, 0x68, 0xa4, 0x5a, 0x00, 0x5f, 0x19, + 0x74, 0x18, 0xf6, 0x7e, 0x47, 0x78, 0x1d, 0xe9, 0x33, 0x85, 0x76, 0x89, 0x56, 0x64, 0xd2, 0x82, + 0x78, 0x1e, 0x66, 0xe0, 0xe4, 0x50, 0x28, 0x2c, 0xb4, 0xdf, 0xea, 0xf7, 0x72, 0xcc, 0xb1, 0x92, + 0xa2, 0x54, 0x7e, 0x3a, 0x78, 0x23, 0xf4, 0xe4, 0xae, 0x3a, 0x9e, 0xc2, 0xd3, 0x1a, 0xac, 0x0b, + 0xcf, 0x69, 0xdb, 0x78, 0x09, 0x26, 0x22, 0x31, 0x49, 0xda, 0xe9, 0xcf, 0x20, 0x3c, 0xa5, 0xad, + 0x25, 0x98, 0xf9, 0x02, 0xa2, 0x7f, 0x31, 0x49, 0xba, 0x69, 0xed, 0xc2, 0x1e, 0xfd, 0xaf, 0x66, + 0x6b, 0x3d, 0x8f, 0x1a, 0x31, 0x49, 0x1a, 0xa9, 0x37, 0xe1, 0x90, 0x36, 0xb2, 0x62, 0x1a, 0x35, + 0x63, 0x92, 0x74, 0x46, 0x67, 0xdc, 0x13, 0xf2, 0x92, 0x90, 0xd7, 0x84, 0xfc, 0x06, 0x0b, 0x3d, + 0x6e, 0x6e, 0x3f, 0x2f, 0x82, 0xb4, 0xcc, 0x0e, 0x80, 0x76, 0x3c, 0xcf, 0xad, 0x76, 0x66, 0x53, + 0xde, 0xc5, 0x17, 0x7d, 0x24, 0xf1, 0xe6, 0x8f, 0x14, 0x21, 0x6d, 0x4e, 0xa5, 0x93, 0x15, 0x46, + 0x37, 0xad, 0xf4, 0x78, 0xb2, 0xdd, 0x33, 0xb2, 0xdb, 0x33, 0xf2, 0xb5, 0x67, 0xe4, 0xfd, 0xc0, + 0x82, 0xdd, 0x81, 0x05, 0x1f, 0x07, 0x16, 0xdc, 0x8f, 0xf2, 0xc2, 0xcd, 0xd6, 0x19, 0x57, 0xb8, + 0x14, 0x8f, 0x52, 0xcd, 0xe5, 0x62, 0x22, 0x33, 0x2b, 0xfc, 0xcf, 0xaf, 0x7c, 0x2d, 0xaf, 0xc7, + 0x62, 0xdc, 0x66, 0x05, 0x36, 0x6b, 0x55, 0xcf, 0xbc, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc4, + 0x7c, 0x2b, 0x30, 0xbd, 0x01, 0x00, 0x00, +} + +func (m *OracleRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Bid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOracle(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if m.Chunk != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Chunk)) + i-- + dAtA[i] = 0x18 + } + if len(m.Merkle) > 0 { + i -= len(m.Merkle) + copy(dAtA[i:], m.Merkle) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Merkle))) + i-- + dAtA[i] = 0x12 + } + if len(m.Requester) > 0 { + i -= len(m.Requester) + copy(dAtA[i:], m.Requester) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Requester))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *OracleEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OracleEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OracleEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x22 + } + if m.Chunk != 0 { + i = encodeVarintOracle(dAtA, i, uint64(m.Chunk)) + i-- + dAtA[i] = 0x18 + } + if len(m.Merkle) > 0 { + i -= len(m.Merkle) + copy(dAtA[i:], m.Merkle) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Merkle))) + i-- + dAtA[i] = 0x12 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOracle(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOracle(dAtA []byte, offset int, v uint64) int { + offset -= sovOracle(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OracleRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Requester) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Merkle) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.Chunk != 0 { + n += 1 + sovOracle(uint64(m.Chunk)) + } + l = m.Bid.Size() + n += 1 + l + sovOracle(uint64(l)) + return n +} + +func (m *OracleEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + l = len(m.Merkle) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + if m.Chunk != 0 { + n += 1 + sovOracle(uint64(m.Chunk)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovOracle(uint64(l)) + } + return n +} + +func sovOracle(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOracle(x uint64) (n int) { + return sovOracle(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *OracleRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requester", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Requester = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Merkle", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Merkle = append(m.Merkle[:0], dAtA[iNdEx:postIndex]...) + if m.Merkle == nil { + m.Merkle = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) + } + m.Chunk = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Chunk |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Bid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *OracleEntry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OracleEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OracleEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Merkle", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Merkle = append(m.Merkle[:0], dAtA[iNdEx:postIndex]...) + if m.Merkle == nil { + m.Merkle = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) + } + m.Chunk = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Chunk |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOracle + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOracle + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOracle + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOracle(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOracle + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOracle(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOracle + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthOracle + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOracle + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOracle + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOracle = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOracle = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOracle = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/storage/types/tx.pb.go b/x/storage/types/tx.pb.go index 46353eedc..7c5e32f26 100644 --- a/x/storage/types/tx.pb.go +++ b/x/storage/types/tx.pb.go @@ -6,6 +6,8 @@ package types import ( context "context" fmt "fmt" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" @@ -1643,6 +1645,230 @@ func (m *MsgReportResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgReportResponse proto.InternalMessageInfo +type MsgRequestChunk struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Merkle []byte `protobuf:"bytes,2,opt,name=merkle,proto3" json:"merkle,omitempty"` + Chunk int64 `protobuf:"varint,3,opt,name=chunk,proto3" json:"chunk,omitempty"` + Bid types.Coin `protobuf:"bytes,4,opt,name=bid,proto3" json:"bid"` +} + +func (m *MsgRequestChunk) Reset() { *m = MsgRequestChunk{} } +func (m *MsgRequestChunk) String() string { return proto.CompactTextString(m) } +func (*MsgRequestChunk) ProtoMessage() {} +func (*MsgRequestChunk) Descriptor() ([]byte, []int) { + return fileDescriptor_2194ba0b2c3d6a97, []int{30} +} +func (m *MsgRequestChunk) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestChunk) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestChunk.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRequestChunk) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestChunk.Merge(m, src) +} +func (m *MsgRequestChunk) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestChunk) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestChunk.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestChunk proto.InternalMessageInfo + +func (m *MsgRequestChunk) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgRequestChunk) GetMerkle() []byte { + if m != nil { + return m.Merkle + } + return nil +} + +func (m *MsgRequestChunk) GetChunk() int64 { + if m != nil { + return m.Chunk + } + return 0 +} + +func (m *MsgRequestChunk) GetBid() types.Coin { + if m != nil { + return m.Bid + } + return types.Coin{} +} + +type MsgRequestChunkResponse struct { +} + +func (m *MsgRequestChunkResponse) Reset() { *m = MsgRequestChunkResponse{} } +func (m *MsgRequestChunkResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRequestChunkResponse) ProtoMessage() {} +func (*MsgRequestChunkResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2194ba0b2c3d6a97, []int{31} +} +func (m *MsgRequestChunkResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRequestChunkResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRequestChunkResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRequestChunkResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRequestChunkResponse.Merge(m, src) +} +func (m *MsgRequestChunkResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRequestChunkResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRequestChunkResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRequestChunkResponse proto.InternalMessageInfo + +type MsgFulfillRequest struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Requester string `protobuf:"bytes,2,opt,name=requester,proto3" json:"requester,omitempty"` + Merkle []byte `protobuf:"bytes,3,opt,name=merkle,proto3" json:"merkle,omitempty"` + Chunk int64 `protobuf:"varint,4,opt,name=chunk,proto3" json:"chunk,omitempty"` + Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` + HashList []byte `protobuf:"bytes,6,opt,name=hash_list,json=hashList,proto3" json:"hash_list,omitempty"` +} + +func (m *MsgFulfillRequest) Reset() { *m = MsgFulfillRequest{} } +func (m *MsgFulfillRequest) String() string { return proto.CompactTextString(m) } +func (*MsgFulfillRequest) ProtoMessage() {} +func (*MsgFulfillRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_2194ba0b2c3d6a97, []int{32} +} +func (m *MsgFulfillRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgFulfillRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgFulfillRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgFulfillRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgFulfillRequest.Merge(m, src) +} +func (m *MsgFulfillRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgFulfillRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgFulfillRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgFulfillRequest proto.InternalMessageInfo + +func (m *MsgFulfillRequest) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgFulfillRequest) GetRequester() string { + if m != nil { + return m.Requester + } + return "" +} + +func (m *MsgFulfillRequest) GetMerkle() []byte { + if m != nil { + return m.Merkle + } + return nil +} + +func (m *MsgFulfillRequest) GetChunk() int64 { + if m != nil { + return m.Chunk + } + return 0 +} + +func (m *MsgFulfillRequest) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *MsgFulfillRequest) GetHashList() []byte { + if m != nil { + return m.HashList + } + return nil +} + +type MsgFulfillRequestResponse struct { +} + +func (m *MsgFulfillRequestResponse) Reset() { *m = MsgFulfillRequestResponse{} } +func (m *MsgFulfillRequestResponse) String() string { return proto.CompactTextString(m) } +func (*MsgFulfillRequestResponse) ProtoMessage() {} +func (*MsgFulfillRequestResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_2194ba0b2c3d6a97, []int{33} +} +func (m *MsgFulfillRequestResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgFulfillRequestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgFulfillRequestResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgFulfillRequestResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgFulfillRequestResponse.Merge(m, src) +} +func (m *MsgFulfillRequestResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgFulfillRequestResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgFulfillRequestResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgFulfillRequestResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgPostFile)(nil), "canine_chain.storage.MsgPostFile") proto.RegisterType((*MsgPostFileResponse)(nil), "canine_chain.storage.MsgPostFileResponse") @@ -1674,87 +1900,102 @@ func init() { proto.RegisterType((*MsgRequestReportFormResponse)(nil), "canine_chain.storage.MsgRequestReportFormResponse") proto.RegisterType((*MsgReport)(nil), "canine_chain.storage.MsgReport") proto.RegisterType((*MsgReportResponse)(nil), "canine_chain.storage.MsgReportResponse") + proto.RegisterType((*MsgRequestChunk)(nil), "canine_chain.storage.MsgRequestChunk") + proto.RegisterType((*MsgRequestChunkResponse)(nil), "canine_chain.storage.MsgRequestChunkResponse") + proto.RegisterType((*MsgFulfillRequest)(nil), "canine_chain.storage.MsgFulfillRequest") + proto.RegisterType((*MsgFulfillRequestResponse)(nil), "canine_chain.storage.MsgFulfillRequestResponse") } func init() { proto.RegisterFile("canine_chain/storage/tx.proto", fileDescriptor_2194ba0b2c3d6a97) } var fileDescriptor_2194ba0b2c3d6a97 = []byte{ - // 1192 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x4f, 0x4f, 0x1b, 0x47, - 0x14, 0x67, 0xb1, 0x01, 0xfb, 0x61, 0xd2, 0x64, 0x03, 0xc9, 0xb2, 0x09, 0x06, 0x16, 0xa5, 0xa5, - 0x89, 0x62, 0xab, 0x44, 0x6a, 0x2f, 0xbd, 0x40, 0x51, 0x24, 0x1a, 0x5c, 0xd1, 0x25, 0x55, 0xff, - 0x49, 0x5d, 0x8d, 0xbd, 0x83, 0xd9, 0x62, 0xef, 0x6c, 0x66, 0xc6, 0x0e, 0xce, 0xa5, 0x6a, 0xcf, - 0x3d, 0xf4, 0x73, 0xf4, 0xd6, 0x5b, 0x3f, 0x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0x01, 0xc5, - 0xcc, 0x5a, 0x90, 0x67, 0x89, 0x68, 0x9a, 0x90, 0x0f, 0x09, 0xc7, 0x56, 0x41, 0xa6, 0x22, 0x7f, - 0x3b, 0xdf, 0xc2, 0xed, 0x54, 0xc2, 0x2e, 0x66, 0x11, 0x09, 0x19, 0x36, 0x37, 0xa1, 0x14, 0x51, - 0xd2, 0x0d, 0x7c, 0x4c, 0xbd, 0x20, 0x62, 0x96, 0xb1, 0x91, 0xdb, 0x2e, 0xba, 0x8b, 0x89, 0xee, - 0x20, 0x62, 0xe6, 0x3a, 0x2c, 0x32, 0x8e, 0x28, 0xf7, 0xea, 0x2d, 0xd2, 0x38, 0x93, 0x34, 0xe4, - 0x5c, 0x90, 0xaa, 0x3d, 0xa1, 0x71, 0xfe, 0x34, 0xa0, 0xa4, 0x6c, 0xcb, 0xd0, 0x32, 0xd8, 0x34, - 0x21, 0x1f, 0x70, 0xdc, 0x56, 0x5c, 0xca, 0xdf, 0x82, 0xc9, 0x53, 0xc4, 0x4e, 0xbd, 0x56, 0xc0, - 0xb8, 0x64, 0xb2, 0xe4, 0x16, 0x84, 0xe2, 0x30, 0x60, 0x3c, 0x45, 0x7f, 0x7e, 0x80, 0xfe, 0x65, - 0x98, 0x23, 0x2f, 0x43, 0x4c, 0x25, 0x6b, 0x45, 0x37, 0x16, 0x84, 0x56, 0xc6, 0xa5, 0xc8, 0x8a, - 0x05, 0x73, 0x15, 0x0a, 0x9c, 0x08, 0x1a, 0xbb, 0x38, 0x61, 0x8a, 0x93, 0x23, 0x21, 0x3a, 0x5f, - 0xc1, 0x72, 0x3a, 0x72, 0x4d, 0x8b, 0x05, 0x0b, 0xac, 0xd3, 0x68, 0x60, 0xc6, 0x64, 0x06, 0x05, - 0x37, 0x11, 0xcd, 0x2d, 0x58, 0xc2, 0x94, 0x12, 0xea, 0xb5, 0x31, 0x63, 0xa8, 0x19, 0x3f, 0x8b, - 0xa2, 0x5b, 0x92, 0xca, 0x5a, 0xac, 0x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f, 0x9c, 0xf7, 0xff, - 0x41, 0xe8, 0x45, 0x98, 0xd5, 0xe7, 0xe5, 0xbf, 0x08, 0x4f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, - 0xe4, 0xc8, 0x02, 0xdc, 0x66, 0x10, 0x00, 0x00, + // 1367 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0xcb, 0x6e, 0xdb, 0x46, + 0x17, 0x36, 0x2d, 0xf9, 0xa2, 0x63, 0xd9, 0x49, 0x18, 0x27, 0xa1, 0x99, 0x58, 0x76, 0x18, 0xe4, + 0xff, 0xdd, 0x04, 0x91, 0x60, 0x07, 0x68, 0x37, 0xdd, 0xd8, 0x09, 0x02, 0xa4, 0x89, 0x0b, 0x97, + 0x4e, 0xd1, 0x1b, 0x50, 0x61, 0x44, 0x8e, 0x65, 0xc6, 0x14, 0x87, 0xe1, 0x8c, 0x14, 0x2b, 0x9b, + 0xa2, 0xed, 0xb6, 0x8b, 0x3e, 0x47, 0x9f, 0xa0, 0x8f, 0x90, 0x65, 0x96, 0x5d, 0x15, 0x45, 0xf2, + 0x00, 0x7d, 0x85, 0x62, 0x2e, 0x1c, 0x91, 0xb2, 0x44, 0x29, 0x46, 0x83, 0xee, 0x78, 0xce, 0x7c, + 0x73, 0xae, 0x33, 0x67, 0x3e, 0x10, 0xd6, 0x3d, 0x14, 0x05, 0x11, 0x6e, 0x7a, 0xc7, 0x28, 0x88, + 0x1a, 0x94, 0x91, 0x04, 0xb5, 0x71, 0x83, 0x9d, 0xd6, 0xe3, 0x84, 0x30, 0x62, 0xae, 0x66, 0x97, + 0xeb, 0x6a, 0xd9, 0xae, 0x79, 0x84, 0x76, 0x08, 0x6d, 0xb4, 0x10, 0xc5, 0x8d, 0xde, 0x76, 0x0b, + 0x33, 0xb4, 0xdd, 0xf0, 0x48, 0x10, 0xc9, 0x5d, 0xf6, 0x6a, 0x9b, 0xb4, 0x89, 0xf8, 0x6c, 0xf0, + 0x2f, 0xa9, 0x75, 0xfe, 0x36, 0x60, 0x69, 0x9f, 0xb6, 0x0f, 0x08, 0x65, 0x8f, 0x82, 0x10, 0x9b, + 0x16, 0x2c, 0x78, 0x09, 0x46, 0x8c, 0x24, 0x96, 0xb1, 0x69, 0x6c, 0x55, 0xdc, 0x54, 0x34, 0xaf, + 0xc2, 0x7c, 0x07, 0x27, 0x27, 0x21, 0xb6, 0x66, 0x37, 0x8d, 0xad, 0xaa, 0xab, 0x24, 0xf3, 0x3a, + 0x54, 0x8e, 0x82, 0x10, 0x37, 0x69, 0xf0, 0x0a, 0x5b, 0xa5, 0x4d, 0x63, 0xab, 0xe4, 0x2e, 0x72, + 0xc5, 0x61, 0xf0, 0x0a, 0x9b, 0xb7, 0x61, 0x25, 0x4e, 0x08, 0x39, 0x6a, 0x06, 0x11, 0xc3, 0x49, + 0x0f, 0x85, 0x56, 0x59, 0x20, 0x96, 0x85, 0xf6, 0xb1, 0x52, 0x9a, 0xeb, 0x00, 0x12, 0xc6, 0xfa, + 0x31, 0xb6, 0xe6, 0x04, 0xa4, 0x22, 0x34, 0xcf, 0xfa, 0x31, 0xe6, 0xcb, 0x1d, 0x74, 0xda, 0x14, + 0x0a, 0x6a, 0xcd, 0xcb, 0xe5, 0x0e, 0x3a, 0x3d, 0x10, 0x0a, 0x1e, 0x33, 0x3e, 0x8d, 0x83, 0x04, + 0x53, 0x6b, 0x41, 0xac, 0xa5, 0xa2, 0x69, 0x42, 0x39, 0x22, 0x0c, 0x5b, 0x8b, 0x22, 0x15, 0xf1, + 0xed, 0x7c, 0x03, 0x97, 0x33, 0x09, 0xbb, 0x98, 0xc6, 0x24, 0xa2, 0xd8, 0xbc, 0x09, 0xd5, 0x38, + 0x21, 0xbd, 0xc0, 0xc7, 0x49, 0x33, 0x88, 0xa9, 0x65, 0x6c, 0x96, 0xb6, 0x2a, 0xee, 0x52, 0xaa, + 0x7b, 0x1c, 0x53, 0x73, 0x03, 0x96, 0x28, 0x43, 0x09, 0x6b, 0xb6, 0x42, 0xe2, 0x9d, 0x88, 0x32, + 0x94, 0x5c, 0x10, 0xaa, 0x3d, 0xae, 0x71, 0x7e, 0x37, 0xa0, 0xaa, 0x6c, 0x8b, 0xd0, 0x0a, 0xaa, + 0x69, 0x42, 0x39, 0x60, 0xb8, 0xa3, 0x6a, 0x29, 0xbe, 0x79, 0x25, 0x8f, 0x11, 0x3d, 0x6e, 0x86, + 0x01, 0x65, 0xa2, 0x92, 0x55, 0x77, 0x91, 0x2b, 0x9e, 0x06, 0x94, 0x65, 0xca, 0x5f, 0xce, 0x95, + 0x7f, 0x15, 0xe6, 0xc8, 0xcb, 0x08, 0x27, 0xa2, 0x6a, 0x15, 0x57, 0x0a, 0x5c, 0x2b, 0xe2, 0x52, + 0xc5, 0x92, 0x82, 0xb9, 0x06, 0x8b, 0x8c, 0xf0, 0x32, 0xf6, 0x70, 0x5a, 0x29, 0x46, 0x0e, 0xb8, + 0xe8, 0x7c, 0x09, 0xab, 0xd9, 0xc8, 0x75, 0x59, 0x2c, 0x58, 0xa0, 0x5d, 0xcf, 0xc3, 0x94, 0x8a, + 0x0c, 0x16, 0xdd, 0x54, 0x34, 0x6f, 0xc1, 0x32, 0x4e, 0x12, 0x92, 0x34, 0x3b, 0x98, 0x52, 0xd4, + 0x96, 0xc7, 0xa2, 0xe2, 0x56, 0x85, 0x72, 0x5f, 0xea, 0x9c, 0xaf, 0x60, 0x79, 0x9f, 0xb6, 0x1f, + 0xe2, 0x10, 0x33, 0x7c, 0xce, 0xf3, 0xa5, 0x53, 0x29, 0x65, 0x52, 0x71, 0xae, 0xc1, 0x95, 0x9c, + 0xe1, 0x34, 0x60, 0xe7, 0x53, 0xb8, 0xb8, 0x4f, 0xdb, 0x87, 0x98, 0xe7, 0x21, 0x3b, 0x77, 0x50, + 0xe0, 0x74, 0x05, 0x66, 0x83, 0x58, 0x45, 0x3e, 0x1b, 0xc4, 0x8e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a, 0x8d, + 0x82, 0xdd, 0x1c, 0x50, 0x90, 0x48, 0xfe, 0x9d, 0xe6, 0x57, 0x36, 0xf7, 0x46, 0xdf, 0x9e, 0x14, + 0x97, 0x80, 0x15, 0x5c, 0xd9, 0x51, 0x6f, 0xac, 0xf9, 0x1c, 0x56, 0x86, 0xde, 0xd7, 0xf1, 0x01, + 0xe6, 0x81, 0x76, 0x63, 0x4a, 0x60, 0xea, 0x6b, 0xef, 0xe9, 0xeb, 0xb7, 0x35, 0xe3, 0xcd, 0xdb, + 0x9a, 0xf1, 0xd7, 0xdb, 0x9a, 0xf1, 0xeb, 0xbb, 0xda, 0xcc, 0x9b, 0x77, 0xb5, 0x99, 0x3f, 0xde, + 0xd5, 0x66, 0xbe, 0xdd, 0x69, 0x07, 0xec, 0xb8, 0xdb, 0xaa, 0x7b, 0xa4, 0xd3, 0x78, 0x8e, 0xbc, + 0x13, 0x14, 0x3e, 0x45, 0x2d, 0xda, 0x90, 0xf6, 0xef, 0xc9, 0x7f, 0x57, 0xa7, 0x83, 0xbf, 0x57, + 0xfd, 0x18, 0xd3, 0xd6, 0xbc, 0xf8, 0xeb, 0x74, 0xff, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, + 0x48, 0xff, 0xa3, 0xe2, 0x12, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1784,6 +2025,9 @@ type MsgClient interface { Attest(ctx context.Context, in *MsgAttest, opts ...grpc.CallOption) (*MsgAttestResponse, error) RequestReportForm(ctx context.Context, in *MsgRequestReportForm, opts ...grpc.CallOption) (*MsgRequestReportFormResponse, error) Report(ctx context.Context, in *MsgReport, opts ...grpc.CallOption) (*MsgReportResponse, error) + // oracle stuff + RequestChunk(ctx context.Context, in *MsgRequestChunk, opts ...grpc.CallOption) (*MsgRequestChunkResponse, error) + FulfillRequest(ctx context.Context, in *MsgFulfillRequest, opts ...grpc.CallOption) (*MsgFulfillRequestResponse, error) } type msgClient struct { @@ -1929,6 +2173,24 @@ func (c *msgClient) Report(ctx context.Context, in *MsgReport, opts ...grpc.Call return out, nil } +func (c *msgClient) RequestChunk(ctx context.Context, in *MsgRequestChunk, opts ...grpc.CallOption) (*MsgRequestChunkResponse, error) { + out := new(MsgRequestChunkResponse) + err := c.cc.Invoke(ctx, "/canine_chain.storage.Msg/RequestChunk", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) FulfillRequest(ctx context.Context, in *MsgFulfillRequest, opts ...grpc.CallOption) (*MsgFulfillRequestResponse, error) { + out := new(MsgFulfillRequestResponse) + err := c.cc.Invoke(ctx, "/canine_chain.storage.Msg/FulfillRequest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { PostFile(context.Context, *MsgPostFile) (*MsgPostFileResponse, error) @@ -1946,6 +2208,9 @@ type MsgServer interface { Attest(context.Context, *MsgAttest) (*MsgAttestResponse, error) RequestReportForm(context.Context, *MsgRequestReportForm) (*MsgRequestReportFormResponse, error) Report(context.Context, *MsgReport) (*MsgReportResponse, error) + // oracle stuff + RequestChunk(context.Context, *MsgRequestChunk) (*MsgRequestChunkResponse, error) + FulfillRequest(context.Context, *MsgFulfillRequest) (*MsgFulfillRequestResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -1997,6 +2262,12 @@ func (*UnimplementedMsgServer) RequestReportForm(ctx context.Context, req *MsgRe func (*UnimplementedMsgServer) Report(ctx context.Context, req *MsgReport) (*MsgReportResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Report not implemented") } +func (*UnimplementedMsgServer) RequestChunk(ctx context.Context, req *MsgRequestChunk) (*MsgRequestChunkResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RequestChunk not implemented") +} +func (*UnimplementedMsgServer) FulfillRequest(ctx context.Context, req *MsgFulfillRequest) (*MsgFulfillRequestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method FulfillRequest not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -2272,6 +2543,42 @@ func _Msg_Report_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Msg_RequestChunk_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRequestChunk) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RequestChunk(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/canine_chain.storage.Msg/RequestChunk", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RequestChunk(ctx, req.(*MsgRequestChunk)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_FulfillRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgFulfillRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).FulfillRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/canine_chain.storage.Msg/FulfillRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).FulfillRequest(ctx, req.(*MsgFulfillRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "canine_chain.storage.Msg", HandlerType: (*MsgServer)(nil), @@ -2336,6 +2643,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "Report", Handler: _Msg_Report_Handler, }, + { + MethodName: "RequestChunk", + Handler: _Msg_RequestChunk_Handler, + }, + { + MethodName: "FulfillRequest", + Handler: _Msg_FulfillRequest_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "canine_chain/storage/tx.proto", @@ -3481,51 +3796,212 @@ func (m *MsgReportResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgRequestChunk) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgPostFile) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgRequestChunk) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestChunk) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Merkle) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.FileSize != 0 { - n += 1 + sovTx(uint64(m.FileSize)) - } - if m.ProofInterval != 0 { - n += 1 + sovTx(uint64(m.ProofInterval)) + { + size, err := m.Bid.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) } - if m.ProofType != 0 { - n += 1 + sovTx(uint64(m.ProofType)) + i-- + dAtA[i] = 0x22 + if m.Chunk != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Chunk)) + i-- + dAtA[i] = 0x18 } - if m.MaxProofs != 0 { - n += 1 + sovTx(uint64(m.MaxProofs)) + if len(m.Merkle) > 0 { + i -= len(m.Merkle) + copy(dAtA[i:], m.Merkle) + i = encodeVarintTx(dAtA, i, uint64(len(m.Merkle))) + i-- + dAtA[i] = 0x12 } - if m.Expires != 0 { - n += 1 + sovTx(uint64(m.Expires)) + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa } - l = len(m.Note) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + return len(dAtA) - i, nil +} + +func (m *MsgRequestChunkResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - return n + return dAtA[:n], nil +} + +func (m *MsgRequestChunkResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRequestChunkResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgFulfillRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgFulfillRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgFulfillRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.HashList) > 0 { + i -= len(m.HashList) + copy(dAtA[i:], m.HashList) + i = encodeVarintTx(dAtA, i, uint64(len(m.HashList))) + i-- + dAtA[i] = 0x32 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x2a + } + if m.Chunk != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Chunk)) + i-- + dAtA[i] = 0x20 + } + if len(m.Merkle) > 0 { + i -= len(m.Merkle) + copy(dAtA[i:], m.Merkle) + i = encodeVarintTx(dAtA, i, uint64(len(m.Merkle))) + i-- + dAtA[i] = 0x1a + } + if len(m.Requester) > 0 { + i -= len(m.Requester) + copy(dAtA[i:], m.Requester) + i = encodeVarintTx(dAtA, i, uint64(len(m.Requester))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgFulfillRequestResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgFulfillRequestResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgFulfillRequestResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgPostFile) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Merkle) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.FileSize != 0 { + n += 1 + sovTx(uint64(m.FileSize)) + } + if m.ProofInterval != 0 { + n += 1 + sovTx(uint64(m.ProofInterval)) + } + if m.ProofType != 0 { + n += 1 + sovTx(uint64(m.ProofType)) + } + if m.MaxProofs != 0 { + n += 1 + sovTx(uint64(m.MaxProofs)) + } + if m.Expires != 0 { + n += 1 + sovTx(uint64(m.Expires)) + } + l = len(m.Note) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n } func (m *MsgPostFileResponse) Size() (n int) { @@ -4016,6 +4492,78 @@ func (m *MsgReportResponse) Size() (n int) { return n } +func (m *MsgRequestChunk) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Merkle) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Chunk != 0 { + n += 1 + sovTx(uint64(m.Chunk)) + } + l = m.Bid.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgRequestChunkResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgFulfillRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Requester) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Merkle) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Chunk != 0 { + n += 1 + sovTx(uint64(m.Chunk)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.HashList) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgFulfillRequestResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -7427,6 +7975,509 @@ func (m *MsgReportResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRequestChunk) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRequestChunk: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestChunk: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Merkle", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Merkle = append(m.Merkle[:0], dAtA[iNdEx:postIndex]...) + if m.Merkle == nil { + m.Merkle = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) + } + m.Chunk = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Chunk |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bid", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Bid.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRequestChunkResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRequestChunkResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRequestChunkResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgFulfillRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgFulfillRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgFulfillRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requester", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Requester = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Merkle", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Merkle = append(m.Merkle[:0], dAtA[iNdEx:postIndex]...) + if m.Merkle == nil { + m.Merkle = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Chunk", wireType) + } + m.Chunk = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Chunk |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HashList", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HashList = append(m.HashList[:0], dAtA[iNdEx:postIndex]...) + if m.HashList == nil { + m.HashList = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgFulfillRequestResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgFulfillRequestResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgFulfillRequestResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/storage/utils/trees.go b/x/storage/utils/trees.go index 4e173a54a..d1d5d9dbb 100644 --- a/x/storage/utils/trees.go +++ b/x/storage/utils/trees.go @@ -12,6 +12,22 @@ import ( ) func BuildTree(buf io.Reader, chunkSize int64) ([]byte, []byte, [][]byte, int, error) { + tree, chunks, size, err := BuildJustTree(buf, chunkSize) + if err != nil { + return nil, nil, nil, 0, err + } + + r := tree.Root() + + exportedTree, err := json.Marshal(tree) + if err != nil { + return nil, nil, nil, 0, err + } + + return r, exportedTree, chunks, size, nil +} + +func BuildJustTree(buf io.Reader, chunkSize int64) (*merkletree.MerkleTree, [][]byte, int, error) { size := 0 data := make([][]byte, 0) @@ -46,17 +62,31 @@ func BuildTree(buf io.Reader, chunkSize int64) ([]byte, []byte, [][]byte, int, e tree, err := merkletree.NewUsing(data, sha3.New512(), false) if err != nil { - return nil, nil, nil, 0, err + return nil, nil, 0, err } - r := tree.Root() + return tree, chunks, size, nil +} - exportedTree, err := json.Marshal(tree) +// VerifyProof checks whether a proof is valid against a merkle +func VerifyProof(merkle []byte, proofData []byte, chunk int64, item []byte) bool { + h := sha256.New() + _, err := io.WriteString(h, fmt.Sprintf("%d%x", chunk, item)) if err != nil { - return nil, nil, nil, 0, err + return false } + hashName := h.Sum(nil) - tree = nil // for GC + var proof merkletree.Proof // unmarshal proof + err = json.Unmarshal(proofData, &proof) + if err != nil { + return false + } - return r, exportedTree, chunks, size, nil + verified, err := merkletree.VerifyProofUsing(hashName, false, &proof, [][]byte{merkle}, sha3.New512()) + if err != nil { + return false + } + + return verified } From ff3bb1c22ae6a578c2ef273e979336e19d672a9d Mon Sep 17 00:00:00 2001 From: marston Date: Tue, 5 Dec 2023 22:40:04 -0500 Subject: [PATCH 2/2] fixing genesis --- proto/canine_chain/storage/genesis.proto | 3 + x/storage/genesis.go | 12 ++ x/storage/types/genesis.go | 20 +-- x/storage/types/genesis.pb.go | 186 +++++++++++++++++++---- 4 files changed, 183 insertions(+), 38 deletions(-) diff --git a/proto/canine_chain/storage/genesis.proto b/proto/canine_chain/storage/genesis.proto index 505b8c6f5..94227115d 100644 --- a/proto/canine_chain/storage/genesis.proto +++ b/proto/canine_chain/storage/genesis.proto @@ -6,6 +6,7 @@ import "canine_chain/storage/params.proto"; import "canine_chain/storage/active_deals.proto"; import "canine_chain/storage/providers.proto"; import "canine_chain/storage/payment_info.proto"; +import "canine_chain/storage/oracle.proto"; option go_package = "github.com/jackalLabs/canine-chain/x/storage/types"; @@ -18,4 +19,6 @@ message GenesisState { repeated ActiveProviders active_providers_list = 6 [ (gogoproto.nullable) = false ]; repeated ReportForm report_forms = 7 [ (gogoproto.nullable) = false ]; repeated AttestationForm attest_forms = 8 [ (gogoproto.nullable) = false ]; + repeated OracleRequest oracle_requests = 9 [ (gogoproto.nullable) = false ]; + repeated OracleEntry oracle_entries = 10 [ (gogoproto.nullable) = false ]; } diff --git a/x/storage/genesis.go b/x/storage/genesis.go index e11d46d8b..7e5f4fe88 100644 --- a/x/storage/genesis.go +++ b/x/storage/genesis.go @@ -43,6 +43,16 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetActiveProviders(ctx, elem) } + // Set all the oracle requests + for _, elem := range genState.OracleRequests { + k.SetOracleRequest(ctx, elem) + } + + // Set all the oracle entries + for _, elem := range genState.OracleEntries { + k.SetOracleEntry(ctx, elem) + } + k.SetParams(ctx, genState.Params) } @@ -58,6 +68,8 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.ActiveProvidersList = k.GetAllActiveProviders(ctx) genesis.ReportForms = k.GetAllReport(ctx) genesis.AttestForms = k.GetAllAttestation(ctx) + genesis.OracleRequests = k.GetAllOracleRequests(ctx) + genesis.OracleEntries = k.GetAllOracleEntries(ctx) return genesis } diff --git a/x/storage/types/genesis.go b/x/storage/types/genesis.go index 92287a05f..f9b3da349 100644 --- a/x/storage/types/genesis.go +++ b/x/storage/types/genesis.go @@ -4,24 +4,26 @@ import ( "fmt" ) -// DefaultIndex is the default capability global index -const DefaultIndex uint64 = 1 - // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - FileList: []UnifiedFile{}, - ProvidersList: []Providers{}, - PaymentInfoList: []StoragePaymentInfo{}, - // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), + Params: DefaultParams(), + FileList: []UnifiedFile{}, + ProvidersList: []Providers{}, + PaymentInfoList: []StoragePaymentInfo{}, + CollateralList: []Collateral{}, + ActiveProvidersList: []ActiveProviders{}, + ReportForms: []ReportForm{}, + AttestForms: []AttestationForm{}, + OracleRequests: []OracleRequest{}, + OracleEntries: []OracleEntry{}, } } // Validate performs basic genesis state validation returning an error upon any // failure. -func (gs GenesisState) Validate() error { +func (gs *GenesisState) Validate() error { // Check for duplicated index in files filesIndexMap := make(map[string]struct{}) diff --git a/x/storage/types/genesis.pb.go b/x/storage/types/genesis.pb.go index cc8993cfd..e74d30548 100644 --- a/x/storage/types/genesis.pb.go +++ b/x/storage/types/genesis.pb.go @@ -32,6 +32,8 @@ type GenesisState struct { ActiveProvidersList []ActiveProviders `protobuf:"bytes,6,rep,name=active_providers_list,json=activeProvidersList,proto3" json:"active_providers_list"` ReportForms []ReportForm `protobuf:"bytes,7,rep,name=report_forms,json=reportForms,proto3" json:"report_forms"` AttestForms []AttestationForm `protobuf:"bytes,8,rep,name=attest_forms,json=attestForms,proto3" json:"attest_forms"` + OracleRequests []OracleRequest `protobuf:"bytes,9,rep,name=oracle_requests,json=oracleRequests,proto3" json:"oracle_requests"` + OracleEntries []OracleEntry `protobuf:"bytes,10,rep,name=oracle_entries,json=oracleEntries,proto3" json:"oracle_entries"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -123,6 +125,20 @@ func (m *GenesisState) GetAttestForms() []AttestationForm { return nil } +func (m *GenesisState) GetOracleRequests() []OracleRequest { + if m != nil { + return m.OracleRequests + } + return nil +} + +func (m *GenesisState) GetOracleEntries() []OracleEntry { + if m != nil { + return m.OracleEntries + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "canine_chain.storage.GenesisState") } @@ -132,35 +148,39 @@ func init() { } var fileDescriptor_a52da9fdb04c8b35 = []byte{ - // 444 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0xd2, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x07, 0xf0, 0x84, 0x6d, 0x65, 0xb8, 0x65, 0x13, 0x61, 0x48, 0x55, 0x85, 0xb2, 0x6e, 0x02, - 0xd1, 0x0b, 0x89, 0x54, 0x6e, 0xdc, 0x18, 0x68, 0x68, 0x52, 0x04, 0xd3, 0x26, 0x2e, 0xbb, 0x44, - 0xaf, 0xe9, 0x4b, 0x66, 0x70, 0xec, 0xc8, 0x36, 0x13, 0xfb, 0x04, 0x5c, 0xf9, 0x58, 0x3b, 0xee, - 0xc8, 0x09, 0xa1, 0xf6, 0x8b, 0xa0, 0xd9, 0x6e, 0x56, 0x26, 0xaf, 0xa7, 0x56, 0xd6, 0xff, 0xff, - 0xcb, 0x7b, 0x89, 0xc9, 0x7e, 0x01, 0x9c, 0x72, 0xcc, 0x8b, 0x73, 0xa0, 0x3c, 0x55, 0x5a, 0x48, - 0xa8, 0x30, 0xad, 0x90, 0xa3, 0xa2, 0x2a, 0x69, 0xa4, 0xd0, 0x22, 0xda, 0x59, 0xce, 0x24, 0x2e, - 0x33, 0xd8, 0xa9, 0x44, 0x25, 0x4c, 0x20, 0xbd, 0xf9, 0x67, 0xb3, 0x83, 0x3d, 0xaf, 0xd7, 0x80, - 0x84, 0xda, 0x71, 0x83, 0x57, 0xde, 0x08, 0x14, 0x9a, 0x5e, 0x60, 0x3e, 0x45, 0x60, 0x8b, 0xe0, - 0x0b, 0xbf, 0x25, 0xc5, 0x05, 0x9d, 0xa2, 0x5c, 0xcd, 0x35, 0x70, 0x59, 0x23, 0xd7, 0x39, 0xe5, - 0xa5, 0x1b, 0x6d, 0xff, 0xe7, 0x06, 0xe9, 0x7d, 0xb4,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 0xf4, 0x89, 0xf4, 0x40, 0x6b, 0x54, 0x0b, 0x6a, 0x73, 0xe5, 0x88, 0x26, 0x09, 0x9a, 0x0a, 0xbe, - 0xec, 0x59, 0xc0, 0x78, 0x07, 0xd9, 0xd5, 0x2c, 0x0e, 0xaf, 0x67, 0x71, 0xf8, 0x77, 0x16, 0x87, - 0xbf, 0xe6, 0x71, 0x70, 0x3d, 0x8f, 0x83, 0xdf, 0xf3, 0x38, 0x38, 0x1b, 0x57, 0x54, 0x9f, 0x7f, - 0x9f, 0x24, 0x85, 0xa8, 0xd3, 0xaf, 0x50, 0x7c, 0x03, 0x96, 0xc1, 0x44, 0xa5, 0xf6, 0x41, 0xaf, - 0xed, 0x15, 0xff, 0xd1, 0x5e, 0x72, 0x7d, 0xd9, 0xa0, 0x9a, 0x74, 0xcc, 0xf5, 0x7e, 0xf3, 0x2f, - 0x00, 0x00, 0xff, 0xff, 0x97, 0x4b, 0x51, 0x36, 0xcb, 0x03, 0x00, 0x00, + // 503 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0xd3, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0x07, 0xf0, 0x86, 0x8d, 0xb2, 0xb9, 0x65, 0x15, 0x61, 0x48, 0x51, 0x85, 0xb2, 0x6e, 0x80, + 0xe8, 0x85, 0x44, 0x2a, 0x37, 0x6e, 0x0c, 0x18, 0x9a, 0x54, 0xb1, 0xa9, 0x13, 0x97, 0x5d, 0x22, + 0x37, 0x7d, 0xc9, 0x0c, 0x89, 0x1d, 0xec, 0xb7, 0x89, 0x7e, 0x0b, 0xbe, 0x07, 0x5f, 0x64, 0xc7, + 0x1d, 0x39, 0x21, 0xd4, 0x7e, 0x11, 0x54, 0xdb, 0xc9, 0xca, 0x14, 0x72, 0x6a, 0xf5, 0xf4, 0x7f, + 0xbf, 0x3c, 0x3f, 0xd9, 0xe4, 0x20, 0xa6, 0x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0x75, 0x3e, 0x4a, 0x19, 0x5e, 0x5c, 0x4e, 0x83, 0x58, 0xe4, 0xe1, 0x17, + 0x1a, 0x7f, 0xa5, 0xd9, 0x98, 0x4e, 0x55, 0x68, 0x3e, 0xf3, 0xca, 0x3c, 0xc0, 0xef, 0xd5, 0x13, + 0xc4, 0x79, 0x01, 0x6a, 0xda, 0xd6, 0x4f, 0xf0, 0xf5, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, + 0x63, 0x25, 0xa1, 0x92, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -183,6 +203,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.OracleEntries) > 0 { + for iNdEx := len(m.OracleEntries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OracleEntries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.OracleRequests) > 0 { + for iNdEx := len(m.OracleRequests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.OracleRequests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } if len(m.AttestForms) > 0 { for iNdEx := len(m.AttestForms) - 1; iNdEx >= 0; iNdEx-- { { @@ -355,6 +403,18 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.OracleRequests) > 0 { + for _, e := range m.OracleRequests { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.OracleEntries) > 0 { + for _, e := range m.OracleEntries { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -664,6 +724,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleRequests", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OracleRequests = append(m.OracleRequests, OracleRequest{}) + if err := m.OracleRequests[len(m.OracleRequests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OracleEntries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OracleEntries = append(m.OracleEntries, OracleEntry{}) + if err := m.OracleEntries[len(m.OracleEntries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:])