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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
:)
There was a problem hiding this comment.
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 }) |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Closing in favor of aragon/aragon-apps#1231 |
Related to aragon/aragon-apps#1214
This PR adds an improvement to avoid calling
IAgreement#closeAction
from the internal helper method ofDisputableAragonApp
if the requested action is already closed.