Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

combine vote and execute, modify the test files based on the change #389

Merged
merged 4 commits into from
Sep 17, 2021

Conversation

andersonlee725
Copy link
Contributor

@andersonlee725 andersonlee725 commented Sep 15, 2021

Description

Combine vote and execute.

During voting, if the proposal status is changed to Passed, then automatically executes the proposal.
In this case, even though the execute is reverted, the whole transaction is not reverted.
If the execute is reverted, the proposal status still stays on Passed.
And if the proposal status was in Passed, then automatically executes the Proposal without any _expiry checking.
But in this case, if the execute is reverted, the whole transaction is reverted.
For above functionality, executeProposal function accepts a new parameter(bool revertOnFail).

Related Issue Or Context

Closes: #255

How Has This Been Tested? Testing details.

First, added a test contract that reverts in its executeProposal function.

Checked

  • During the vote, if the proposal status is changed to Passed and execute is reverted, status still should be Passed not Active.
  • During the vote, if the proposal status was in Passed and execute is reverted, status still should be Passed not Executed.
  • During the vote, if the proposal status is changed to Passed and execute is not reverted, status should be Executed.
  • During the vote, if the proposal status was in Passed and execute is not reverted, status should be Executed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Checklist:

  • I have commented my code, particularly in hard-to-understand areas.
  • I have ensured that all acceptance criteria (or expected behavior) from issue are met
  • I have updated the documentation locally and in chainbridge-docs.
  • I have added tests to cover my changes.
  • I have ensured that all the checks are passing and green, I've signed the CLA bot

Copy link
Contributor

@lastperson lastperson left a comment

Choose a reason for hiding this comment

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

Additional tests that would help:

  1. Check that vote on a Passed proposal (with failed execution) does not modify anything in the proposal. Votes, status, etc. should stay unchanged.
  2. Check that vote on a Passed proposal triggers execution and it is successful.
  3. Check that vote on a Passed proposal triggers execution and it is reverted.
  4. Check that different kinds of fails in execution are caught.

contracts/Bridge.sol Show resolved Hide resolved
contracts/Bridge.sol Outdated Show resolved Hide resolved
contracts/Bridge.sol Outdated Show resolved Hide resolved
contracts/Bridge.sol Show resolved Hide resolved
test/contractBridge/executeWithFailedHandler.js Outdated Show resolved Hide resolved
test/contractBridge/executeWithFailedHandler.js Outdated Show resolved Hide resolved
test/contractBridge/voteDepositProposal.js Outdated Show resolved Hide resolved
Copy link
Contributor

@lastperson lastperson left a comment

Choose a reason for hiding this comment

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

Check that vote on a Passed proposal triggers execution and it is successful.

This case is not covered it seems.

  1. Vote 1
  2. Vote 2 -> Passed -> Execution reverted
  3. Vote 3 -> Execution succeeds.

contracts/Bridge.sol Show resolved Hide resolved
test/contractBridge/executeWithFailedHandler.js Outdated Show resolved Hide resolved
test/contractBridge/executeWithFailedHandler.js Outdated Show resolved Hide resolved
test/contractBridge/voteDepositProposal.js Outdated Show resolved Hide resolved
contracts/Bridge.sol Outdated Show resolved Hide resolved
@lastperson lastperson merged commit 6f92da4 into develop Sep 17, 2021
@lastperson lastperson deleted the anderson/combine-vote-and-execute branch September 17, 2021 17:30
P1sar added a commit that referenced this pull request Oct 27, 2021
* Anderson/remove deposit record (#382)

* remove DepositRecord in every handler,  modify event in Bridge, modify IDepositExecute interface
* modify test files based on removing deposit records
* add handlerResponse to deposit event and modify test files based on the event

* Rename chainID to domainID (#384)

* Add admin set deposit nonce (#385)

* Сombine vote and execute [Breaking] (#389)

* Remove resources from handler constructors (#393)

* Update dependencies and bump version (#394)

Set disableConfirmationListener: true to avoid spamming ganache during tests. trufflesuite/truffle#3522

* Remove fund functions (#412)

Co-authored-by: andersonlee725 <86676141+andersonlee725@users.noreply.github.com>
Co-authored-by: Oleksii Matiiasevych <oleksii@chainsafe.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants