-
Notifications
You must be signed in to change notification settings - Fork 162
ci: update Solo version used in CI tests #2733
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
imshubham22apr-gif
wants to merge
4
commits into
hiero-ledger:main
Choose a base branch
from
imshubham22apr-gif:ci/update-solo-version
base: main
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e4b9560
ci: update Solo version used in CI tests
imshubham22apr-gif 05cbdf2
fix: handle FeeEstimateQuery failures and avoid duplicate transactions
imshubham22apr-gif 3d6b748
Merge remote-tracking branch 'upstream/main' into temp-signed-fix
imshubham22apr-gif a12bab3
fix: implement retry mechanism for FeeEstimateQuery in example
imshubham22apr-gif 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,9 @@ public static void main(String[] args) throws Exception { | |
| TransferTransaction tx = createTransferTransaction(client, recipientId); | ||
| FeeEstimateResponse stateEstimate = estimateWithStateMode(client, tx); | ||
| FeeEstimateResponse intrinsicEstimate = estimateWithIntrinsicMode(client, tx); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete the new lines here and on line 66 |
||
| compareEstimates(stateEstimate, intrinsicEstimate); | ||
|
|
||
| demonstrateTokenCreationEstimate(client); | ||
|
|
||
| client.close(); | ||
|
|
@@ -100,10 +102,11 @@ private static TransferTransaction createTransferTransaction(Client client, Acco | |
| private static FeeEstimateResponse estimateWithStateMode(Client client, TransferTransaction tx) throws Exception { | ||
| System.out.println("\n=== Estimating Fees with STATE Mode ==="); | ||
|
|
||
| FeeEstimateResponse stateEstimate = new FeeEstimateQuery() | ||
| FeeEstimateQuery query = new FeeEstimateQuery() | ||
| .setMode(FeeEstimateMode.STATE) | ||
| .setTransaction(tx) | ||
| .execute(client); | ||
| .setTransaction(tx); | ||
|
|
||
| FeeEstimateResponse stateEstimate = executeWithRetry(query, client); | ||
|
|
||
| printNetworkFee(stateEstimate); | ||
| printNodeFee(stateEstimate); | ||
|
|
@@ -151,10 +154,11 @@ private static FeeEstimateResponse estimateWithIntrinsicMode(Client client, Tran | |
| throws Exception { | ||
| System.out.println("\n=== Estimating Fees with INTRINSIC Mode ==="); | ||
|
|
||
| FeeEstimateResponse intrinsicEstimate = new FeeEstimateQuery() | ||
| FeeEstimateQuery query = new FeeEstimateQuery() | ||
| .setMode(FeeEstimateMode.INTRINSIC) | ||
| .setTransaction(tx) | ||
| .execute(client); | ||
| .setTransaction(tx); | ||
|
|
||
| FeeEstimateResponse intrinsicEstimate = executeWithRetry(query, client); | ||
|
|
||
| System.out.println( | ||
| "Network Fee Subtotal: " + intrinsicEstimate.getNetwork().getSubtotal() + " tinycents"); | ||
|
|
@@ -187,12 +191,33 @@ private static void demonstrateTokenCreationEstimate(Client client) throws Excep | |
| .freezeWith(client) | ||
| .signWithOperator(client); | ||
|
|
||
| FeeEstimateResponse tokenEstimate = new FeeEstimateQuery() | ||
| FeeEstimateQuery query = new FeeEstimateQuery() | ||
| .setMode(FeeEstimateMode.STATE) | ||
| .setTransaction(tokenTx) | ||
| .execute(client); | ||
| .setTransaction(tokenTx); | ||
|
|
||
| FeeEstimateResponse tokenEstimate = executeWithRetry(query, client); | ||
|
|
||
| System.out.println("Token Creation Estimated Fee: " + tokenEstimate.getTotal() + " tinycents"); | ||
| System.out.println("Token Creation Estimated Fee: " + Hbar.fromTinybars(tokenEstimate.getTotal() / 100)); | ||
| } | ||
|
|
||
| private static FeeEstimateResponse executeWithRetry(FeeEstimateQuery query, Client client) throws Exception { | ||
| int maxAttempts = 5; | ||
| int waitMillis = 2000; | ||
| IllegalStateException lastException = null; | ||
|
|
||
| for (int attempt = 1; attempt <= maxAttempts; attempt++) { | ||
| try { | ||
| return query.execute(client); | ||
| } catch (IllegalStateException e) { | ||
| lastException = e; | ||
| System.err.println("Attempt " + attempt + " failed: " + e.getMessage()); | ||
| if (attempt < maxAttempts) { | ||
| System.out.println("Waiting " + (waitMillis / 1000) + " seconds before retry..."); | ||
| Thread.sleep(waitMillis); | ||
| } | ||
| } | ||
| } | ||
| throw new RuntimeException("Failed to execute FeeEstimateQuery after " + maxAttempts + " attempts", lastException); | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
These changes skip the example if we don't get the estimates. Also we don't need the try/catch blocks.
The correct approach here would be a retry mechanism or a wait time