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

Do not model an insufficient bid with cvm.error #18

Open
symbiont-eric-torreborre opened this issue Aug 23, 2022 · 0 comments
Open

Do not model an insufficient bid with cvm.error #18

symbiont-eric-torreborre opened this issue Aug 23, 2022 · 0 comments

Comments

@symbiont-eric-torreborre

I think we should leave cvm.error to real errors where a contract don't know how to make further progress. For example here:

@executable
def _bid(id: Identifier, amount: int) -> Optional[Bid]:
    row = get_auction(id)
    if isinstance(row, None):
        cvm.error(f"You don't have access to this auction.")

However when someone places a bid with an insufficient amount:

if amount <= last_bid.amount:
        cvm.error(f"The bid amount must be larger than current bid amount ${last_bid.amount}.")

This is expected behaviour and we should return a job complete result indicating that the bid was insufficient.

The downside of using cvm.error everywhere is that we end-up creating job fail events which are indistinguishable from job fail events due to a channel which cannot be rotated (because the key alias is not the owner anymore), a temporary failure to post a transaction to Smartlog or a bug on the platform.

Maybe one way forward is to make a stronger distinction in the language between failures and errors where

  • failures are non-"happy path" conditions but totally expected flows
  • errors are the equivalent of asserts in other programming languages
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

No branches or pull requests

1 participant