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

Revert mint retry #85

Closed
wants to merge 1 commit into from
Closed

Revert mint retry #85

wants to merge 1 commit into from

Conversation

DylanVerstraete
Copy link
Contributor

@DylanVerstraete DylanVerstraete commented May 17, 2021

Underlying functions called in the mint function already retry on no peer err..

func (bridge *Bridge) mint(receiver ERC20Address, depositedAmount *big.Int, txID string) (err error) {
log.Info("Minting", "receiver", hex.EncodeToString(receiver[:]), "txID", txID)
// check if we already know this ID
if depositedAmount.Cmp(bridge.depositFee) <= 0 {
return errors.New("Deposited amount is <= Fee")
}
known, err := bridge.bridgeContract.IsMintTxID(txID)
if err != nil {
return
}
if known {
log.Info("Skipping known minting transaction", "txID", txID)
// we already know this withdrawal address, so ignore the transaction
return
}
amount := &big.Int{}
amount.Sub(depositedAmount, bridge.depositFee)
return bridge.bridgeContract.Mint(receiver, amount, txID)
}

check mint txid:

func (bridge *BridgeContract) IsMintTxID(txID string) (bool, error) {
res, err := bridge.isMintTxID(txID)
for IsNoPeerErr(err) {
log.Warn("no peers while trying to check mint txid, retrying...")
time.Sleep(retryDelay)
res, err = bridge.isMintTxID(txID)
}

mint:

func (bridge *BridgeContract) Mint(receiver ERC20Address, amount *big.Int, txID string) error {
err := bridge.mint(receiver, amount, txID)
for IsNoPeerErr(err) {
log.Warn("no peers while trying to mint, retrying...")
time.Sleep(retryDelay)
err = bridge.mint(receiver, amount, txID)
}

AFAIK we can only retry a mint on no peers error, other failed mint should actually be stored somewhere so we can recover some details about failed mints (if there are any)

@robvanmieghem
Copy link
Contributor

See my comment on the referenced issue

@robvanmieghem
Copy link
Contributor

3f2f2a7

@DylanVerstraete DylanVerstraete deleted the fix/mint-retry-issue branch May 17, 2021 14:07
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.

No need to retry minting everywhere if no suitable peers found
2 participants