Skip to content

Commit

Permalink
feat: add IO
Browse files Browse the repository at this point in the history
fix: warn on equality, error on decrease && simplify code

fix: regenerate subxt for dynamic dory changes

The chain recently merged changes to the commitment schemes types.
This resulted in new type metadata being generated - in particular,
CommitmentScheme::Dory is now CommitmentScheme::DynamicDory.

feat: add and warn about postprocessing

feat: add `PostprocessingLevel`

fix: make sure it runs && address reviews

fix: use count(*) in count_table

fix: not use manual parsing

feat: add json files to .gitignore

fix: make `PostprocessingLevel` `ValueEnum`

refactor: move bins

fix: happy clippy

docs: add `README.md`

docs: swap out LICENSE

docs: address reviews

docs: address NIT

fix: change default SUBSTRATE_NODE_URL to use wss.

feat: copy chainlink example code

```
cp documentation/public/samples/ChainlinkFunctions/FunctionsConsumerExample.sol smart-contract/FunctionsConsumerExample.sol
cp -r smart-contract-examples/functions-examples/examples/5-use-secrets-threshold example
cp -r smart-contract-examples/functions-examples/package.json .
```

feat: add FunctionsConsumerAbi.json

This ABI file can be generated using any solidity compiler. This was copied from Remix.

feat: remove hardcoded values from example

doc: add README explaining how to run the example

feat: add code to retrieve sxt access token

Co-authored-by: Jay White <[email protected]>

chore: add .env.enc to .gitignore

feat: prepend wasm codegen to javascript job

```
cat sxt_proof_of_sql_sdk_wasm.js example/source.js > tmp && mv tmp example/source.js
```

fix: update generated javascript wasm bindings

* removed an `export`s
* now the wasm is loaded from a hardcoded url

feat: add commitment request and decoding

chore: add commented out line to enable running simulation only

style: format js code using prettier

`npx prettier example/source.js --write`

feat: update codegen

feat: add prover query and verification

refactored source code

secrets
  • Loading branch information
