Skip to content

Withdrawals (smart contract part)#25

Merged
dapplion merged 22 commits intodevelopfrom
ib-withdrawal-contract-part
Mar 22, 2023
Merged

Withdrawals (smart contract part)#25
dapplion merged 22 commits intodevelopfrom
ib-withdrawal-contract-part

Conversation

@Barichek
Copy link
Contributor

@Barichek Barichek commented Feb 14, 2023

Enable withdrawals on Gnosis chain, conforming to spec https://github.com/gnosischain/specs/blob/master/execution/withdrawals.md

  • Uses deposited GNO principal + expected top-up rewards balance to fund withdrawals on demand.
  • If a withdrawal fails, it is persisted on storage for latter retry
  • mGNO is dropped for GNO as the canonical token to deposit. Deposit contract emits the deposited amount by 32 to beacon chain, and divides withdrawn amount by 32. Admin should call unwrapTokens once to unwrap all deposited mGNO prior to the upgrade

*/
function executeSystemWithdrawals(uint64[] calldata _amounts, address[] calldata _addresses) external {
require(
_msgSender() == SYSTEM_WITHDRAWAL_EXECUTOR || _msgSender() == _admin(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why also allow for _admin address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is more for test purposes. I mean anyway the admin have rights to do everything with this contract, but this way we have the opportunity to conveniently test this contract.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has the function name defined in the spec been changed permanently?

Copy link
Contributor Author

@Barichek Barichek Feb 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I just used more declarative name. For sure we can change it if it is required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Barichek I like this better as I prefer the function name to be a verb. So, either this one or just withdraw. And since this function is called from the execution client, I need to know what name to use. If we stick with this one, the spec needs to be updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update the spec with executeSystemWithdrawals. While admin can do anything, having it allowed here explicitly is a bit unclean. Can you find another approach to become the system executor on testing?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me help

@dapplion dapplion mentioned this pull request Feb 24, 2023
@dapplion dapplion force-pushed the ib-withdrawal-contract-part branch from dacd43c to f2eb640 Compare February 25, 2023 00:09
@dapplion dapplion mentioned this pull request Feb 25, 2023
@dapplion
Copy link
Member

* @param _amounts Array of amounts to be withdrawn.
* @param _addresses Array of addresses that should receive the corresponding amount of tokens.
*/
function executeSystemWithdrawals(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An idea to consider. If we would change this function to return a boolean flag indicating whether withdrawals were succeeded or not, an execution client could log a warning hinting to check the contract for details. This could improve the user experience a little at the cost of a slight gas usage increase because of the flag handling. Not entirely sure though whether it's worth that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure of its value either, won't be opposed to it. It's not actionable info for a user, same way failed txs from the network are not logged.

@atifnimran
Copy link

Okay

filoozom and others added 2 commits March 22, 2023 21:56
* wip: remove mGNO

* test: fix remaining tests

* chore: update error message

* feat: add `unwrapTokens` function

* wip: upgradeToAndCall

* chore: remove package-lock and reset yarn.lock

* Add division on withdraw

---------

Co-authored-by: dapplion <35266934+dapplion@users.noreply.github.com>
Copy link
Member

@dapplion dapplion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dapplion dapplion merged commit b6f6531 into develop Mar 22, 2023
@dapplion dapplion deleted the ib-withdrawal-contract-part branch March 30, 2023 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants