AVM icon indicating copy to clipboard operation
AVM copied to clipboard

Assertion failure during contract deployment

Open fulldecent opened this issue 6 years ago • 2 comments

Test case:

  1. Clone https://github.com/fulldecent/aion-aip040
  2. Checkout 0xa0beeb017dd82747692965c3ca7b6f1a2a3c1b777d4472ce54174e224ca61962
  3. Initialize
  4. ./mvnw clean install

Expected

AVM never has an assertion failure no matter what customers of AVM do

Actual

AVM has an assertion error

fulldecent avatar Aug 16 '19 21:08 fulldecent

You are only seeing this because you are running test cases using avmrule with debug mode on, which can show the exact error in the AVM that causes a failure a transaction. That being said, you are only seeing the assertion error because your test cases are running using AVM(avm.jar) directly. This is a privilege Java gives us for smart contract development. With our avmrule (debugging tooling), it allows users to test and debug their contracts using JUnit tests. User can use breakpoints to find the exact lines in their contracts that are wrong. In addition, with debug mode, users can understand the issue more and find a way to fix it faster.

If you deploy the contract to the real network, your transaction will JUST be rejected and you will only notice a transaction failure.

jennijuju avatar Aug 19 '19 15:08 jennijuju

I understand what you are saying, but I don't see how it applies here.

In programming, every assert() call should include the name and cell phone number of the programmer who put it there. In the event that assert(false) is called, the programmer gets called, woken up, and they fix it so that assert(false) never happens.

If assert here is being used as a way to point user to an explanation of on error the user made then I recommend an exception, error or other mechanism.

fulldecent avatar Aug 20 '19 01:08 fulldecent