Skip to content
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

feat: improving masp transactions feedback for users and other gas estimation fixes #1594

Merged
merged 6 commits into from
Feb 3, 2025

Conversation

pedrorezende
Copy link
Collaborator

@pedrorezende pedrorezende commented Jan 31, 2025

This PR refactors all the transactions logic separating the build step from the signing step. With this we will be able to improve user experience while waiting for long steps, like the generation of masp params. I've only implemented multiple status on Shielding because we're going to change a few things on the UI in the next PRs.

It also creates a quick workaround to increase gas fees while we improve the indexer api for estimate. The reason behind it is that many transactions were frequently failing because of gas (ex: unstake, re-delegate, etc)

@pedrorezende pedrorezende requested review from euharrison, jurevans and mateuszjasiuk and removed request for euharrison and jurevans January 31, 2025 05:44
Copy link
Collaborator

@euharrison euharrison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool! Nice!

Left a few comments, but my main concern is the notifications. But it's also ok if we address this in a new PR

@@ -154,6 +155,7 @@ export const MaspShield: React.FC = () => {
isSubmitting={isPerformingTransfer}
errorMessage={generalErrorMessage}
onSubmitTransfer={onSubmitTransfer}
submittingText={isPerformingTransfer ? currentStep : "Shield"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could talk with Chris later to improve this change visually, maybe with animations 🌟

const [displayAmount, setDisplayAmount] = useState<BigNumber | undefined>();
const [generalErrorMessage, setGeneralErrorMessage] = useState("");

const [currentStep, setCurrentStep] = useState("");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you apply this on MaspUnshield and NamadaTransfer as well? Or is this part of a future PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! This is going to be part of a PR I'm working now. We're going to change the whole interface after submitting the transaction, that's why I didn't apply this change to other pages

@@ -80,10 +80,6 @@ const IncrementBonding = (): JSX.Element => {
</>
),
}),
parseErrorTxNotification: () => ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove this, the notification failed doesn't appear. I tested this trying to stake with a custom small amoutn of gas (0.01 NAM) and you can observe the notification there forever

Screenshot 2025-01-31 at 14 06 47

// the minimum gas limit ever used for a TX, and avg is failing in most of the transactions.
// So we estabilish the average value between gasEstimate.avg and gasEstimate.max as the min value.
// The other values derive from this one.
const newMin = Math.ceil((gasEstimate.avg + gasEstimate.max) / 2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the reason, but I'm afraid of this math creates an infinite loop of gas growing infinitely. We need to discuss this with other folks, but I'm good for now on campfire

For me, this endpoint should be the return value of a dry-run, then we apply a const like the 1.25 and 1.5 you did

Copy link
Collaborator Author

@pedrorezende pedrorezende Feb 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't dry run because we would need to sign. I've talked to @Fraccaman about this, and this was the best shot we have for now. Don't think it will change gas on indexer infinitely, since it will be a security issue. I think indexer takes in consideration the gas effectively used, not the amount users define

if (!publicKeyRevealed) {
const revealPkTx = await tx.buildRevealPk(wrapperTxProps);
txs.push(revealPkTx);
if (!skipRevealPk) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to avoid "not-not", how about renaming this to revealPk?: boolean = true and if (revealPk)?

| UseTransactionOutput<TransparentTransferMsgValue>
| UseTransactionOutput<ShieldedTransferMsgValue>
| UseTransactionOutput<ShieldingTransferMsgValue>
| UseTransactionOutput<UnshieldingTransferMsgValue>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops, thanks!

@pedrorezende pedrorezende force-pushed the feat/multiple-masp-stages branch from d576050 to 682b25b Compare February 3, 2025 16:33
@pedrorezende pedrorezende merged commit 426dbd3 into main Feb 3, 2025
7 checks passed
@pedrorezende pedrorezende deleted the feat/multiple-masp-stages branch February 3, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants