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

ethclient, mobile: add TransactionSender #15127

Merged
merged 7 commits into from
Oct 1, 2017
Merged

Conversation

fjl
Copy link
Contributor

@fjl fjl commented Sep 11, 2017

The new method can get the right signer without any crypto, and without
knowledge of the signature scheme that was used when the transaction was
included.

@fjl fjl requested a review from bas-vk September 11, 2017 14:04
@fjl fjl force-pushed the ethclient-tx-sender branch 5 times, most recently from d3846ea to 68de1c3 Compare September 11, 2017 22:09
There are two reasons to do this now: The upcoming ethclient signer
doesn't know the public key, just the address. EIP 208 will introduce a
new signer which derives the 'entry point' address for transactions with
zero signature. The entry point has no public key.

Other changes to the interface ease the path make to moving signature
crypto out of core/types later.
@fjl fjl force-pushed the ethclient-tx-sender branch 2 times, most recently from 984140b to 3e6bf9c Compare September 11, 2017 22:22
The new method can get the right signer without any crypto, and without
knowledge of the signature scheme that was used when the transaction was
included.
@fjl fjl force-pushed the ethclient-tx-sender branch from 3e6bf9c to e4ae593 Compare September 11, 2017 22:30
@fjl fjl changed the title [WIP] ethclient: add Sender and cache the sender address ethclient: add Sender and cache the sender address Sep 11, 2017
@fjl fjl changed the title ethclient: add Sender and cache the sender address ethclient, mobile: add TransactionSender Sep 11, 2017

var errNotCached = errors.New("sender not cached")

func setSenderFromServer(tx *types.Transaction, addr common.Address) {
Copy link
Member

Choose a reason for hiding this comment

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

We can call this method also from getBlock since the response always contains full transaction details. That saves a round up trip to the node when the client calls TransactionSender on the transactions in the block.

// TODO It'd better to use GetTransactionByBlockHashAndIndex because it works with the
// light client. This will be even more important with EIP 208 because there can be
// multiple inclusions of the same tx. The downside is that users would need to supply
// the inclusion block.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bas-vk I need your feedback on this comment because it would change the method signature. I don't want to change the signature later.

fjl added 2 commits September 20, 2017 11:17

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@fjl
Copy link
Contributor Author

fjl commented Sep 25, 2017

@bas-vk PTAL

addr, err := ec.client.TransactionSender(ctx.context, tx.tx)
// GetTransactionSender returns the sender address of a transaction. The transaction must
// be included in the blockchain.
func (ec *EthereumClient) GetTransactionSender(ctx *Context, tx *Transaction, hash *Hash, index int) (sender *Address, _ error) {
Copy link
Member

Choose a reason for hiding this comment

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

Please document that hash and index points to a block hash and tx index. That is not obvious.

Copy link
Member

@bas-vk bas-vk left a comment

Choose a reason for hiding this comment

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

@fjl
Copy link
Contributor Author

fjl commented Sep 27, 2017

@bas-vk PTAL

@bas-vk
Copy link
Member

bas-vk commented Sep 27, 2017

👍

@fjl fjl merged commit d78ad22 into ethereum:master Oct 1, 2017
@karalabe karalabe added this to the 1.7.1 milestone Oct 2, 2017
vincentserpoul pushed a commit to vincentserpoul/go-ethereum that referenced this pull request Nov 22, 2017
* core/types: make Signer derive address instead of public key

There are two reasons to do this now: The upcoming ethclient signer
doesn't know the public key, just the address. EIP 208 will introduce a
new signer which derives the 'entry point' address for transactions with
zero signature. The entry point has no public key.

Other changes to the interface ease the path make to moving signature
crypto out of core/types later.

* ethclient, mobile: add TransactionSender

The new method can get the right signer without any crypto, and without
knowledge of the signature scheme that was used when the transaction was
included.
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

3 participants