Skip to content

Commit 10f0acd

Browse files
authored
refactor: use latest thegraph-core crate version (#548)
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent 5159de2 commit 10f0acd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+945
-863
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ resolver = "2"
1717
opt-level = 3
1818

1919
[workspace.dependencies]
20-
alloy = { version = "=0.5.4", features = [
21-
"kzg",
22-
"signer-mnemonic",
23-
"dyn-abi",
24-
"sol-types",
25-
"signer-local",
26-
"eip712",
27-
"rlp",
28-
"signers",
29-
], default-features = false }
3020
clap = "4.4.3"
3121
lazy_static = "1.4.0"
3222
axum = { version = "0.7.9", default-features = false, features = [
@@ -62,14 +52,23 @@ uuid = { version = "1.11.0", features = ["v7"] }
6252
tracing = { version = "0.1.40", default-features = false }
6353
bigdecimal = "0.4.3"
6454
build-info = "0.0.39"
65-
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "61b47b3", default-features = false }
66-
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "61b47b3", default-features = false }
55+
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "1c6e29f", default-features = false }
56+
tap_aggregator = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "1c6e29f", default-features = false }
6757
tracing-subscriber = { version = "0.3", features = [
6858
"json",
6959
"env-filter",
7060
"ansi",
7161
], default-features = false }
72-
thegraph-core = { git = "https://github.com/edgeandnode/toolshed", rev = "1663534fc1738e2db1b11cb54b5bb478ee970d40" }
62+
thegraph-core = { version = "0.9.6", features = [
63+
"attestation",
64+
"alloy-eip712",
65+
"alloy-sol-types",
66+
"alloy-rlp",
67+
"alloy-signers",
68+
"alloy-signer-local",
69+
"alloy-signer-mnemonic",
70+
"serde"
71+
] }
7372
thegraph-graphql-http = { version = "0.3.2", features = ["reqwest"] }
7473
graphql_client = { version = "0.14.0", features = ["reqwest-rustls"] }
7574
bip39 = "2.0.0"

crates/allocation/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ edition = "2021"
66
[dependencies]
77
indexer-query = { path = "../query" }
88
serde = { workspace = true, features = ["derive"] }
9-
alloy.workspace = true
109
thegraph-core.workspace = true
1110
anyhow.workspace = true

crates/allocation/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
use std::str::FromStr;
55

6-
use alloy::primitives::U256;
76
use indexer_query::allocations_query;
87
use serde::{Deserialize, Deserializer};
9-
use thegraph_core::{Address, DeploymentId};
8+
use thegraph_core::{
9+
alloy::primitives::{Address, U256},
10+
DeploymentId,
11+
};
1012

