-
Notifications
You must be signed in to change notification settings - Fork 209
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
Refactoring #113
Refactoring #113
Conversation
shahafn
commented
May 21, 2019
- Changing snake to camel case
- Adding version to hub
- Changing canRelay ret val from uint32 to uint
contracts/RelayHubApi.sol
Outdated
@@ -1,6 +1,6 @@ | |||
pragma solidity >=0.4.0 <0.6.0; | |||
|
|||
contract RelayHubApi { | |||
contract RelayHubApi { |
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.
better use the interface notation IRelayHub
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.
This one was done in a previous pull request...
It was called RelayHubApi to be consistent with RelayRecipientApi. I can rename them but not sure it if it matters
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
contracts/RelayHubApi.sol
Outdated
function relay(address from, address to, bytes memory encoded_function, uint transaction_fee, uint gas_price, uint gas_limit, uint nonce, bytes memory approval) public; | ||
function getNonce(address from) view external returns (uint); | ||
|
||
function relay(address from, address to, bytes memory encodedFunction, uint transactionFee, uint gasPrice, uint gasLimit, uint nonce, bytes memory approval) public; |
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 be renamed relayCall
- its better to have experssive method names, with object-subject
- we use the terminology of acceptRelayedCall, postRelayedCall, so it makes sense to use Call here too.
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
@@ -34,6 +34,9 @@ for f in $folders ; do test -d $f && FOLDERS+=" -v $f:$f"; done | |||
FOLDERS+=" -v `pwd`/build/dock-builD:`pwd`/build" | |||
FOLDERS+=" -v `pwd`/build/dock-node_modules:`pwd`/node_modules" | |||
mkdir -p build/dock-builD | |||
mkdir -p build/dock-node_modules |
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 are these for?
In any case, you have to do ./dock/run.sh npm install
to get all required modules. This copies only few. We could copy a lot of modules (just to save time for npm install) - but must skip all those with native code.
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 only need them for openzeppelin & @0x deps we have in the contracts currently
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.
no. if you want to do test or whatever inside the dock, you need other modules too. don't start copy partial modules around..
we must do ./dock/run.sh npm install
.
(the mkdir
you added above IS required, but the cp
below are not)
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.
./dock/run.sh npm install
doesn't work. It probably needs to be run as root but I'm not going to run it with sudo.
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.
it does work, but only if the dock-node_modules folder exists before (the docker uses existing folder, but if it doesn't exists, it creates one as root, which breaks the scripts.
that's why I said the mkdir is required, but the rest isn't.
I just did such "docker/run npm install" on a clean environment .
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
server/src/RelayHttpServer.go
Outdated
@@ -19,7 +19,7 @@ import ( | |||
"time" | |||
) | |||
|
|||
const VERSION = "0.3.5" | |||
const VERSION = "0.3.6" |
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 more than a minor change - its a clear API change.
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.
This one is the the server version, no API change in 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.
done
server/src/librelay/relay_server.go
Outdated
maxCharge := request.GasPrice.Uint64() * gasEstimate * (100 + relay.GasPricePercent.Uint64()) / 100 | ||
if toBalance.Uint64() < maxCharge { | ||
err = fmt.Errorf("Recipient balance too low: %d, gasEstimate*fee: %d", toBalance, maxCharge) | ||
log.Println(err) | ||
return | ||
} | ||
log.Println("Estimated max charge of relyed tx:",maxCharge) |
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.
relayed, not relyed
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
Yes, I meant renaming them both.
…On Wed, May 22, 2019, 06:29 shahafn ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In contracts/RelayHubApi.sol
<#113 (comment)>
:
> @@ -1,6 +1,6 @@
pragma solidity >=0.4.0 <0.6.0;
-contract RelayHubApi {
+contract RelayHubApi {
This one was done in a previous pull request...
It was called RelayHubApi to be consistent with RelayRecipientApi. I can
rename them but not sure it if it matters
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#113>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJTY4D4WOX7UYPTV5UARQDLPWSAWXANCNFSM4HOM563A>
.
|
contracts/RelayHub.sol
Outdated
@@ -16,7 +16,7 @@ contract RelayHub is IRelayHub { | |||
uint constant minimumRelayBalance = 0.5 ether; // XXX TBD - can't register/refresh below this amount. | |||
uint constant public gasReserve = 99999; // XXX TBD - calculate how much reserve we actually need, to complete the post-call part of relayCall(). | |||
uint constant public gasOverhead = 47445; // the total gas overhead of relayCall(), before the first gasleft() and after the last gasleft(). Assume that relay has non-zero balance (costs 15'000 more otherwise). |
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.
- Don't leave such long line comment. Split them to be readable.
- Do we need gasReserve? It's still XXX
@@ -34,6 +34,9 @@ for f in $folders ; do test -d $f && FOLDERS+=" -v $f:$f"; done | |||
FOLDERS+=" -v `pwd`/build/dock-builD:`pwd`/build" | |||
FOLDERS+=" -v `pwd`/build/dock-node_modules:`pwd`/node_modules" | |||
mkdir -p build/dock-builD | |||
mkdir -p build/dock-node_modules |
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.
no. if you want to do test or whatever inside the dock, you need other modules too. don't start copy partial modules around..
we must do ./dock/run.sh npm install
.
(the mkdir
you added above IS required, but the cp
below are not)
contracts/RelayRecipient.sol
Outdated
* @param gasPrice - the gas price for this transaction | ||
* @param transactionFee - the relay compensation (in %) for this transaction | ||
*/ | ||
function acceptRelayedCall(address relay, address from, bytes memory encodedFunction, uint gasPrice, uint transactionFee, bytes memory approval) public view returns(uint); |
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.
fix indent, newline after method (I almost commented that its a comment for the wrong method
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
1d41425
to
049cc31
Compare