-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
677 additions
and
3 deletions.
There are no files selected for viewing
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,218 @@ | ||
"Data that can be used as proof to validate notices and execute vouchers on the base layer blockchain" | ||
type Proof { | ||
"Validity proof for an output" | ||
validity: OutputValidityProof! | ||
"Data that allows the validity proof to be contextualized within submitted claims, given as a payload in Ethereum hex binary format, starting with '0x'" | ||
context: String! | ||
} | ||
|
||
enum CompletionStatus { | ||
UNPROCESSED | ||
ACCEPTED | ||
REJECTED | ||
EXCEPTION | ||
MACHINE_HALTED | ||
CYCLE_LIMIT_EXCEEDED | ||
TIME_LIMIT_EXCEEDED | ||
PAYLOAD_LENGTH_LIMIT_EXCEEDED | ||
} | ||
|
||
"Request submitted to the application to advance its state" | ||
type Input { | ||
"Input index starting from genesis" | ||
index: Int! | ||
"Status of the input" | ||
status: CompletionStatus! | ||
"Address responsible for submitting the input" | ||
msgSender: String! | ||
"Timestamp associated with the input submission, as defined by the base layer's block in which it was recorded" | ||
timestamp: BigInt! | ||
"Number of the base layer block in which the input was recorded" | ||
blockNumber: BigInt! | ||
"Input payload in Ethereum hex binary format, starting with '0x'" | ||
payload: String! | ||
"Get voucher from this particular input given the voucher's index" | ||
voucher(index: Int!): Voucher! | ||
"Get notice from this particular input given the notice's index" | ||
notice(index: Int!): Notice! | ||
"Get report from this particular input given the report's index" | ||
report(index: Int!): Report! | ||
"Get vouchers from this particular input with support for pagination" | ||
vouchers(first: Int, last: Int, after: String, before: String): VoucherConnection! | ||
"Get notices from this particular input with support for pagination" | ||
notices(first: Int, last: Int, after: String, before: String): NoticeConnection! | ||
"Get reports from this particular input with support for pagination" | ||
reports(first: Int, last: Int, after: String, before: String): ReportConnection! | ||
} | ||
|
||
"Validity proof for an output" | ||
type OutputValidityProof { | ||
"Local input index within the context of the related epoch" | ||
inputIndexWithinEpoch: Int! | ||
"Output index within the context of the input that produced it" | ||
outputIndexWithinInput: Int! | ||
"Merkle root of all output hashes of the related input, given in Ethereum hex binary format (32 bytes), starting with '0x'" | ||
outputHashesRootHash: String! | ||
"Merkle root of all voucher hashes of the related epoch, given in Ethereum hex binary format (32 bytes), starting with '0x'" | ||
vouchersEpochRootHash: String! | ||
"Merkle root of all notice hashes of the related epoch, given in Ethereum hex binary format (32 bytes), starting with '0x'" | ||
noticesEpochRootHash: String! | ||
"Hash of the machine state claimed for the related epoch, given in Ethereum hex binary format (32 bytes), starting with '0x'" | ||
machineStateHash: String! | ||
"Proof that this output hash is in the output-hashes merkle tree. This array of siblings is bottom-up ordered (from the leaf to the root). Each hash is given in Ethereum hex binary format (32 bytes), starting with '0x'." | ||
outputHashInOutputHashesSiblings: [String!]! | ||
"Proof that this output-hashes root hash is in epoch's output merkle tree. This array of siblings is bottom-up ordered (from the leaf to the root). Each hash is given in Ethereum hex binary format (32 bytes), starting with '0x'." | ||
outputHashesInEpochSiblings: [String!]! | ||
} | ||
|
||
"Representation of a transaction that can be carried out on the base layer blockchain, such as a transfer of assets" | ||
type Voucher { | ||
"Voucher index within the context of the input that produced it" | ||
index: Int! | ||
"Input whose processing produced the voucher" | ||
input: Input! | ||
"Transaction destination address in Ethereum hex binary format (20 bytes), starting with '0x'" | ||
destination: String! | ||
"Transaction payload in Ethereum hex binary format, starting with '0x'" | ||
payload: String! | ||
"Proof object that allows this voucher to be validated and executed on the base layer blockchain" | ||
proof: Proof | ||
} | ||
|
||
"Top level queries" | ||
type Query { | ||
"Get input based on its identifier" | ||
input(index: Int!): Input! | ||
"Get voucher based on its index" | ||
voucher(voucherIndex: Int!, inputIndex: Int!): Voucher! | ||
"Get notice based on its index" | ||
notice(noticeIndex: Int!, inputIndex: Int!): Notice! | ||
"Get report based on its index" | ||
report(reportIndex: Int!, inputIndex: Int!): Report! | ||
"Get inputs with support for pagination" | ||
inputs(first: Int, last: Int, after: String, before: String, where: InputFilter): InputConnection! | ||
"Get vouchers with support for pagination" | ||
vouchers(first: Int, last: Int, after: String, before: String): VoucherConnection! | ||
"Get notices with support for pagination" | ||
notices(first: Int, last: Int, after: String, before: String): NoticeConnection! | ||
"Get reports with support for pagination" | ||
reports(first: Int, last: Int, after: String, before: String): ReportConnection! | ||
} | ||
|
||
"Pagination entry" | ||
type NoticeEdge { | ||
"Node instance" | ||
node: Notice! | ||
"Pagination cursor" | ||
cursor: String! | ||
} | ||
|
||
"Pagination result" | ||
type InputConnection { | ||
"Total number of entries that match the query" | ||
totalCount: Int! | ||
"Pagination entries returned for the current page" | ||
edges: [InputEdge!]! | ||
"Pagination metadata" | ||
pageInfo: PageInfo! | ||
} | ||
|
||
"Pagination result" | ||
type VoucherConnection { | ||
"Total number of entries that match the query" | ||
totalCount: Int! | ||
"Pagination entries returned for the current page" | ||
edges: [VoucherEdge!]! | ||
"Pagination metadata" | ||
pageInfo: PageInfo! | ||
} | ||
|
||
"Informational statement that can be validated in the base layer blockchain" | ||
type Notice { | ||
"Notice index within the context of the input that produced it" | ||
index: Int! | ||
"Input whose processing produced the notice" | ||
input: Input! | ||
"Notice data as a payload in Ethereum hex binary format, starting with '0x'" | ||
payload: String! | ||
"Proof object that allows this notice to be validated by the base layer blockchain" | ||
proof: Proof | ||
} | ||
|
||
"Pagination entry" | ||
type ReportEdge { | ||
"Node instance" | ||
node: Report! | ||
"Pagination cursor" | ||
cursor: String! | ||
} | ||
|
||
"Pagination result" | ||
type ReportConnection { | ||
"Total number of entries that match the query" | ||
totalCount: Int! | ||
"Pagination entries returned for the current page" | ||
edges: [ReportEdge!]! | ||
"Pagination metadata" | ||
pageInfo: PageInfo! | ||
} | ||
|
||
"Filter object to restrict results depending on input properties" | ||
input InputFilter { | ||
"Filter only inputs with index lower than a given value" indexLowerThan: Int | ||
"Filter only inputs with index greater than a given value" indexGreaterThan: Int | ||
} | ||
|
||
scalar BigInt | ||
|
||
"Pagination result" | ||
type NoticeConnection { | ||
"Total number of entries that match the query" | ||
totalCount: Int! | ||
"Pagination entries returned for the current page" | ||
edges: [NoticeEdge!]! | ||
"Pagination metadata" | ||
pageInfo: PageInfo! | ||
} | ||
|
||
"Pagination entry" | ||
type InputEdge { | ||
"Node instance" | ||
node: Input! | ||
"Pagination cursor" | ||
cursor: String! | ||
} | ||
|
||
"Page metadata for the cursor-based Connection pagination pattern" | ||
type PageInfo { | ||
"Cursor pointing to the first entry of the page" | ||
startCursor: String | ||
"Cursor pointing to the last entry of the page" | ||
endCursor: String | ||
"Indicates if there are additional entries after the end curs" | ||
hasNextPage: Boolean! | ||
"Indicates if there are additional entries before the start curs" | ||
hasPreviousPage: Boolean! | ||
} | ||
|
||
"Application log or diagnostic information" | ||
type Report { | ||
"Report index within the context of the input that produced it" | ||
index: Int! | ||
"Input whose processing produced the report" | ||
input: Input! | ||
"Report data as a payload in Ethereum hex binary format, starting with '0x'" | ||
payload: String! | ||
} | ||
|
||
"Pagination entry" | ||
type VoucherEdge { | ||
"Node instance" | ||
node: Voucher! | ||
"Pagination cursor" | ||
cursor: String! | ||
} | ||
|
||
schema { | ||
query: Query | ||
} |
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,53 @@ | ||
// (c) Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: Apache-2.0 (see LICENSE) | ||
|
||
package input | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/Khan/genqlient/graphql" | ||
"github.com/cartesi/rollups-node/internal/logger" | ||
"github.com/cartesi/rollups-node/pkg/readerclient" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "input", | ||
Short: "Reads input from node GraphQL", | ||
Example: examples, | ||
Run: run, | ||
} | ||
|
||
const examples = `# Read specific input from GraphQL: | ||
cartesi-rollups-cli read input --index 5` | ||
|
||
var ( | ||
index int | ||
graphqlEndpoint string | ||
) | ||
|
||
func init() { | ||
Cmd.Flags().IntVar(&index, "index", 0, | ||
"index of the input") | ||
|
||
cobra.CheckErr(Cmd.MarkFlagRequired("index")) | ||
|
||
Cmd.Flags().StringVar(&graphqlEndpoint, "graphql-endpoint", "http://0.0.0.0:4000/graphql", | ||
"address used to connect to graphql") | ||
} | ||
|
||
func run(cmd *cobra.Command, args []string) { | ||
logger.Init("info", true) | ||
|
||
ctx := cmd.Context() | ||
client := graphql.NewClient(graphqlEndpoint, nil) | ||
|
||
resp, err := readerclient.GetInput(ctx, client, int(index)) | ||
cobra.CheckErr(err) | ||
|
||
val, err := json.MarshalIndent(resp, "", " ") | ||
cobra.CheckErr(err) | ||
|
||
logger.Info.Printf(string(val)) | ||
} |
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,20 @@ | ||
// (c) Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: Apache-2.0 (see LICENSE) | ||
|
||
package read | ||
|
||
import ( | ||
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/read/input" | ||
"github.com/cartesi/rollups-node/cmd/cartesi-rollups-cli/root/read/inputs" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "read", | ||
Short: "Read the node state from the GraphQL API", | ||
} | ||
|
||
func init() { | ||
Cmd.AddCommand(input.Cmd) | ||
Cmd.AddCommand(inputs.Cmd) | ||
} |
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
Oops, something went wrong.