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

Give clients on the wallet a way to get pending transactions #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bencxr
Copy link
Contributor

@bencxr bencxr commented Jun 14, 2016

Give clients on the wallet a way to get the pending transactions that require the confirmation of other signers on the wallet.

New methods to help deal with multi user transactions:
getPendingConfirmationsNeeded(bytes32 _operation) returns (uint)
numPendingTransactions() returns (uint)
getPendingTransaction(uint _index) returns (bytes32)
getPendingTransactionToAddress(bytes32 _operation) returns (address)
getPendingTransactionValue(bytes32 _operation) returns (uint)
getPendingTransactionData(bytes32 _operation) returns (bytes)

Example usage and tests:
https://github.com/BitGo/eth-multisig-v2/blob/master/test/wallet.js#L60

@bencxr bencxr changed the title Methods to deal with pending transactions Give clients on the wallet a way to get pending transactions Jun 14, 2016
@frozeman
Copy link
Contributor

Couldn't you simply return multiple return parameters and reduce this to two functions?
In web3.js they will be returned as array of values, but you could name them. In the future we will allow named return parameters in web3.js

@bencxr bencxr force-pushed the getPendingTransactionsMethods branch from c992080 to 9878ab2 Compare July 5, 2016 08:42
@bencxr
Copy link
Contributor Author

bencxr commented Jul 5, 2016

you are right and i have made the change as you suggested!

@gavofyork
Copy link
Contributor

logs can be used to achieve the same thing without the extra chain-side code.

@frozeman
Copy link
Contributor

frozeman commented Aug 1, 2016

Yes, but this way is prone to errors, needs complex log matching with chain-reorg detection and doesn't work if you only have the current state.

I worked with your contract since a year+ and build the wallet on top of it. These functions are exactly missing.

Matching logs is especially bad if you have the same operation hash in multiple logs. You can't know which one was already confirmed and which not. Trust me it's not fun building interfaces like this.

@bencxr
Copy link
Contributor Author

bencxr commented Aug 1, 2016

I would add also that good interfaces to get previous logs (by event type) do not exist as far as I looked. This puts a burden of storing state on the wallet developer.

We should strive to make this contract interface intuitive to use for the developer to build on top of.


// INTERNAL METHODS
Copy link

Choose a reason for hiding this comment

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

I feel the extra line was for visibility. Check line 50 above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alright, i'll leave it in

// Use m_pendingIndex.length to get all hashes, then count how many of the
// operations are transactions, because we don't want to store hashes twice
// and this is a local call anyway
for (uint i = 0; i < m_pendingIndex.length; i++) {
Copy link

@veox veox Aug 2, 2016

Choose a reason for hiding this comment

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

m_pendingIndex.length is a dynamically-sized array. i would be an uint8 (as per the docs).

If m_pendingIndex.length > 255, this is an endless loop.

I haven't looked through all the dapp, but can it be guaranteed that this won't end in always-OOG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a uint

@veox
Copy link

veox commented Aug 2, 2016

Sorry for the barrage of copy-paste comments. Tired ATM.

@veox
Copy link

veox commented Aug 3, 2016

I can swear I saw var i in those loops y-day. @bencxr, did you rewrite history, or was I delusional?

@bencxr bencxr force-pushed the getPendingTransactionsMethods branch from 9878ab2 to 46b7e3b Compare August 8, 2016 08:27
@bencxr
Copy link
Contributor Author

bencxr commented Aug 8, 2016

ok, addressed your comments. this diff uses uints, but I do have another with some var usage. thanks for your input though.


// Gets the pending operation at a specified index
// Will return a tuple [bytes32 operationHash, uint confirmationsNeeded, address toAddress, uint transactionValue, bytes data]
function getPendingTransaction(uint _index) constant returns (bytes32, uint, address, uint, bytes) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better readable if you named the return parameters. Then it is also much harder to make a mistake an the actual return instruction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I named the return parameters.. but more for documentation than to replace 391.

@vbuterin
Copy link
Contributor

I'll echo gav's comment that logs are a nicer approach. Multisig wallets should be a very universal tool that is eventually the type of account used by almost everyone; imo it's not acceptable to give them 100k gas of overhead.

@chriseth
Copy link
Collaborator

@vbuterin especially if multisig wallets are tools that are used by almost everyone, they can be used together with DELEGATECALL at basically no cost. From all our experience, logs are extremely unreliable, but even if that is fixed, I would say it is much safer to just add some query methods. Building up a copy of the current state through deltas from logs in the frontend is just not the same thing as just asking for the current state that is anyway present in the backend.

@bencxr
Copy link
Contributor Author

bencxr commented Aug 25, 2016

@vbuterin I feel that @chriseth has made a good point on the DELEGATECALL. We use solc --clone over here and so far are very pleased with the result, huge amount of savings over our wallets. I wonder if we should have some way for all dapps that are accepted / merged in here to be deployed and addresses listed so that other contract browsers / creators can re-use the space.

@bencxr bencxr force-pushed the getPendingTransactionsMethods branch from 46b7e3b to 6f56bd7 Compare August 29, 2016 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants