-
Notifications
You must be signed in to change notification settings - Fork 60
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
feat(contracts): add new forwarder contracts #108
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.
Nice Work !!! :heart , Small comments
contracts/NewForwarder.sol
Outdated
// Address to which any funds sent to this contract will be forwarded | ||
address public parentAddress; | ||
address public feeAddress; | ||
mapping(address => bool) public whiteListedAddresses; |
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.
If we are not adding a function to update whiteListedAddresses with additional addresses, Do we need to add this mapping?, Just need to have a comparison in the modifier to check the address is parentAddress or feeAddress, But if using mapping uses lesser gas, Its okay
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.
Modified this and removed mapping
contracts/NewForwarder.sol
Outdated
parentAddress = _parentAddress; | ||
feeAddress = _feeAddress; |
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.
Should we add null address checks here in constructor
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.
updated
937e1d6
to
a486408
Compare
8da20d3
to
26c90ef
Compare
26c90ef
to
0923ba1
Compare
93dd8fa
to
320df67
Compare
@barathcj Can you please share your thoughts on moving these updated contracts to a new eth-multisig-v6 repo |
34660ac
to
7d0ce22
Compare
7d0391c
to
1c5a815
Compare
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.
My Questions can be little vague, just thinking of all possible negative cases
onlyAllowedAddress | ||
{ | ||
address forwarderAddress = address(this); | ||
uint256 length = tokenContractAddresses.length; |
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.
I think we should have a max length check here
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.
I think its okay not to have that, if it exceeds beyond a single transaction could handle, we should be getting a gaslimit error, Also the implementation of the token also matters when it comes to number of transactions we can do too.
address forwarderAddress = address(this); | ||
uint256 length = tokenContractAddresses.length; | ||
for (uint256 i; i < length; i++) { | ||
ERC20Interface instance = ERC20Interface(tokenContractAddresses[i]); |
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.
What happens if tokenContractAddresses[i]
is not an erc20 contract address
also incase we pass the same erc20 contract address twice, I think forwarderBalance check will go through for both cases
In this case, do we see partial failures or the whole tx fails?
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.
If we pass the same token address multiple times, then it doesn't seem to be causing any failures or something, it just seem to be performing the tx once. https://sepolia.arbiscan.io/tx/0x82a819eed6b4ee0b87d40893bd92faf99db2f731074d1f65c548966e1a62face
Also if the token address passed is not an erc20 contract address, then it seems to be erroring during the gas estimate itself, so shouldn't be an issue of partial or whole tx failure
/** | ||
* @inheritdoc IForwarderV4 | ||
*/ | ||
function batchFlushERC20Tokens(address[] calldata tokenContractAddresses) |
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.
Can you set some context on how are we doing to use this function from application side
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 should be able to batch token flushes together, should help in better gas savings.
contracts/ForwarderV4.sol
Outdated
address target, | ||
uint256 value, | ||
bytes calldata data | ||
) external onlyAllowedAddress returns (bytes memory) { |
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.
wondering do we have to allow feeAddress
here as well ?
cause using feeAddr we can move funds to any address
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.
I think that's a valid point. Bitgo on its own shouldn't be able to move any funds. This function should only be used in exceptional cases any ways
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.
updated this, now only parent address will be able to call this method
) external onlyUninitialized { | ||
require(_parentAddress != address(0x0), 'Invalid parent address'); | ||
parentAddress = _parentAddress; | ||
require(_feeAddress != address(0x0), 'Invalid fee address'); |
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.
should we add feeAddr != parentAddr?
maybe we would be over doing it
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.
I think probably no need for this
e0bbd8c
to
31edb46
Compare
fdd3ff4
to
b8abd6d
Compare
/// @notice Address which is allowed to call methods on this contract alongwith the parentAddress | ||
address public feeAddress; | ||
bool public autoFlush721 = true; | ||
bool public autoFlush1155 = true; |
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.
ok thanks for the comparison. It is weird that arbitrum gas is twice than of optimism. Anyway, not a blocker but something to keep in mind in the future
For this comment, #108 (comment) actually arbitrum gas vary drastically probably because there is this L1 part of the gas which depend on the base fees of the Eth network |
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.
Nice Work!!!
This PR adds 3 contracts ForwarderV4.sol, ForwarderFactoryV4.sol and IForwarderV4.sol
Change in contracts (as compared to Forwarder.sol and ForwarderFactory.sol) is that we have added feeAddress as an address that will be one of the allowed addresses to call the methods of the contract along with parentAddress. This means the methods to flush the tokens, etc can be called using the gas tank address. Apart from this batchFlushERC20Tokens method to batch flush erc20 tokens has been added to the ForwarderV4 contract
WIN-506