Skip to content

Commit 885ddfe

Browse files
Merge branch 'graphprotocol:main' into main
2 parents 99740aa + ff06fa6 commit 885ddfe

File tree

15 files changed

+134
-278
lines changed

15 files changed

+134
-278
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version = "1.1.0"
44
edition = "2021"
55

66
[dependencies]
7+
indexer-config = { path = "../config" }
78
thiserror.workspace = true
89
async-trait.workspace = true
910
alloy.workspace = true
@@ -37,6 +38,7 @@ tower-http = { version = "0.5.2", features = [
3738
"trace",
3839
] }
3940
tokio-util = "0.7.10"
41+
bip39 = "2.0.0"
4042

4143
[dev-dependencies]
4244
env_logger = { version = "0.11.0", default-features = false }

common/src/address.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use alloy::signers::local::{
55
coins_bip39::English, LocalSignerError, MnemonicBuilder, PrivateKeySigner,
66
};
7+
use bip39::Mnemonic;
78

89
/// Build Wallet from Private key or Mnemonic
910
pub fn build_wallet(value: &str) -> Result<PrivateKeySigner, LocalSignerError> {
@@ -13,8 +14,8 @@ pub fn build_wallet(value: &str) -> Result<PrivateKeySigner, LocalSignerError> {
1314
}
1415

1516
// Format public key to a String
16-
pub fn public_key(value: &str) -> Result<String, LocalSignerError> {
17-
let wallet = build_wallet(value)?;
17+
pub fn public_key(value: Mnemonic) -> Result<String, LocalSignerError> {
18+
let wallet = build_wallet(&value.to_string())?;
1819
let addr = format!("{:?}", wallet.address());
1920
Ok(addr)
2021
}

common/src/attestations/signers.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22
// SPDX-License-Identifier: Apache-2.0
33

4+
use bip39::Mnemonic;
45
use std::collections::HashMap;
56
use std::sync::Arc;
67
use thegraph_core::{Address, ChainId};
@@ -18,12 +19,13 @@ use crate::prelude::{Allocation, AttestationSigner};
1819
/// An always up-to-date list of attestation signers, one for each of the indexer's allocations.
1920
pub async fn attestation_signers(
2021
mut indexer_allocations_rx: Receiver<HashMap<Address, Allocation>>,
21-
indexer_mnemonic: String,
22+
indexer_mnemonic: Mnemonic,
2223
chain_id: ChainId,
2324
mut dispute_manager_rx: Receiver<Option<Address>>,
2425
) -> Receiver<HashMap<Address, AttestationSigner>> {
2526
let attestation_signers_map: &'static Mutex<HashMap<Address, AttestationSigner>> =
2627
Box::leak(Box::new(Mutex::new(HashMap::new())));
28+
let indexer_mnemonic = indexer_mnemonic.to_string();
2729

2830
let starter_signers_map = modify_sigers(
2931
Arc::new(indexer_mnemonic.clone()),
@@ -91,14 +93,17 @@ async fn modify_sigers(
9193
if !signers.contains_key(id) {
9294
let signer =
9395
AttestationSigner::new(&indexer_mnemonic, allocation, chain_id, dispute_manager);
94-
if let Err(e) = signer {
95-
warn!(
96-
"Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}",
97-
allocation.id, allocation.subgraph_deployment.id,
98-
allocation.created_at_epoch, e
99-
);
100-
} else {
101-
signers.insert(*id, signer.unwrap());
96+
match signer {
97+
Ok(signer) => {
98+
signers.insert(*id, signer);
99+
}
100+
Err(e) => {
101+
warn!(
102+
"Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}",
103+
allocation.id, allocation.subgraph_deployment.id,
104+
allocation.created_at_epoch, e
105+
);
106+
}
102107
}
103108
}
104109
}
@@ -108,9 +113,7 @@ async fn modify_sigers(
108113

109114
#[cfg(test)]
110115
mod tests {
111-
use crate::test_vectors::{
112-
DISPUTE_MANAGER_ADDRESS, INDEXER_ALLOCATIONS, INDEXER_OPERATOR_MNEMONIC,
113-
};
116+
use crate::test_vectors::{DISPUTE_MANAGER_ADDRESS, INDEXER_ALLOCATIONS, INDEXER_MNEMONIC};
114117

115118
use super::*;
116119

@@ -123,7 +126,7 @@ mod tests {
123126
.unwrap();
124127
let mut signers = attestation_signers(
125128
allocations_rx,
126-
(*INDEXER_OPERATOR_MNEMONIC).to_string(),
129+
INDEXER_MNEMONIC.clone(),
127130
1,
128131
dispute_manager_rx,
129132
)

common/src/indexer_service/http/config.rs

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)