pendulum-chain / wasm-deploy

A tool to deploy an ensemble of wasm smart contracts to Pendulum
GNU General Public License v3.0
2 stars 1 forks source link

Ensure that Nabla can be deployed on Pendulum #45

Closed TorstenStueber closed 5 months ago

TorstenStueber commented 6 months ago

When deploying Nabla to Foucoco with the current deployment definition on branch 39-implement-tests-for-nabla-indexer, then the fifth phase of the deployment scripts 06_deploy_swap_pools.ts will not work as expected and some method calls will revert.

How to reproduce

Alternative way to reproduce

Since the script runs very slowly, it is very time consuming to reproduce this call as it is occurs late in the deployment. In order to directly execute the call, you can instead use this gist, which refers to an already existing partial deployment of Nabla, and:

The result will be

Result {
  execution: { type: 'onlyQuery' },
  result: { type: 'error', error: 'unknown' }
}

This means that the RPC call that is executed before the actual submission of the transaction (that is used as a dry run to determine gas fees) already fails. Closer inspection shows that the RPC returns with the following values:

That means that the contract reverts without any further information.

Context

This problem did not exist with the previous version of Nabla, which used commit 3e96787e161fb2657c90f18034691749647b691f of https://github.com/0xamberhq/contracts.

It started to occur with the new necessary changes I added to Nabla that are now on branch pendulum-launch.

All test have been adapted to that branch and run successfully. For that reason I assume that there is no inherent problem with that branch.

Further assumptions

Looking at the definition of registerPool in the router contract, there are only a few places where the contract can revert:

prayagd commented 5 months ago

Hey team! Please add your planning poker estimate with Zenhub @b-yap @bogdanS98 @ebma @gianfra-t @TorstenStueber

gianfra-t commented 5 months ago

I will leave as a record the cause and solution found for this bug.

The issue was caused by the changes introduced in this PR where the chain extensions definitions were refactored into using a tuple of chain extensions (one for Tokens, one for Prices).

With this new changes, the way in which the id of the chain extension is called is also modified. Previously only the function identifier (defined here) was enough to specify which chain extension method to call.

When using tuples, we also need to reference the ID of the chain extension element of the tuple (defined here). This is done by concatenating the id as the 2 most significant bytes of the u32. The two less significant will be used to match the function of the specified extension.

Therefore in order to call function id 1100 of extension with ID 1 we need shift the ID 2 bytes and add it to the function id. In this example, it would be 66636.

Ultimately, the failure to call the proper approve extension by the ERC20Wrapper resulted in the unknown error seen.

TorstenStueber commented 5 months ago

To add to this comment: the problem has been resolved through this PR: https://github.com/pendulum-chain/pendulum-solidity-wrapper/issues/42.

We can close this ticket now.