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

Replace custom external call with native solidity .call #204

Merged

Conversation

tedwu13
Copy link
Contributor

@tedwu13 tedwu13 commented Feb 19, 2021

Overview

Replacing custom externalCall function with the native solidity .call. With older versions of solidity (0.4.24) inline assembly is used to make external function calls. Now solidity supports external function calls. Removing the externalCall function because it is not being used in the repo. Let me know if I should keep the externalCall function.

Based on the documentation, .call returns a boolean and bytes of memory.
<address>.call(bytes memory) returns (bool, bytes memory)

Changes

  • Replace externalCall with .call
  • Remove externalCall function since it is not being used anywhere

Reviewers

@nithinkrishna

@@ -47,7 +47,7 @@ contract Orchestrator is Ownable {
for (uint256 i = 0; i < transactions.length; i++) {
Transaction storage t = transactions[i];
if (t.enabled) {
bool result = externalCall(t.destination, t.data);
(bool result, bytes memory reason) = t.destination.call(t.data);
if (!result) {
emit TransactionFailed(t.destination, i, t.data);
Copy link
Member

@aalavandhan aalavandhan Feb 19, 2021

Choose a reason for hiding this comment

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

With the new flow, if one of the transactions reverts rebase reverts.

The TransactionFailed log message will not be emitted when transaction reverts, it can be removed.

https://github.com/ampleforth/uFragments/pull/204/files#diff-f13d714954d0cdb635fb60fc06f19ce891c26582cd08f6298ebd3071096d657fL19

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I remove the log message, should I also remove the TransactionFailed event or do we listen to that event anywhere else? https://github.com/ampleforth/uFragments/blob/07e229b2c3dd23b1b55ed871207196179fdfb5e6/contracts/Orchestrator.sol#L19

Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove it. The contract doesn't really use it so there's not need for it.

Services do listen to this, however the next orchestrator version will be a fresh contract deployment so it shouldn't break anything :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

awesome will remove it.

@@ -47,7 +47,7 @@ contract Orchestrator is Ownable {
for (uint256 i = 0; i < transactions.length; i++) {
Transaction storage t = transactions[i];
if (t.enabled) {
bool result = externalCall(t.destination, t.data);
(bool result, bytes memory reason) = t.destination.call(t.data);
Copy link
Member

Choose a reason for hiding this comment

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

Seems like we're not using reason, so maybe not reference it?

 (bool result, ) = t.destination.call(t.data);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah good call I'll remove it

@aalavandhan
Copy link
Member

@tedwu13 looks mostly good. Left a couple of comments 👍

@aalavandhan aalavandhan linked an issue Feb 19, 2021 that may be closed by this pull request
6 tasks
@tedwu13 tedwu13 requested a review from aalavandhan February 19, 2021 19:37
@@ -3,26 +3,26 @@ import { HardhatUserConfig } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
import '@openzeppelin/hardhat-upgrades'
import "@nomiclabs/hardhat-etherscan";
Copy link
Member

@aalavandhan aalavandhan Feb 19, 2021

Choose a reason for hiding this comment

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

Hmm. Can you leave the changes in this file out to keep the diff clean?
Seems like they've been added by the linter

@tedwu13 tedwu13 force-pushed the tedwu-change-external-call-to-call branch from d7a03bf to 8d1e556 Compare February 19, 2021 19:52
Copy link
Member

@aalavandhan aalavandhan left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

@aalavandhan aalavandhan merged commit 213cfb7 into ampleforth:master Feb 19, 2021
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.

Orchestrator V2
2 participants