Skip to content

Commit

Permalink
Merge branch 'main' into feat/update-worker-set
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcobb23 committed Aug 25, 2023
2 parents 9d3f352 + 6a3c6f2 commit 58781f4
Show file tree
Hide file tree
Showing 27 changed files with 1,046 additions and 163 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ P --"GetMessages([M1.id,M2.id])"-->G2
P --"GetActiveWorkers"-->S
P --"StartSigningSession(key_id, batch_hash)"-->M
Workers --"SubmitSignature(session_id, signature)"-->M
Relayer --"GetProof(proof_id)" --> P
Relayer --"GetProof(multisig_session_id)" --> P
P --"GetSigningSession(session_id)"-->M
```

Expand Down Expand Up @@ -114,11 +114,11 @@ sequenceDiagram
OutgoingGateway-->>Prover: [M1,M2]
Prover->>Prover: create batch of [M1,M2]
Prover->>Multisig: StartSigningSession(snapshot, batch hash)
Multisig-->>Prover: session_id
Prover-->>Relayer: proof_id
Multisig-->>Prover: multisig_session_id
Prover-->>Relayer: multisig_session_id
Worker->>Multisig: SubmitSignature(session_id, signature)
Worker->>Multisig: SubmitSignature(session_id, signature)
Relayer->>Prover: GetProof(proof_id)
Relayer->>Prover: GetProof(multisig_session_id)
Prover->>Multisig: GetSigningSession(session_id)
Multisig-->>Prover: signing session
Prover-->>Relayer: signed batch
Expand All @@ -144,8 +144,7 @@ The gateway also accepts messages from the router. These are messages sent from
The verifier contracts are responsible for verifying whether a given message or batch of messages has occurred on a connected external chain. The verifier can take many different forms, such as a [`voting-verifier`](./contracts/voting-verifier) that conducts stake weighted polls for batches of messages, a light client that accepts block headers and merkle tree proofs, a zk proof verifier, etc. The verifier can also be an [`aggregate-verifier`](./contracts/aggregate-verifier), that is linked to 1 or more other verifiers, and defines a security policy such as 2 out of 3 linked verification methods need to report a message as verified.

### Prover
The prover contract is responsible for constructing proofs of routed messages, to be passed to external chains. The most common example of this is the [`multisig-prover`](./contracts/command-batcher) that constructs signed batches of routed messages, which are then relayed (permissionlessly) to an external chain. In this example, the prover fetches the messages from the gateway, and interacts with the multisig contract to conduct the signing,
The prover contract is responsible for constructing proofs of routed messages, to be passed to external chains. The most common example of this is the [`multisig-prover`](./contracts/multisig-prover) that constructs signed batches of routed messages, which are then relayed (permissionlessly) to an external chain. In this example, the prover fetches the messages from the gateway, and interacts with the multisig contract to conduct the signing,
The prover contract is responsible for constructing proofs of routed messages, to be passed to external chains. The most common example of this is the [`multisig-prover`](./contracts/multisig-prover) that constructs signed batches of routed messages, which are then relayed (permissionlessly) to an external chain. In this example, the prover fetches the messages from the gateway, and interacts with the multisig contract to conduct the signing.

### Multisig Contract
[`multisig`](./contracts/multisig) is responsible for signing arbitrary blobs of data. Contracts register with the multisig contract to generate a key id, and then use that key id to initiate signing sessions. Off chain workers associated with the key id sign messages when new signing sessions are created.
Expand Down
9 changes: 6 additions & 3 deletions ampd/tests/report.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::env;

use error_stack::Report;

use ampd::report::{Error, LoggableError};

// Do not move this test or the location field checks break
#[test]
fn correct_error_log() {
env::set_var("RUST_BACKTRACE", "1");
let report = Report::new(Error::new("error1".to_string()))
.attach_printable("foo1")
.change_context(Error::new("error2".to_string()))
Expand All @@ -25,15 +28,15 @@ fn correct_error_log() {
let expected_err = LoggableError {
msg: "error3".to_string(),
attachments: vec!["opaque attachment".to_string()],
location: "ampd/tests/report.rs:13:10".to_string(),
location: "ampd/tests/report.rs:16:10".to_string(),
cause: Some(Box::new(LoggableError {
msg: "error2".to_string(),
attachments: vec!["test1".to_string(), "test2".to_string()],
location: "ampd/tests/report.rs:10:10".to_string(),
location: "ampd/tests/report.rs:13:10".to_string(),
cause: Some(Box::new(LoggableError {
msg: "error1".to_string(),
attachments: vec!["foo1".to_string()],
location: "ampd/tests/report.rs:8:18".to_string(),
location: "ampd/tests/report.rs:11:18".to_string(),
cause: None,
backtrace: None,
})),
Expand Down
3 changes: 3 additions & 0 deletions contracts/multisig-prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ cosmwasm-schema = "1.1.3"
cosmwasm-std = "1.1.3"
cosmwasm-storage = "1.1.3"
cw-storage-plus = "1.0.1"
cw-utils = "1.0.1"
cw2 = "0.15.1"
schemars = "0.8.10"
serde = { version = "1.0.145", default-features = false, features = ["derive"] }
Expand All @@ -47,6 +48,8 @@ multisig = { workspace = true, features = ["library"] }
service-registry = { workspace = true, features = ["library"] }
axelar-wasm-std = { workspace = true }
k256 = { version = "0.13.1", features = ["ecdsa"] }
gateway = { workspace = true, features = ["library"]}

[dev-dependencies]
cw-multi-test = "0.15.1"
anyhow = "1.0"
30 changes: 11 additions & 19 deletions contracts/multisig-prover/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub enum ExecuteMsg {
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(GetProofResponse)]
GetProof { proof_id: String },
GetProof { multisig_session_id: Uint64 },
}

pub enum ProofStatus {
Expand All @@ -97,32 +97,24 @@ pub enum ProofStatus {
}

pub struct GetProofResponse {
pub proof_id: HexBinary,
pub multisig_session_id: Uint64,
pub message_ids: Vec<String>,
pub data: Data,
pub proof: Proof,
pub status: ProofStatus,
}

pub struct Data {
pub destination_chain_id: Uint256,
pub commands_ids: Vec<[u8; 32]>,
pub commands_types: Vec<String>,
pub commands_params: Vec<HexBinary>
}

pub struct Proof {
pub operators: Vec<Addr>,
pub weights: Vec<Uint256>,
pub threshold: Uint256,
pub signatures: Vec<HexBinary>,
}
```

## Events

```Rust
pub struct ProofUnderConstruction {
pub proof_id: HexBinary, // Unique hash derived from the message ids
pub enum Event {
ProofUnderConstruction {
multisig_session_id: Uint64,
},
SnapshotRotated {
key_id: String,
snapshot: Snapshot,
pub_keys: HashMap<String, HexBinary>,
},
}
```
Loading

0 comments on commit 58781f4

Please sign in to comment.