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

Deployment initialization order is unspecified #59

Open
fulldecent opened this issue Aug 4, 2019 · 2 comments
Open

Deployment initialization order is unspecified #59

fulldecent opened this issue Aug 4, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@fulldecent
Copy link
Contributor

From https://docs.aion.network/docs/deployment-initialization

It is stated:

The <clinit> of every class submitted as part of the contract (including all the code within static {} blocks) will be run when the contract is first deployed, and never again. This makes static {} the ideal place to run any contract initialization logic.

The order of the static {} blocks should be specified.

@fulldecent fulldecent added the bug Something isn't working label Aug 4, 2019
@johnnymatthews
Copy link
Contributor

The following snippet is from /developers/fundamentals/avm-concepts/initializable-fields.md:

Data supplied in the data field must be supplied in the exact same order as the @Initializable field are defined. If not, an ABIException will be thrown.

...

The static{} function will do the following in order:

  1. Instantiate an ABIDecoder with Blockchain.getData() and try to decode an Integer and a string;
  2. Set owner as the address that deployed the contract.
  3. Execute increaseMyIntByOne() and increase the value of myInt by one.

It looks to me that this addresses this issue. I'll leave this issue open for now for further comments however.

@fulldecent
Copy link
Contributor Author

Within one contract it is clear that they are handled in the order defined.

But what is the order of the contracts?

In my test code I use

byte[] contractData = avmRule.getDappBytes(Main.class, data, AIP040Events.class, NFToken.class, NFTokenMock.class, NFTokenStorage.class, BigInteger.class);

Is that the order the the contracts are processed (and for each in the order defined in the files)? What happens if I don't have test code, is there different code that runs for deployment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants