-
Notifications
You must be signed in to change notification settings - Fork 228
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
Add gas price on initialization of Foreign erc-to-erc mode #91
Merged
+33
−16
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
38565d2
Add gas price on initialize foreign erc-to-erc
patitonar 4f30ca8
Test initialize fails if incorrect number of parameters
patitonar 205a7c3
Remove revert reason ForeignBridgeErcToErc
patitonar a4beb53
Remove revert reason ForeignBridgeErcToNative
patitonar 31de52f
Update initialize tests ForeignBridgeErcToErc
patitonar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's be consistent and return
revert
reason in allrequire
in theinitialize
method.My suggestion is to use values as numbers instead of strings since it should reduce the gas usage. You could do simple experiment in order to determine how gas consumption is reduced if a number will be used in
require(_validatorContract != address(0), "address cannot be empty");
for example. You need to consider how the gas usage differs for both the contract deployment and the method invocation). If the difference is significant let's use numbers.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 ran some tests to determine gas consumption, I deployed and call
initialize
method with the following variations on Kovan network:require(_validatorContract != address(0));
require(_validatorContract != address(0), "1");
require(_validatorContract != address(0), "address cannot be empty");
Results:
Deploy:
+ 22701
+ 1344
Initialize method failed (called with address(0) for validatorContract parameter):
+ 102
+ 0
Initialize method success:
+ 0
+ 0
From the results, it seems that avoiding using reason on
require
saves a lot of gas on deployment and very little on calling the method. Changing a full text to a number have some impact on deployment I guess depending on the string length.The other contracts doesn't use reason on
require
, except foreign erc20-to-native which was built based on this contract. Also it seems that reason string is not yet fully supported on toolings (web3/web3.js#1707) so I think that it could be a good idea to remove the reason string from these two contracts. What do you think @akolotov ?Details from the tests:
require(_validatorContract != address(0), "address cannot be empty");
Deploy
https://kovan.etherscan.io/tx/0x42cb3448e31c2a873b77869759ddc92698cf9d89004e3d989a6952eb392f9d07
Gas Used By Transaction:2530163
Success initialization
https://kovan.etherscan.io/tx/0xe9d150b24edeb3007158d1997b77f19c690ab005c2e1e97deb0638e8799e581a
Gas Used By Transaction:152124
Failed initialization with zero_address on validators
https://kovan.etherscan.io/tx/0x1edcb0d738807b049df726c00ecb53b85b6d12292f9d2c83f252489e3e845f03
Gas Used By Transaction:26487
require(_validatorContract != address(0), "1");
Deploy
https://kovan.etherscan.io/tx/0x44690aa21eca360a28b85b6bacae44e8f11a603d28859f6115d70232df461295
Gas Used By Transaction:2528819
Success initialization
https://kovan.etherscan.io/tx/0x31b57c073d60820905a6b5db1e01a6cf28106f81a57862e23349d45df0fd2057
Gas Used By Transaction:152124
Failed initialization with zero_address on validators
https://kovan.etherscan.io/tx/0x74fbff2f43ba2d5dfe3b09e4c100265a15612d7bc6c20774b5c0a798d168f167
Gas Used By Transaction:26487
require(_validatorContract != address(0));
Deploy
https://kovan.etherscan.io/tx/0xbd67b40a0fba02aeac507535c8a33b61530733d56cde4233bc09b3b2532fba63
Gas Used By Transaction:2506118
Success initialization
https://kovan.etherscan.io/tx/0x539066f85a9a8d392f61bf15142d3322d49d669ad5bf336bc3fc1060babd846e
Gas Used By Transaction:152124
Failed initialization with zero_address on validators
https://kovan.etherscan.io/tx/0xc7f62f1abdaff1362a1baf282ecdc00fdd992ccb6b19b66580bd08522ec8d38e
Gas Used By Transaction:26385
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.
Great! I vote for removing the revert reason.
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.
Done