iajoiner authored and Dustin-Ray committed Nov 20, 2024
1 parent 5c7b263 commit 56fbdb0
Show file tree
Hide file tree
Showing 26 changed files with 1,506 additions and 245 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.env
**/*.json

# Rust
# Generated by Cargo
Expand Down
19 changes: 3 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[workspace]
members = ["./scripts/count-ethereum-core", "sdk"]
[package]
name = "sxt-proof-of-sql-sdk"
version = "0.1.0"
edition = "2021"
resolver = "2"

[workspace.dependencies]
[dependencies]
ark-serialize = { version = "0.4.0", default-features = false }
clap = { version = "4.5.20", features = ["derive", "env"] }
dotenv = "0.15"
Expand All @@ -18,6 +21,17 @@ reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1.0", features = ["serde_derive"] }
serde_json = "1.0"
subxt = "0.37.0"
sxt-proof-of-sql-sdk = { path = "sdk" }
tokio = { version = "1.0", features = ["rt-multi-thread", "macros"] }
tonic = { version = "0.11", features = ["tls", "tls-roots"] }

[build-dependencies]
prost-build = "0.12"
tonic-build = { version = "0.11" }

[[example]]
name = "cli"
path = "examples/cli/main.rs"

[[example]]
name = "count-ethereum-core"
path = "examples/count-ethereum-core/main.rs"
69 changes: 67 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,70 @@
Copyright (C) 2024 Space and Time Labs, Inc.

All Rights Reserved.
Cryptographic Open Software License 1.0

This software may not be copied, distributed, modified, and/or utilized in any way without the express permission of Space and Time Labs, Inc.
This license contains the terms and conditions under which Space
and Time Labs, Inc. ("Space and Time") makes available this
Software. Your use of the Software is subject to these terms and
conditions.

Space and Time grants you ("Licensee") a license to use, modify,
and redistribute the Software, but only (a) for Non-Commercial
Use, or (b) for Commercial Use with the Space and Time Platform
only. You must use the Software only as allowed by applicable
law.

If Licensee makes available a copy of the Software to any third
party, the Software must be subject to the terms of this license
only, and Licensee must provide a copy of this license to that
third party.

If Licensee makes changes or additions to the Software, Licensee
may license those changes or additions under terms of Licensee's
choice, but Licensee cannot change this license for the
Software.

These terms do not allow Licensee to sublicense or transfer any
of Licensee’s rights to anyone else. These terms do not imply
any other licenses not expressly granted in this license.

If Licensee violates any of these terms, or uses the Software in
a way not authorized under this license, the license granted to
Licensee ends immediately.

If Licensee makes, or authorizes any other person to make, any
written claim that the Software, or any other product or service
of Space and Time, infringes or contributes to infringement of
any patent, all rights granted to Licensee under this license
end immediately.

As far as the law allows, the Software is provided AS IS,
without any warranty or condition, and Space and Time will not
be liable to Licensee for any damages arising out of these terms
or the use or nature of the Software, under any kind of legal
claim. If the disclaimer in this paragraph is unenforceable
under applicable law, this license is void.

Terms in this license are used as follows:

The "Software" is any software made available by Space and Time
under this license.

A "Space and Time Product" is any product or service offered by
Space and Time or its affiliates.

"Non-Commercial Use" means personal, academic, scientific, or
research and development use, or evaluating the Software, but
does not include uses where the Software facilitates any
transaction of economic value or supports any system that
provides any economic or commercial value other than on the
Space and Time Platform.

Any use that is not a Non-Commercial Use is a "Commercial Use."

"Space and Time Platform" means the enterprise data platform, or
node operations within a Space and Time decentralized network,
in each case for processing database queries with cryptographic
proofs, that is made available by Space and Time.

To "use" means any use, modification, distribution or other
exploitation of the Software or any part of it.
78 changes: 55 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,70 @@
# Sxt Proof Of Sql Sdk
# Space and Time (SxT) Proof of SQL SDK

sxt-node
An SDK to help users interact with the Space and Time (SxT) TestNet and execute Proof of SQL queries.

## 📑 Table of Contents
## Introduction

- [🛠️ Installation](#installation)
- [🚀 Usage](#usage)
- [🤝 Contributing](#contributing)
- [📝 Commit Messages](#commit-messages)
- [📧 Contact](#contact)
- [📚 Additional Resources](#additional-resources)
The Space and Time Proof of SQL SDK is a Rust crate designed to simplify the process of running SQL queries against the Space and Time TestNet and verifying the results using cryptographic proofs. It leverages the [Proof of SQL](https://github.com/spaceandtimelabs/sxt-proof-of-sql) framework to ensure the integrity and correctness of query results.

## <a name="installation"></a>🛠️ Installation
## Installation

Provide instructions on how to install or set up the project. Include any dependencies that need to be installed and how to install them.
Add the following to your `Cargo.toml`:

## <a name="usage"></a>🚀 Usage
```toml
[dependencies]
sxt-proof-of-sql-sdk = "0.1.0"
```
Then, run:

Explain how to use the project. Provide examples if applicable. This could include command line instructions, code snippets, or screenshots.
```bash
cargo build
```

## <a name="contributing"></a>🤝 Contributing
## Usage
### Running Examples

If you would like others to contribute to your project, provide guidelines for how they can do so. This could include information on how to report bugs, suggest enhancements, or submit pull requests.
To run the provided example that counts entries in the Ethereum core table:

#### <a name="commit-messages"></a>📝 Commit Messages
```bash

Please ensure your commits follow the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) standards. Doing so allows our CI system to properly categorize changes during the release process.
cargo run --example cli -- -q "select * from ethereum.blocks" --table-ref "ethereum.blocks"
```

## <a name="contact"></a>📧 Contact
### Basic Usage in Code

For questions on this repository, please reach out to [JayWhite2357](https://github.com/JayWhite2357).
Here's how you can use the `SxTClient` in your Rust application:

## <a name="additional-resources"></a>📚 Additional Resources
```rust

- [📋 Changelog](CHANGELOG.md)
- [📜 License](LICENSE)
- [👨‍💻 Code Owners](CODEOWNERS)
use sxt_proof_of_sql_sdk::SxTClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize the SxT client with necessary URLs and API key
let client = SxTClient::new(
"https://api.spaceandtime.dev".to_string(),
"https://proxy.api.spaceandtime.dev".to_string(),
"https://rpc.testnet.sxt.network".to_string(),
"your_sxt_api_key".to_string(),
"path/to/verifier_setup.bin".to_string(),
);

// Execute and verify a SQL query
let result = client
.query_and_verify("SELECT COUNT(*) FROM ethereum.transactions", "ethereum.transactions")
.await?;

println!("Query Result: {:?}", result);
Ok(())
}
```

Note: Replace "your_sxt_api_key" with your actual SxT API key, and ensure the `verifier_setup.bin` file is correctly specified. You can use the [file here](https://github.com/spaceandtimelabs/sxt-proof-of-sql-sdk/blob/main/verifier_setup.bin) or fetch the files [here](https://github.com/spaceandtimelabs/sxt-proof-of-sql/releases/tag/dory-prover-params-nu-16).

## Getting an API Key

To obtain an API key for accessing SxT services, please refer to the [Space and Time docs](https://docs.spaceandtime.io/docs/accreditation-use-api-keys).

## License

This project is licensed under the terms of the [Cryptographic Open Software License 1.0](https://github.com/spaceandtimelabs/sxt-proof-of-sql-sdk/blob/main/LICENSE).
File renamed without changes.
2 changes: 2 additions & 0 deletions chainlink-functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.env.enc
13 changes: 13 additions & 0 deletions chainlink-functions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This example is heavily borrowed from https://docs.chain.link/chainlink-functions/tutorials/api-use-secrets.
1. Run `npm install` to install the dependencies.
2. Set up your on chain resources as shown here: https://docs.chain.link/chainlink-functions/tutorials/api-use-secrets#configure-your-onchain-resources.
3. Add the following environment variables, either in a `.env` file, or using `npx env-enc set`.
```
CONSUMER_ADDRESS=0x8dFf78B7EE3128D00E90611FBeD20A71397064D9 # REPLACE this with your Functions consumer address
SUBSCRIPTION_ID=3 # REPLACE this with your subscription ID
LINK_TOKEN_ADDRESS=0x779877A7B0D9E8603169DdbD7836e478b4624789 # REPLACE this with your wallet address
ETHEREUM_SEPOLIA_RPC_URL=
PRIVATE_KEY=
SXT_API_KEY=
```
4. Run `node example/request.js` to upload the secrets, run a simulation, and then submit a chainlink job.
Loading

0 comments on commit 56fbdb0

Please sign in to comment.