-
Notifications
You must be signed in to change notification settings - Fork 1
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
grant_installation #50
Conversation
should have an integration test in the style of revoke_installation |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
==========================================
+ Coverage 77.32% 82.01% +4.69%
==========================================
Files 10 10
Lines 172 228 +56
==========================================
+ Hits 133 187 +54
- Misses 39 41 +2 ☔ View full report in Codecov by Sentry. |
let attribute: [u8; 32] = Attribute::from(name).into(); | ||
log::debug!( | ||
"setting attribute {:#?}", | ||
String::from_utf8_lossy(&attribute) |
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.
Remember that this string will always be created, even if this log is suppressed. This may be slightly too verbose logging.
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'm perfectly fine eliminating that. it was used during my debugging, but I don't feel strongly here.
@jac18281828 question - I've calculated a validity to be one year in the future.
|
) | ||
.send() | ||
.await? | ||
.await?; |
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.
so far, we've been doing this strategy with .await?.await?
which first sends the transaction, gets back a PendingTransaction
, and then waits for it to be included + a specified amount of confirmations (default of 1). I like what you did below, though, but unsure what the better path would be:
Do we make the gateway wait until tx is confirmed or do we just return the tx_hash and have libxmtp/client wait?
We can instead just return the txHash from the RPC, and not wait on transaction inclusion, leaving tx confirmations up to the client. We do give up some control if something goes wrong.
Not a super important detail, but maybe worth a quick discussion WDYT @tsachiherman @jac18281828 @37ng
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 think that it's a very important observation, as this is a blocking operation that consumes servers memory for the entire duration of the operation.
Another point is that regardless if we make it "non-blocking" or not, we need to be able to detect a fail cases so that we can log these.
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.
That's true, IMO I think we should hand off control of the transaction to the client and just return txHash. A PendingTransaction
can be easily rebuilt from libxmtp
side by just providing the hash and a provider, so if anything fails they could re-submit the transaction
We could also provide an endpoint to do this for them, i.e subscribeTransaction
or something along those lines
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.
We should avoid waiting whenever possible in the service. We haven't spent much time optimizing the number of threads, etc., these threads will be precious.
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.
made an issue for this: #52
the return of revoke_installation will have to change as well
@@ -23,16 +24,57 @@ where | |||
Self { registry } | |||
} | |||
|
|||
fn resolve_did_address(&self, did: String) -> Result<H160, ContactOperationError<M>> { | |||
// for now, we will just assume the DID is a valid ethereum wallet address | |||
// TODO: Parse or resolve the actual DID |
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.
Made into an issue, #51
@@ -23,16 +24,57 @@ where | |||
Self { registry } | |||
} | |||
|
|||
fn resolve_did_address(&self, did: String) -> Result<H160, ContactOperationError<M>> { | |||
// for now, we will just assume the DID is a valid ethereum wallet address | |||
// TODO: Parse or resolve the actual DID |
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.
// TODO: Parse or resolve the actual DID |
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.
Looks good! I'm willing to approve after an integration test is added
The validity period should be sent to the contract (how long). The contract computes the validity internally according to the EVM block timestamp and reports back the validity that it came up with. That validity should then be used in the future for all operations. The validity required for the signature will be the duration validity (one year) not the actual timestamp. We may want to standardize on two options to begin with: does not expire, or one year |
see |
We could do this in the style of the attribute, i.e an enum like enum Validity {
OneYear
Forever
} |
Yeah, my bad, I should have looked it up before I wrote my message but a validity is always required. We may want to choose either OneYear or FiveYear. |
I'll merge it and keep working on the extended unit tests & validity. |
What ?
This PR adds support for registering a new installation.
Design considerations
The
xps-gateway
is the executable endpoint, that manages the rpc endpoint. It will setup an rpc server that would listen for incoming requests and perform input validation. Valid requests would be forwarded to the inbox / messaging / registry crates for method-specific implementation.Requirements
This PR followed the design details in #22; discussion in #13 and xmtp/libxmtp#274