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

Disputables: Avoid calling close action if closed #594

Closed
wants to merge 2 commits into from

Conversation

facuspagnuolo
Copy link
Contributor

@facuspagnuolo facuspagnuolo commented Jul 15, 2020

Related to aragon/aragon-apps#1214

This PR adds an improvement to avoid calling IAgreement#closeAction from the internal helper method of DisputableAragonApp if the requested action is already closed.

Copy link
Contributor

@bingen bingen left a comment

Choose a reason for hiding this comment

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

LGTM

@facuspagnuolo facuspagnuolo self-assigned this Jul 17, 2020
@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 98.876% when pulling 68f2eac on avoid_calling_close_action_innecessary into 841915f on next.

Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

Couple of quick comments, main one being sure that this is actually an optimization!

it('does not revert', async () => {
await disputable.newAction(0, '0x00', owner)
it('submits a new action', async () => {
const { receipt } = await disputable.newAction(0, '0x00', owner)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like some opportunities to use the EMPTY_BYTES :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remember we don't have the helpers here yet haha, but I'll extract this to a constant so we don't miss it :)


const logs = decodeEventsOfType(receipt, AgreementMock.abi, 'NewAction')
assertAmountOfEvents({ logs }, 'NewAction')
assertEvent({ logs }, 'NewAction', { disputableActionId: 0, context: '0x00', submitter: owner })
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick, but we could use embed use the decodeAbiFor option now :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't have the helpers here yet haha

(,,,,, bool closed,,) = agreement.getAction(_actionId);

if (!closed) {
agreement.closeAction(_actionId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not opposed to it, but I think we should do a small trial run to see how much the gas difference actually is, if this is just an optimization.

The extra call to agreement.getAction() may remove the large part of the savings if closeAction() is fairly simple on already-closed actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea! I tested this and it is not an optimizing it actually, I'll roll it back

@facuspagnuolo facuspagnuolo deleted the avoid_calling_close_action_innecessary branch July 24, 2020 18:18
@facuspagnuolo
Copy link
Contributor Author

Closing in favor of aragon/aragon-apps#1231

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.

None yet

4 participants