-
Notifications
You must be signed in to change notification settings - Fork 86
feat: Integrate ntx-builder with validator #1453
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
Open
sergerad
wants to merge
8
commits into
next
Choose a base branch
from
sergerad-ntx-builder-validator
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d907308
Revert "Revert "Use RPC to submit proven tx in ntx-builder""
sergerad c3948e7
Missing file
sergerad 2337bfc
Changelog
sergerad 11045cc
Comment
sergerad 3067c4c
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-nt…
sergerad 5e16311
Replace rpc submission with validator
sergerad 8efd76f
Comments
sergerad c60ad81
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-nt…
sergerad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| use miden_node_proto::clients::{Builder, RpcClient as InnerRpcClient}; | ||
| use miden_node_proto::generated::{self as proto}; | ||
| use miden_objects::transaction::{ProvenTransaction, TransactionInputs}; | ||
| use miden_tx::utils::Serializable; | ||
| use tonic::Status; | ||
| use tracing::{info, instrument}; | ||
| use url::Url; | ||
|
|
||
| use crate::COMPONENT; | ||
|
|
||
| // RPC CLIENT | ||
| // ================================================================================================ | ||
|
|
||
| /// Interface to the RPC server's gRPC API. | ||
| #[derive(Clone, Debug)] | ||
| pub struct RpcClient { | ||
| client: InnerRpcClient, | ||
| } | ||
|
|
||
| impl RpcClient { | ||
| /// Creates a new RPC client with a lazy connection. | ||
| pub fn new(rpc_url: Url) -> Self { | ||
| info!(target: COMPONENT, rpc_endpoint = %rpc_url, "Initializing RPC client with lazy connection"); | ||
|
|
||
| let rpc = Builder::new(rpc_url) | ||
| .without_tls() | ||
| .without_timeout() | ||
| .without_metadata_version() | ||
| .without_metadata_genesis() | ||
| .with_otel_context_injection() | ||
| .connect_lazy::<InnerRpcClient>(); | ||
|
|
||
| Self { client: rpc } | ||
| } | ||
|
|
||
| /// Submits a proven transaction with transaction inputs to the RPC server. | ||
| #[instrument(target = COMPONENT, name = "ntx.rpc.client.submit_proven_transaction", skip_all, err)] | ||
| pub async fn submit_proven_transaction( | ||
| &self, | ||
| proven_tx: ProvenTransaction, | ||
| tx_inputs: TransactionInputs, | ||
| ) -> Result<(), Status> { | ||
| let request = proto::transaction::ProvenTransaction { | ||
| transaction: proven_tx.to_bytes(), | ||
| transaction_inputs: Some(tx_inputs.to_bytes()), | ||
| }; | ||
|
|
||
| self.client.clone().submit_proven_transaction(request).await?; | ||
|
|
||
| Ok(()) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unfortunately this won't work as the RPC rejects network transactions since these are not allowed to be sent publicly (yet).
Options:
I haven't done (3) with gRPC before, so I would automatically reach for auth via http but https://grpc.io/docs/guides/auth/ has some more info.
Uh oh!
There was an error while loading. Please reload this page.
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.
Can you share some more context on the relationship of auth / network transactions beyond to give some context? (link is enough)
Uh oh!
There was an error while loading. Please reload this page.
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.
There isn't really any direct context aside from the fact that currently we only allow our own network transaction builder component to submit network transactions. Allowing external submissions would cause races with our builder and we don't want to deal with that at this stage.
This is currently enforced in the RPC component's
SubmitProvenTransactionimplementation by simply rejecting all transactions that target a network account (except for those which create the account). This means external clients/users can only create a network account and thereafter all transactions for that account cannot go via the public RPC endpoints.The network tx builder circumvents this by using the block-producer's
SubmitProvenTransactiondirectly. This works but now that we're adding additional logic (validator stuff) to the RPC's gRPC implementation it would be ideal if we only have that in a single place.Network transactions must also be submitted to the validator, so either we
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 don't think option 2 is viable. Network transactions shouldn't come from the outside at this point.
Why is option 1 unreasonable? NTX builder could send the transaction directly to the validator in the same way as the RPC does. It feel like this would take the least amount of work.
My order of preference would probably be:
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.
Summarizing: go with option 1 - ntx-builder talks directly to validator
Uh oh!
There was an error while loading. Please reload this page.
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.
Moved forward with Option 1 (ready for review again)