aionnetwork / AVM

Enabling Java code to run in a blockchain environment
https://theoan.com/
MIT License
49 stars 25 forks source link

Assertion failure during contract deployment #411

Open fulldecent opened 5 years ago

fulldecent commented 5 years ago

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

jennijuju commented 5 years ago

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.

fulldecent commented 5 years ago

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.