Skip to content

Commit 707c2ca

Browse files
committed
fix transaction sender cache miss before broadcast
1 parent 0ee6114 commit 707c2ca

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

core/types/transaction_signing.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint
5353
return signer
5454
}
5555

56+
// LatestSigner returns the 'most permissive' Signer available for the given chain
57+
// configuration. Specifically, this enables support of all types of transactions
58+
// when their respective forks are scheduled to occur at any block number (or time)
59+
// in the chain config.
60+
//
61+
// Use this in transaction-handling code where the current block number is unknown. If you
62+
// have the current block number available, use MakeSigner instead.
63+
func LatestSigner(config *params.ChainConfig) Signer {
64+
var signer Signer
65+
if config.ChainID != nil {
66+
switch {
67+
case config.EIP155Block != nil:
68+
signer = NewEIP155Signer(config.ChainID)
69+
default:
70+
signer = HomesteadSigner{}
71+
}
72+
} else {
73+
signer = HomesteadSigner{}
74+
}
75+
return signer
76+
}
77+
5678
// LatestSignerForChainID returns the 'most permissive' Signer available. Specifically,
5779
// this enables support for EIP-155 replay protection and all implemented EIP-2718
5880
// transaction types if chainID is non-nil.

ctxc/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ func (pm *ProtocolManager) BroadcastTransactions(txs types.Transactions) {
10931093
total := new(big.Int).Exp(direct, big.NewInt(2), nil) // Stabilise total peer count a bit based on sqrt peers
10941094

10951095
var (
1096-
signer = types.LatestSignerForChainID(pm.blockchain.Config().ChainID) // Don't care about chain status, we just need *a* sender
1096+
signer = types.LatestSigner(pm.blockchain.Config()) // Don't care about chain status, we just need *a* sender
10971097
hasher = crypto.NewKeccakState()
10981098
hash = make([]byte, 32)
10991099
)

0 commit comments

Comments
 (0)