echidna icon indicating copy to clipboard operation
echidna copied to clipboard

Deploying many large interacting contracts

Open elizabethdinella opened this issue 3 years ago • 8 comments

I am trying to write tests for the AvvenireAuction contract.

AvvenireAuction interacts with an externally deployed contract AvvenireCitizens.

AvvenireCitizens interacts with 2 externally deployed byte code contracts.

To deploy the bytecode contracts, I paste the bytecodes in my config using deployBytecodes at the addresses 0x9559067eBb005c002EAd3CD0e09D97C39177ba34 and 0x8F4d063621DDE21d17129c68174a90A67aFC74Fa.

When I execute the constructor below, echidna hangs indefinitely.

constructor() {
        address dataContractAddress = 0x9559067eBb005c002EAd3CD0e09D97C39177ba34;

        citizens = new AvvenireCitizens("AvvenireCitizens", "AVC", "https://av.mypinata.cloud/ipfs/QmYwCridML3Qo3vGSR2QrCs2rvofrTcyL2hd1z9AXqSduN/", 
                                       "",  dataContractAddress, 0x8F4d063621DDE21d17129c68174a90A67aFC74Fa);

        auction = new AvvenireAuction(2, 5000, 1000, 100, address(citizens));
    }

Alternatively, I explored deploying AvvenireCitizens using the deployContracts flag. However, AvvenireCitizens takes constructor arguments. How can I specify those in the config?

elizabethdinella avatar Jun 03 '22 17:06 elizabethdinella

I'm trying to reproduce this issue, I haven't finish yet, but it seems that using codeSize: 0xffffffffff in the config file allow me deploy AvvenireCitizens, but I'm still working on the other ones.

gustavo-grieco avatar Jun 03 '22 19:06 gustavo-grieco

Hi, just checking, is there any update on this?

elizabethdinella avatar Jun 13 '22 20:06 elizabethdinella

I will have some time to finish investigating this next week. Sorry for the delay! :slightly_smiling_face:

gustavo-grieco avatar Jun 22 '22 13:06 gustavo-grieco

It seems that at least one of the contracts, the one deployed at 0x9559067eBb005c002EAd3CD0e09D97C39177ba34 fails when redeployed inside Echidna using its bytecode.

echidna-test: Deploying the contract 0x9559067eBb005c002EAd3CD0e09D97C39177ba34 failed (revert, out-of-gas, sending ether to an non-payable constructor, etc.)

without source code or more information about this contract, it is impossible to debug, I'm afraid.

gustavo-grieco avatar Jun 28 '22 13:06 gustavo-grieco

Same with the other one at 0x8F4d063621DDE21d17129c68174a90A67aFC74Fa.

gustavo-grieco avatar Jun 28 '22 13:06 gustavo-grieco

Ah okay, so there is some require failing in the byte code? (Rather than something wrong with the way I am deploying the byte code)

elizabethdinella avatar Jun 28 '22 17:06 elizabethdinella

Yes, something inside that CREATE transactions is reverting. It could be a timestamp requirement, a lack of balance or an external call or something else :thinking:

gustavo-grieco avatar Jun 28 '22 17:06 gustavo-grieco

Great, I had a suspicion this was the case. How did you figure this out? I was having trouble since the error message was vague.

echidna-test: Deploying the contract 0x9559067eBb005c002EAd3CD0e09D97C39177ba34 failed (revert, out-of-gas, sending ether to an non-payable constructor, etc.)

elizabethdinella avatar Jun 28 '22 17:06 elizabethdinella

Also getting this on deploying a large contract system with echidna, is there any way to increase the gas limits?

echidna-test: Deploying the contract 0x00a329c0648769A73afAc7F9381E08FB43dBEA72 failed (revert, out-of-gas, sending ether to an non-payable constructor, etc.)

Im trying to deploy many large contracts from inside the constructor of my echidna test, however since it's run locally there should be some way to just have it ignore gas limits/ increase the block gas limit right?

I've confirmed this comes from gas cost in the constructor with an arbitrarily large for loop of an operation that executes successfully.

brucdarc avatar Dec 14 '22 09:12 brucdarc

If the contract is very large, you should using codeSize: 0xffffffffff. Otherwise, perhaps reverts for another reason. Please try #871

gustavo-grieco avatar Dec 14 '22 11:12 gustavo-grieco

Please try #871

How?

Silur avatar Feb 08 '23 00:02 Silur

Please try #871

How?

the change in #871 has been merged, if you install the latest echidna version (2.0.5) it should be included in it 👍

elopez avatar Feb 08 '23 04:02 elopez

okay but there's no documentation on how to enable this feature, and I didn't manage to dig it out from the haskell code :)

I'm using 2.0.5 inside docker but still lacking revert reasons on deployment fails so I guess this is an opt-in flag

Silur avatar Feb 08 '23 09:02 Silur

Luckily, there is no need to enable anything. You should see the revert reason when the deployment fails. If there is no revert reason, then your reverts do not contain reason strings (e.g. revert(false), instead of revert(false, "reason));

gustavo-grieco avatar Feb 08 '23 10:02 gustavo-grieco

@elizabethdinella can you try using the state network forking feature from 2.1.0?

gustavo-grieco avatar Mar 12 '23 11:03 gustavo-grieco

Closing this one, please reopen if something is wrong.

gustavo-grieco avatar Sep 01 '23 16:09 gustavo-grieco