Skip to content

Commit

Permalink
feat: expose api via a controller
Browse files Browse the repository at this point in the history
  • Loading branch information
dndll committed Jan 5, 2024
1 parent ae4f8dd commit cafc15e
Show file tree
Hide file tree
Showing 15 changed files with 397 additions and 374 deletions.
4 changes: 2 additions & 2 deletions fixtures/batch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"client_block_merkle_root": "WWrLWbWHwSmjtTn5oBZPYgRCuCYn6fkYVa4yhPWNK4L",
"head_block_root": "WWrLWbWHwSmjtTn5oBZPYgRCuCYn6fkYVa4yhPWNK4L",
"batch": [
{
"outcome_proof_block_hash": "3r5dS7bXYG2w35qLXx78nHjPPs8psdYZUdStUYkvHr8N",
Expand Down Expand Up @@ -1312,4 +1312,4 @@
"direction": "Right"
}
]
}
}
3 changes: 1 addition & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
rustc = rustVersion;
};
in {
# stdenv = pkgs.clangStdenv;
stdenv = pkgs.fastStdenv;
devShell = pkgs.mkShell {
LIBCLANG_PATH = pkgs.libclang.lib + "/lib/";
PROTOC = pkgs.protobuf + "/bin/protoc";
# LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib/:$LD_LIBRARY_PATH";

nativeBuildInputs = with pkgs; [
bashInteractive
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# This specifies the version of Rust we use to build.
# Individual crates in the workspace may support a lower version, as indicated by `rust-version` field in each crate's `Cargo.toml`.
# The version specified below, should be at least as high as the maximum `rust-version` within the workspace.
channel = "nightly-2023-12-02"
channel = "1.75.0"
components = [ "rustfmt", "clippy"]
6 changes: 1 addition & 5 deletions src/client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ use thiserror::Error;
pub enum Error {
#[error("Block already verified")]
BlockAlreadyVerified,
#[error("Block not current or next epoch")]
#[error("Block not in current or next epoch")]
BlockNotCurrentOrNextEpoch,
#[error("Signature invalid")]
SignatureInvalid,
#[error("Not enough approved stake")]
NotEnoughApprovedStake,
#[error("Block is in the next epoch but no new set")]
NextBpsInvalid,
#[error("Signature len mismatch")]
SignatureLenMismatch,
#[error("Invalid proof")]
InvalidProof,
#[error("Validator not signed")]
ValidatorNotSigned,
}
31 changes: 16 additions & 15 deletions src/client/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::{Header, Proof};
use super::{protocol::experimental::Proof as ExperimentalProof, Header, Proof};
use anyhow::Result;
use coerce::actor::message::Message;
use near_primitives_core::{hash::CryptoHash, types::AccountId};
use near_primitives::types::TransactionOrReceiptId;
use near_primitives_core::hash::CryptoHash;
use serde::{Deserialize, Serialize};

pub struct Shutdown;

Expand All @@ -23,35 +25,34 @@ impl Message for Archive {
type Result = Option<Header>;
}

pub enum GetProof {
Transaction {
transaction_id: CryptoHash,
sender_id: AccountId,
},
Receipt {
receipt_id: CryptoHash,
receiver_id: AccountId,
},
}
#[derive(Debug, Deserialize, Serialize)]
pub struct GetProof(pub TransactionOrReceiptId);

impl Message for GetProof {
type Result = Option<super::BasicProof>;
type Result = Option<super::Proof>;
}

#[derive(Debug, Deserialize, Serialize)]
pub struct BatchGetProof(pub Vec<GetProof>);

impl Message for BatchGetProof {
type Result = Option<(ExperimentalProof, Vec<anyhow::Error>)>;
}

pub struct VerifyProof {
pub proof: Proof,
}

impl Message for VerifyProof {
type Result = bool;
type Result = Result<bool>;
}

// TODO: batch messages
//
//

Check warning on line 52 in src/client/message.rs

View workflow job for this annotation

GitHub Actions / Lint

Diff in /home/runner/work/near-light-client/near-light-client/src/client/message.rs
#[cfg(test)]
mod tests {
use super::*;


#[test]
fn test_name() {}
Expand Down
Loading

0 comments on commit cafc15e

Please sign in to comment.