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

Refactoring #113

Merged
merged 14 commits into from
May 23, 2019
Merged

Refactoring #113

merged 14 commits into from
May 23, 2019

Conversation

shahafn
Copy link
Member

@shahafn shahafn commented May 21, 2019

  • Changing snake to camel case
  • Adding version to hub
  • Changing canRelay ret val from uint32 to uint

@@ -1,6 +1,6 @@
pragma solidity >=0.4.0 <0.6.0;

contract RelayHubApi {
contract RelayHubApi {
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done

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;
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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)

Copy link
Member Author

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.

Copy link
Member

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 .

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -19,7 +19,7 @@ import (
"time"
)

const VERSION = "0.3.5"
const VERSION = "0.3.6"
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 its more than a minor change - its a clear API change.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

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)
Copy link
Member

Choose a reason for hiding this comment

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

relayed, not relyed

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@drortirosh
Copy link
Member

drortirosh commented May 22, 2019 via email

RelayHubApi -> IRelayHub
RelayRecipientApi -> IRelayRecipient

Updating server version
@@ -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).
Copy link
Member

Choose a reason for hiding this comment

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

  1. Don't leave such long line comment. Split them to be readable.
  2. 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
Copy link
Member

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)

* @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);
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@shahafn shahafn force-pushed the refactoring branch 2 times, most recently from 1d41425 to 049cc31 Compare May 23, 2019 14:31
@shahafn shahafn merged commit 612bee7 into master May 23, 2019
@shahafn shahafn deleted the refactoring branch May 23, 2019 15:04
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.

None yet

2 participants