Skip to content

Commit f651c1b

Browse files
committed
Fix sometimes printing wrong address.
Prior to this fix, a series of submitted transactions in the javascript console would each show a different "from" field when inspected with `eth.getTransaction`. It turns out the transactions were all created with the correct sender, but were just printed incorrectly. We were using the EIP155Signer when all Quorum transactions expect the HomesteadSigner. This fix is not exactly satisfying, since in every other place we've been able to use an `isQuorum` boolean to tell whether a `v` of `37` or `38` denotes a quorum private tx, but it's particularly hard to do that in these two places.
1 parent d21f5e5 commit f651c1b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

core/types/transaction.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var (
3939

4040
// deriveSigner makes a *best* guess about which signer to use.
4141
func deriveSigner(V *big.Int) Signer {
42+
// joel: this is one of the two places we used a wrong signer to print txes
4243
if V.Sign() != 0 && isProtectedV(V) {
4344
return NewEIP155Signer(deriveChainId(V))
4445
} else {
@@ -131,7 +132,10 @@ func (tx *Transaction) Protected() bool {
131132
func isProtectedV(V *big.Int) bool {
132133
if V.BitLen() <= 8 {
133134
v := V.Uint64()
134-
return v != 27 && v != 28
135+
// 27 / 28 are pre eip 155 -- ie unprotected.
136+
// TODO(joel): this is a hack. Everywhere else we maintain vanilla ethereum
137+
// compatibility and we should figure out how to extend that to here
138+
return !(v == 27 || v == 28 || v == 37 || v == 38)
135139
}
136140
// anything not 27 or 28 are considered unprotected
137141
return true

internal/ethapi/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ type RPCTransaction struct {
834834
// representation, with the given location metadata set (if available).
835835
func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction {
836836
var signer types.Signer = types.HomesteadSigner{}
837+
// joel: this is one of the two places we used a wrong signer to print txes
837838
if tx.Protected() {
838839
signer = types.NewEIP155Signer(tx.ChainId())
839840
}

0 commit comments

Comments
 (0)