-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add dips graphql #331
base: main
Are you sure you want to change the base?
add dips graphql #331
Conversation
1c724c9
to
ab06867
Compare
Pull Request Test Coverage Report for Build 11443538911Details
💛 - Coveralls |
2c3a2ec
to
4a514e9
Compare
72ebe2c
to
e2359ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check my comments 🙂
pub expected_payee: String, | ||
pub allowed_payers: Vec<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use the thegraph_core::Address
type here, as we'll provide Ethereum addresses. This way, we can validate at deserialization time.
config/src/config.rs
Outdated
#[derive(Debug, Deserialize)] | ||
#[cfg_attr(test, derive(PartialEq))] | ||
pub struct DipsConfig { | ||
pub expected_payee: String, | ||
pub allowed_payers: Vec<String>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here
dips/src/lib.rs
Outdated
sol! { | ||
// EIP712 encoded bytes, ABI - ethers | ||
#[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)] | ||
struct SignedIndexingAgreementVoucher { | ||
IndexingAgreementVoucher voucher; | ||
bytes signature; | ||
} | ||
|
||
#[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)] | ||
struct IndexingAgreementVoucher { | ||
// should coincide with signer | ||
address payer; | ||
// should coincide with indexer | ||
address payee; | ||
// data service that will initiate payment collection | ||
address service; | ||
// initial indexing amount max | ||
uint256 maxInitialAmount; | ||
uint256 maxOngoingAmountPerEpoch; | ||
// time to accept the agreement, intended to be on the order | ||
// of hours or mins | ||
uint64 deadline; | ||
uint32 maxEpochsPerCollection; | ||
uint32 minEpochsPerCollection; | ||
// after which the agreement is complete | ||
uint32 durationEpochs; | ||
bytes metadata; | ||
} | ||
|
||
// the vouchers are generic to each data service, in the case of subgraphs this is an ABI-encoded SubgraphIndexingVoucherMetadata | ||
#[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)] | ||
struct SubgraphIndexingVoucherMetadata { | ||
uint256 pricePerBlock; // wei GRT | ||
bytes32 protocolNetwork; // eip199:1 format | ||
// differentiate based on indexed chain | ||
bytes32 chainId; // eip199:1 format | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for the future: We might want this to be part of the thegraph_core
crate to share the same code between the different parts.
dips/src/lib.rs
Outdated
|
||
let payer = sig | ||
.recover_address_from_msg(self.voucher.eip712_hash_struct()) | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to return a false
instead of panicking.
EDIT: +1 to the error type on the TODO comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EIP-712 domain separator is an essential part of the signing schema. I miss it here.
Check this implementation for an example: https://github.com/edgeandnode/toolshed/blob/e7ea9a8209b7a960b4c3bd4e9a0dd2f2ea9019a2/thegraph-core/src/attestation.rs#L70-L79
|
||
#[async_trait] | ||
pub trait AgreementStore: Sync + Send { | ||
async fn get_by_signature(&self, signature: String) -> anyhow::Result<Option<Agreement>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am considering using a UUIDv7 as the agreement identifier instead of the signature. It has some good properties that we can use to manage and trace data across the different DIPs' parties (i.e., DIPs Gateway/Dipper, Indexer, and future smart contracts).
Of course, these IDs will be only relevant on the indexer-facing side of the DIPs domain.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, as UUIDv7 is lexicographically sortable, we can quickly sort the agreements from oldest to newest without requiring a timestamp field.
Additionally, I feel more comfortable providing a UUID as a "path parameter" in a RESTful API than a base64 RLP encoded signature because we would need to use the "URL-friendly" flavor of the Base64 encoding.
2c49fc1
to
bd31868
Compare
641ad4d
to
2fbf0c3
Compare
c990e2e
to
f7acdc7
Compare
No description provided.