Skip to content

automint does not leave room for the mint fee - #1093

Open
whiskyrelaxing wants to merge 1 commit into
Veil-Project:masterfrom
whiskyrelaxing:automint-mint-fee
Open

whiskyrelaxing wants to merge 1 commit into
Veil-Project:masterfrom
whiskyrelaxing:automint-mint-fee

Conversation

@whiskyrelaxing

Copy link
Copy Markdown

Every mint costs its denomination plus Zerocoin_MintFee(), and both come out of
the same balance. automint only ever sizes against the denomination, so when the
scaling fills the balance there is nothing left for the fee and the mint is
refused.

The check at wallet.cpp:5233 runs before the scaling, so it tests one
denomination's worth:

if (nSelectedCoinBalance < nMintAmount * COIN) { ... return; }
...
int div = nSelectedCoinBalance / (nMintAmount * COIN);

div multiplies nMintAmount up to fill the balance, nothing checks again, and
MintZerocoin then wants nValue + Zerocoin_MintFee() and refuses at
wallet.cpp:6105.

So it fails whenever the mintable balance is an exact multiple of the
denomination, for any denomination, up to nine times it. At ten times and above
the div > 9 clamp happens to leave the fee behind, which is the only reason this
is not constant.

While it is failing it retries on every block rather than every five minutes,
because the retry delay is only reset in the success branch at wallet.cpp:5282,
so nWaitTime keeps growing and AUTOMINT_DELAY stops holding it back:

AutoZeromint: auto minting failed with error: Insufficient Basecoin Funds
AutoZeromint: auto minting failed with error: Insufficient Basecoin Funds
AutoZeromint: auto minting failed with error: Insufficient Basecoin Funds

Two changes. The sizing uses the cost of one mint including its fee, for the
check and the scaling. And a failed mint resets the delay, which is worth having
on its own since it applies to any failure, not just this one.

@ohcee ohcee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

utACK 459fe70

Math checks out, the fee is per mint (consensus enforces nFees == nMints * Zerocoin_MintFee()), so denom + fee is the real cost of one mint and the batch always fits. The delay reset on failure is worth having on its own.

One suggestion: the two "less than the selected denomination plus its fee" returns still retry every block, give them the same nAutoMintStartupTime reset to finish the de-spam.

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