1113
#[derive(Clone, Debug, PartialEq, Eq)]
1214
pub struct Allocation {

crates/attestation/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
indexer-allocation = { path = "../allocation" }
8-
alloy.workspace = true
98
thegraph-core.workspace = true
109
anyhow.workspace = true
1110

crates/attestation/src/lib.rs

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

4-
use alloy::{
5-
dyn_abi::Eip712Domain,
6-
signers::{
7-
k256,
8-
local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
4+
use indexer_allocation::Allocation;
5+
use thegraph_core::{
6+
alloy::{
7+
primitives::{Address, ChainId},
8+
signers::{
9+
k256,
10+
local::{coins_bip39::English, MnemonicBuilder, PrivateKeySigner},
11+
},
12+
sol_types::Eip712Domain,
913
},
14+
attestation,
15+
attestation::Attestation,
16+
DeploymentId,
1017
};
11-
use thegraph_core::{attestation, Address, Attestation, ChainId, DeploymentId};
12-
13-
use indexer_allocation::Allocation;
1418

1519
pub fn derive_key_pair(
1620
indexer_mnemonic: &str,
@@ -92,7 +96,7 @@ fn wallet_for_allocation(
9296
// range [0, 100] and checking for a match
9397
for i in 0..100 {
9498
// The allocation was either created at the epoch it intended to or one
95-
// epoch later. So try both both.
99+
// epoch later. So try both.
96100
for created_at_epoch in [allocation.created_at_epoch, allocation.created_at_epoch - 1] {
97101
// The allocation ID is the address of a unique key pair, we just
98102
// need to find the right one by enumerating them all
@@ -117,12 +121,18 @@ fn wallet_for_allocation(
117121

118122
#[cfg(test)]
119123
mod tests {
120-
use alloy::primitives::U256;
121124
use std::str::FromStr;
122-
use test_log::test;
123125

124126
use indexer_allocation::{Allocation, AllocationStatus, SubgraphDeployment};
125127
use test_assets::DISPUTE_MANAGER_ADDRESS;
128+
use test_log::test;
129+
use thegraph_core::{
130+
alloy::{
131+
primitives::{address, Address, U256},
132+
signers::local::PrivateKeySigner,
133+
},
134+
DeploymentId,
135+
};
126136

127137
use super::*;
128138

@@ -142,7 +152,7 @@ mod tests {
142152
)
143153
.unwrap()
144154
.address(),
145-
Address::from_str("0xfa44c72b753a66591f241c7dc04e8178c30e13af").unwrap()
155+
address!("fa44c72b753a66591f241c7dc04e8178c30e13af")
146156
);
147157

148158
assert_eq!(
@@ -157,7 +167,7 @@ mod tests {
157167
)
158168
.unwrap()
159169
.address(),
160-
Address::from_str("0xa171cd12c3dde7eb8fe7717a0bcd06f3ffa65658").unwrap()
170+
address!("a171cd12c3dde7eb8fe7717a0bcd06f3ffa65658")
161171
);
162172
}
163173

@@ -166,7 +176,7 @@ mod tests {
166176
// Note that we use `derive_key_pair` to derive the private key
167177

168178
let allocation = Allocation {
169-
id: Address::from_str("0xa171cd12c3dde7eb8fe7717a0bcd06f3ffa65658").unwrap(),
179+
id: address!("a171cd12c3dde7eb8fe7717a0bcd06f3ffa65658"),
170180
status: AllocationStatus::Null,
171181
subgraph_deployment: SubgraphDeployment {
172182
id: DeploymentId::from_str(
@@ -192,7 +202,7 @@ mod tests {
192202
INDEXER_OPERATOR_MNEMONIC,
193203
&allocation,
194204
1,
195-
*DISPUTE_MANAGER_ADDRESS
205+
DISPUTE_MANAGER_ADDRESS
196206
)
197207
.unwrap()
198208
.signer
@@ -213,7 +223,7 @@ mod tests {
213223

214224
let allocation = Allocation {
215225
// Purposefully wrong address
216-
id: Address::from_str("0xdeadbeefcafebabedeadbeefcafebabedeadbeef").unwrap(),
226+
id: address!("deadbeefcafebabedeadbeefcafebabedeadbeef"),
217227
status: AllocationStatus::Null,
218228
subgraph_deployment: SubgraphDeployment {
219229
id: DeploymentId::from_str(
@@ -237,7 +247,7 @@ mod tests {
237247
INDEXER_OPERATOR_MNEMONIC,
238248
&allocation,
239249
1,
240-
*DISPUTE_MANAGER_ADDRESS
250+
DISPUTE_MANAGER_ADDRESS
241251
)
242252
.is_err());
243253
}

crates/config/Cargo.toml

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

66
[dependencies]
7-
alloy.workspace = true
87
serde.workspace = true
98
thegraph-core.workspace = true
109
tracing.workspace = true

crates/config/src/config.rs

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

4-
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
5-
use figment::{
6-
providers::{Env, Format, Toml},
7-
Figment,
8-
};
9-
use serde_repr::Deserialize_repr;
10-
use serde_with::DurationSecondsWithFrac;
114
use std::{
125
collections::HashMap,
6+
env,
137
net::{Ipv4Addr, SocketAddr, SocketAddrV4},
148
path::PathBuf,
159
str::FromStr,
1610
time::Duration,
1711
};
18-
use tracing::warn;
1912

20-
use alloy::primitives::Address;
13+
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
2114
use bip39::Mnemonic;
15+
use figment::{
16+
providers::{Env, Format, Toml},
17+
Figment,
18+
};
2219
use regex::Regex;
2320
use serde::Deserialize;
24-
use serde_with::serde_as;
25-
use std::env;
26-
use thegraph_core::DeploymentId;
21+
use serde_repr::Deserialize_repr;
22+
use serde_with::{serde_as, DurationSecondsWithFrac};
23+
use thegraph_core::{alloy::primitives::Address, DeploymentId};
2724
use url::Url;
2825

2926
use crate::NonZeroGRT;
@@ -57,7 +54,7 @@ impl<'de> Deserialize<'de> for ConfigWrapper {
5754
D: serde::Deserializer<'de>,
5855
{
5956
let config: Config = serde_ignored::deserialize(deserializer, |path| {
60-
warn!("Ignoring unknown configuration field: {}", path);
57+
tracing::warn!("Ignoring unknown configuration field: {}", path);
6158
})?;
6259

6360
Ok(ConfigWrapper(config))
@@ -158,7 +155,7 @@ impl Config {
158155
x if *x <= 1.into() => {
159156
return Err("trigger_value_divisor must be greater than 1".to_string())
160157
}
161-
x if *x > 1.into() && *x < 10.into() => warn!(
158+
x if *x > 1.into() && *x < 10.into() => tracing::warn!(
162159
"It's recommended that trigger_value_divisor \
163160
be a value greater than 10."
164161
),
@@ -176,7 +173,7 @@ impl Config {
176173
.to_u128()
177174
.unwrap()
178175
{
179-
warn!(
176+
tracing::warn!(
180177
"Trigger value is too low, currently below 0.1 GRT. \
181178
Please modify `max_amount_willing_to_lose_grt` or `trigger_value_divisor`. \
182179
It is best to have a higher trigger value, ideally above 1 GRT. \
@@ -190,7 +187,7 @@ impl Config {
190187
let usual_grt_price = BigDecimal::from_str("0.0001").unwrap() * ten;
191188
if self.tap.max_amount_willing_to_lose_grt.get_value() < usual_grt_price.to_u128().unwrap()
192189
{
193-
warn!(
190+
tracing::warn!(
194191
"Your `max_amount_willing_to_lose_grt` value is too close to zero. \
195192
This may deny the sender too often or even break the whole system. \
196193
It's recommended it to be a value greater than 100x an usual query price."
@@ -200,7 +197,7 @@ impl Config {
200197
if self.subgraphs.escrow.config.syncing_interval_secs < Duration::from_secs(10)
201198
|| self.subgraphs.network.config.syncing_interval_secs < Duration::from_secs(10)
202199
{
203-
warn!(
200+
tracing::warn!(
204201
"Your `syncing_interval_secs` value it too low. \
205202
This may overload your graph-node instance, \
206203
a recommended value is about 60 seconds."
@@ -210,15 +207,15 @@ impl Config {
210207
if self.subgraphs.escrow.config.syncing_interval_secs > Duration::from_secs(600)
211208
|| self.subgraphs.network.config.syncing_interval_secs > Duration::from_secs(600)
212209
{
213-
warn!(
210+
tracing::warn!(
214211
"Your `syncing_interval_secs` value it too high. \
215212
This may cause issues while reacting to updates in the blockchain. \
216213
a recommended value is about 60 seconds."
217214
);
218215
}
219216

220217
if self.tap.rav_request.timestamp_buffer_secs < Duration::from_secs(10) {
221-
warn!(
218+
tracing::warn!(
222219
"Your `tap.rav_request.timestamp_buffer_secs` value it too low. \
223220
You may discart receipts in case of any synchronization issues, \
224221
a recommended value is about 30 seconds."
@@ -423,15 +420,15 @@ pub struct RavRequestConfig {
423420

424421
#[cfg(test)]
425422
mod tests {
426-
use alloy::primitives::FixedBytes;
423+
use std::{env, fs, path::PathBuf};
424+
427425
use figment::value::Uncased;
428426
use sealed_test::prelude::*;
429-
use std::{env, fs, path::PathBuf, str::FromStr};
427+
use thegraph_core::alloy::primitives::address;
430428
use tracing_test::traced_test;
431429

432-
use crate::{Config, ConfigPrefix};
433-
434430
use super::{DatabaseConfig, SHARED_PREFIX};
431+
use crate::{Config, ConfigPrefix};
435432

436433
#[test]
437434
fn test_minimal_config() {
@@ -451,9 +448,7 @@ mod tests {
451448
)
452449
.unwrap();
453450
max_config.dips = Some(crate::DipsConfig {
454-
allowed_payers: vec![thegraph_core::Address(
455-
FixedBytes::<20>::from_str("0x3333333333333333333333333333333333333333").unwrap(),
456-
)],
451+
allowed_payers: vec![address!("3333333333333333333333333333333333333333")],
457452
cancellation_time_tolerance: None,
458453
});
459454

crates/dips/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
alloy.workspace = true
87
thiserror.workspace = true
98
anyhow.workspace = true
10-
alloy-sol-types = "=0.8.15"
11-
alloy-rlp = "0.3.9"
9+
alloy-rlp = "0.3.10"
1210
thegraph-core.workspace = true

crates/dips/src/lib.rs

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

4-
use std::str::FromStr;
5-
use std::time::{Duration, SystemTime, UNIX_EPOCH};
6-
7-
pub use alloy;
8-
pub use alloy_rlp;
9-
10-
use alloy::core::primitives::Address;
11-
use alloy::rlp::{RlpDecodable, RlpEncodable};
12-
use alloy::{primitives::PrimitiveSignature as Signature, signers::SignerSync};
13-
use alloy_rlp::Encodable;
14-
use thegraph_core::alloy_sol_types::{sol, Eip712Domain, SolStruct};
4+
use std::{
5+
str::FromStr,
6+
time::{Duration, SystemTime, UNIX_EPOCH},
7+
};
8+
9+
use thegraph_core::alloy::{
10+
core::primitives::Address,
11+
primitives::PrimitiveSignature as Signature,
12+
rlp::{Encodable, RlpDecodable, RlpEncodable},
13+
signers::SignerSync,
14+
sol,
15+
sol_types::{Eip712Domain, SolStruct},
16+
};
1517
use thiserror::Error;
1618

1719
sol! {
@@ -212,10 +214,14 @@ impl SignedCancellationRequest {
212214
mod test {
213215
use std::time::{Duration, SystemTime, UNIX_EPOCH};
214216

215-
use alloy::primitives::{Address, FixedBytes, U256};
216-
use alloy::signers::local::PrivateKeySigner;
217-
use alloy::sol_types::SolStruct;
218-
use thegraph_core::attestation::eip712_domain;
217+
use thegraph_core::{
218+
alloy::{
219+
primitives::{Address, FixedBytes, U256},
220+
signers::local::PrivateKeySigner,
221+
sol_types::SolStruct,
222+
},
223+
attestation::eip712_domain,
224+
};
219225

220226
use crate::{
221227
AgreementVoucherValidationError, CancellationRequest, CancellationRequestValidationError,

0 commit comments

Comments
 (0)