-
Notifications
You must be signed in to change notification settings - Fork 5
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 request type in broadcast message #1
base: trunk
Are you sure you want to change the base?
Conversation
Thanks for jumping in! Am I understanding correctly that this is intended to update |
Sorry for delay, wanted to make working example and it took more time than expected. So basically I tried After comparing the request with the client in using request = std::variant<execute_request, validate_request>;
using response = std::variant<execute_response, validate_response>; The first commit in this PR makes the The second commit (hopefully) properly reads the response from sentinel (or coordinator or shard). It also adds compact tx representation and make it possible to mint and transfer solely with |
Not a problem!
This makes sense actually;
This sounds terrific, thank you for the help! I'll work to get a t-ACK for you today! |
heads-up in-advance; OpenCBDC uses the DCO, and all commits need a sign-off before merging. Just in-case it's not clear, the intent of this is to ensure you keep your intellectual property rights for your contributions! |
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.
concept-ACK. Looks like there a couple small clean-ups/fixes to go through first, but my impression is that this is a solid contribution headed towards bringing -js
inline with supporting sentinel attestations.
I do have one question for you though: this change also adds the ability to communicate with the coordinator and shards. Do you think that's missing or useful functionality?
It was previously left out because there's effectively no reason to allow communication to any component other than the sentinel (and, perhaps the watchtower); presumably, -js
would be most useful for external implementers/integrations—users who would be explicitly outside the secure perimeter.
src/transaction/transaction.js
Outdated
if ((!'inputs') in this || !Array.isArray(this.inputs)) | ||
throw new Error("object doesn't contain inputs"); | ||
|
||
const inbuf = buffer.alloc(8); | ||
inbuf.writeBigUInt64LE(BigInt(this.inputs.length)); | ||
ary.push(inbuf); | ||
|
||
for (let i=0; i<this.inputs.length; i++) { | ||
if ( !'tx_hash' in this.inputs[i] | ||
|| !'index' in this.inputs[i] | ||
|| !'witnessProgramCommitment' in this.inputs[i] | ||
|| !'value' in this.inputs[i] ) | ||
throw new Error('input '+i+' doesn\'t contain tx_hash, index, witnessProgramCommitment, value'); | ||
for (let i = 0; i < this.inputs.length; i++) { | ||
if ( | ||
(!'tx_hash') in this.inputs[i] || | ||
(!'index') in this.inputs[i] || | ||
(!'witnessProgramCommitment') in this.inputs[i] || | ||
(!'value') in this.inputs[i] |
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.
All these instances of (!str) in obj
are likely incorrect. (Note though that this was actually already wrong: !
binds tighter than in
.)
These probably all need to be corrected to be of the form !(str in obj)
such that it is negating the property-existence-check (rather than negating the string before checking that it exists in the object).
These checks as-written will probably never trigger (again, they probably never would have before either), as !str in obj
(which is equivalent to (!str) in obj
) effectively evaluates !str
to false
which is then coerced back into a string ('false'
), and 'false' in obj
is likely to return false
in most cases.
src/transaction/transaction.js
Outdated
(!'tx_hash') in this.inputs[i] || | ||
(!'index') in this.inputs[i] || | ||
(!'witnessProgramCommitment') in this.inputs[i] || | ||
(!'value') in this.inputs[i] |
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.
This snippet (and, perhaps, more generally code to validate a message is well-formed) appears in enough places, it probably makes sense to be turned into a helper (even if not exposed external of this file/module).
Signed-off-by: Amir m. Aghapour <[email protected]>
response of broadcast handled full example for mint and transfer added Signed-off-by: Amir m. Aghapour <[email protected]>
added DCO.
In case of coordinator, I did it mostly to mint without using
I felt it's wrong but considered it as yet-another-weird js syntax and didn't dig into it, sorry. I starting fixing them and added a helper function but on second though are these checks really necessary? I mean one can't simply make an |
Thank you!
This is an interesting point, but I think freely exposing communication to internal components is an unacceptable solution (this is not intended as mean!). There are two reasons for this, one general, and one shard-specific:
To that end, I think enabling communication to internal components can be useful in specific circumstances—predominantly testing—(and I'm not against merging it), but I think it should be gated by a global-unsafe-declaration flag react-style, and must print a diagnostic to the log saying something to the effect of “[SECURITY VIOLATION]: Bypassing sentinel layer is enabled!” on every invocation of sending a message. The alternative is to expose an additional API call for the sentinels to support (e.g., “is this note spendable?”), and to then expose that interface through clients (and, by extension, this library). This is quite a bit more work, but that's how it must be done to not open a massive security violation.
Pretty obviously, I missed it in the initial code review before release; don't sweat it!
Good point! I'm quite comfortable with more useful sanity checks being put in-place instead; but it might be helpful context to know why these checks are here in the first place. In So, I think it might be best if we leave the current checks in-place, suitably updated to function correctly; and, if you'd like to either extend this PR with better sanity checks that enforce useful properties rather than the kind-of-silly format-compliance ones (or open that as an additional PR), they can be added. Does that seem like a reasonable plan? Footnotes
|
Requesting an additional review (particularly making sure I've not totally missed anything with my most recent post/analysis) from @anders94 |
Signed-off-by: Amir m. Aghapour <[email protected]>
I totally agree with you here and understand two reasons you provided, enabling Thing is a supervisee of mine is working on All in all I am convinced to mark communicating with non-sentinel components as test-only or DON'T-USE-unless-your-life-depends-on-it, yet I have no idea how to do it as it is not made explicit what the destination endpoint is! Maybe just making it clear in jsdoc or README is enough? One minor point is (maybe I am wrong here) the function was named
Sure! Moved the fixed version of previous checks to helper function and added hex character and length checks. Still there's always room for more checks ... |
That's very exciting, and it's very cool to hear why you're poking around with this. I think I might suggest two specific options then:
These are effectively the two options I laid out in opencbdc-ui#2; it sounds like you may have already taken a look at it since it sounds like you're looking to add an admin panel. I'd be quite comfortable with either option (or both, if there's a benefit to it)! From the perspective of When you're ready for me to take another walk through the code, feel free to re-request my review. (And I'll continue to monitor discussion and help plan and troubleshoot!) |
Added index of request type (execution/validation) as an argument with default parameter to clarify deserialization of std::variant. Also removed the callback of write since it is not an error handling callback!