-
Notifications
You must be signed in to change notification settings - Fork 9
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.
This PR comes very close to "implementing our own cryptography".
I'd rather pick a different package to compute transaction hashes instead of manipulating private keys directly. Ideally there already is a helper function in the Gnosis Safe repo, in the very worst case I'd copy the code there 1-to-1.
In any case I thought the main motivation of this PR was to remove eth-lightwallet because of this comment. If we are willing to keep eth-lightwallet in then we could simply use a different mnemonic in signTransaction
instead of the default one.
Also, would the complete liquidity provision script work for us with the current setup? We currently use Ganache's default account as the proposer account, which means that we need its private key when running the scripts. But it can't hold any funds, so it can't send out the transaction creating the new Safes.
scripts/utils/sign_and_send.js
Outdated
console.log(`Signing and posting multi-send transaction request from proposer account ${account}`) | ||
const sigs = signTransaction(lightWallet, [account], transactionHash) | ||
const privateKey = process.env.PK | ||
const account = web3.eth.accounts.privateKeyToAccount("0x" + privateKey) |
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.
Implementation question: does this line change the output of web3.eth.getAccounts()
?
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.
Also seems hackey to be doing string manipulation in the vicinity of a private key...
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.
According to the documentation, is only creating an account object, which I am storing in the account variable:
https://web3js.readthedocs.io/en/v1.2.0/web3-eth-accounts.html#privatekeytoaccount
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.
@bh2smith How would you propose to do it better?
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 guess this is standard,
However, I wonder what would happen if I provided the "0x" along with the private when exporting it. For example, if I had copied my PK from ganache?
which includes the 0x.
I would be very much in favour of this. It is a non-standard library to my understanding anyway and is probably also the reason for that silly |
I don't manipulate private keys. I can see that one would like to argue for a vault, but I feel like I don't make anything worse, as we have the PK anyways already exported as env. I think the vault integration that does not depend on unmaintained repos should happen in another PR.
No. I think that it is not acceptable that anyone can propose transactions to our safe. Once the transaction is in the interface, there is a much higher risk that it gets signed accidentally.
Yes, we need to modify the setup for this of the current Master_safe, but it's worth it, for sure. |
I think the changes in this PR are good and needed. I also think the changes in the implementation do not introduce any issue that was not already present before this PR, so overall the PR is approved. I still think we should remove |
Okay, then I will remove the light wallet before we merge this one. |
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.
Bravo! I have been dreaming of a day when this project no longer depends on lightwallet.
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 PR is great!
test/dfusion_multi_safes.js
Outdated
masterSafe, | ||
safeOwner.privateKey, | ||
requestWithdrawalTransaction, | ||
"request withdrawal for all brackets" |
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 really wonder where this string came from. Maybe you can remove it, since you removed a similar one somewhere else in the code?
test/dfusion_multi_safes.js
Outdated
masterSafe, | ||
safeOwner.privateKey, | ||
transferFundsToMasterTransaction, | ||
"transfer funds to master for all brackets" |
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.
Candidate string to remove, as before.
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.
console.log(`Signing and posting multi-send transaction request from proposer account ${account}`) | ||
const sigs = signTransaction(lightWallet, [account], transactionHash) | ||
const privateKey = process.env.PK | ||
const account = web3.eth.accounts.privateKeyToAccount(privateKey) |
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 method is expecting a 0x prefixed string but the PK is exported without the 0x in truffle (https://web3js.readthedocs.io/en/v1.2.0/web3-eth-accounts.html#privatekeytoaccount)
I see now that if you tested this change by exporting a PK with the 0x prefix it works. I should have checked the discussion on this PR before commenting above as it was originally implemented in the way that I would have expected it (allowing to paste a PK from MM). I might have further been mislead by the absence of a test plan. |
Fixes #154 Instead of hardcoding an internal gas limit (which already turned out to be brittle, cf #209), we should use the Safe's functionality to estimate the internal call appropriately. This is also done in the [safe-proxy-kit](https://github.com/gnosis/contract-proxy-kit/pull/49/files) and an example of how to do it can be found in the safe contracts [unit tests](safe-global/safe-smart-account#188) There are two tiny unrelated changes in this PR. One is a hotfix for #200 and the other one is a formatting issue that made only printed as: > Error: Error while talking to the gnosis-interface: [object Object] ### Test Plan ``` export NETWORK_NAME=rinkeby export GAS_PRICE_GWEI=9 export MASTER_SAFE=your master safe export PK=... npx truffle exec scripts/complete_liquidity_provision.js --targetToken=0 --stableToken=7 --lowestLimit=0.10 --highestLimit=1 --currentPrice=0.70 --masterSafe=$MASTER_SAFE --investmentTargetToken=0.05 --investmentStableToken=0.05 --fleetSize=20 --network=$NETWORK_NAME ``` See txs go through. Or check https://rinkeby.etherscan.io/tx/0xbcf31282c2350f8e521123d76d243a3c8a995f21024a8b25776c98c12993b450#internal which shows the hardcoded value of 4M **before this PR** and https://rinkeby.etherscan.io/tx/0x37deb7cd729e52e2d29d195df6b4ac16299f1b6b90b14e6f53300e201d39d3e3#internal for the exact estimated value **after this PR** (2.9M)
closes #158
I eliminated the standardized proposer account.
I think in this PR, we could eliminate the lightwallet integration completely, but then I think in the future we want to have keystore file system for sure.
I am not yet sure, which keystore filesystem we should use, since the one from the gnosis-safe team is no longer maintained:
https://github.com/ConsenSys/eth-lightwallet/blob/master/lib/signing.js
Hence, I have decided to keep the lightwallet in there, in case we switch back in the future.