mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
Merge pull request #1098 from maticnetwork/arpit/fix-shadowfork
allow unprotected txns
This commit is contained in:
commit
abab36be3d
4 changed files with 53 additions and 5 deletions
|
|
@ -159,7 +159,8 @@ var DefaultConfig = Config{
|
|||
AccountQueue: 64,
|
||||
GlobalQueue: 1024,
|
||||
|
||||
Lifetime: 3 * time.Hour,
|
||||
Lifetime: 3 * time.Hour,
|
||||
AllowUnprotectedTxs: false,
|
||||
}
|
||||
|
||||
// sanitize checks the provided user configurations and changes anything that's
|
||||
|
|
@ -590,7 +591,8 @@ func (pool *LegacyPool) local() map[common.Address]types.Transactions {
|
|||
// and does not require the pool mutex to be held.
|
||||
func (pool *LegacyPool) validateTxBasics(tx *types.Transaction, local bool) error {
|
||||
opts := &txpool.ValidationOptions{
|
||||
Config: pool.chainconfig,
|
||||
Config: pool.chainconfig,
|
||||
AllowUnprotectedTxs: pool.config.AllowUnprotectedTxs,
|
||||
Accept: 0 |
|
||||
1<<types.LegacyTxType |
|
||||
1<<types.AccessListTxType |
|
||||
|
|
@ -660,6 +662,11 @@ func (pool *LegacyPool) add(tx *types.Transaction, local bool) (replaced bool, e
|
|||
knownTxMeter.Mark(1)
|
||||
return false, ErrAlreadyKnown
|
||||
}
|
||||
|
||||
if pool.config.AllowUnprotectedTxs {
|
||||
pool.signer = types.NewFakeSigner(tx.ChainId())
|
||||
}
|
||||
|
||||
// Make the local flag. If it's from local source or it's from the network but
|
||||
// the sender is marked as local previously, treat it as the local transaction.
|
||||
isLocal := local || pool.locals.containsTx(tx)
|
||||
|
|
@ -982,6 +989,11 @@ func (pool *LegacyPool) addTxs(txs []*types.Transaction, local, sync bool) []err
|
|||
knownTxMeter.Mark(1)
|
||||
continue
|
||||
}
|
||||
|
||||
if pool.config.AllowUnprotectedTxs {
|
||||
pool.signer = types.NewFakeSigner(tx.ChainId())
|
||||
}
|
||||
|
||||
// Exclude transactions with basic errors, e.g invalid signatures and
|
||||
// insufficient intrinsic gas as soon as possible and cache senders
|
||||
// in transactions before obtaining lock
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ import (
|
|||
type ValidationOptions struct {
|
||||
Config *params.ChainConfig // Chain configuration to selectively validate based on current fork rules
|
||||
|
||||
AllowUnprotectedTxs bool // Whether to allow unprotected transactions in the pool
|
||||
|
||||
Accept uint8 // Bitmap of transaction types that should be accepted for the calling pool
|
||||
MaxSize uint64 // Maximum size of a transaction that the caller can meaningfully handle
|
||||
MinTip *big.Int // Minimum gas tip needed to allow a transaction into the caller pool
|
||||
|
|
@ -91,7 +93,7 @@ func ValidateTransaction(tx *types.Transaction, blobs []kzg4844.Blob, commits []
|
|||
return core.ErrTipAboveFeeCap
|
||||
}
|
||||
// Make sure the transaction is signed properly
|
||||
if _, err := types.Sender(signer, tx); err != nil {
|
||||
if _, err := types.Sender(signer, tx); err != nil && !opts.AllowUnprotectedTxs {
|
||||
return ErrInvalidSender
|
||||
}
|
||||
// Ensure the transaction has more gas than the bare minimum needed to cover
|
||||
|
|
|
|||
|
|
@ -594,3 +594,38 @@ func deriveChainId(v *big.Int) *big.Int {
|
|||
v = new(big.Int).Sub(v, big.NewInt(35))
|
||||
return v.Div(v, big.NewInt(2))
|
||||
}
|
||||
|
||||
// FakeSigner implements the Signer interface and accepts unprotected transactions
|
||||
type FakeSigner struct{ londonSigner }
|
||||
|
||||
var _ Signer = FakeSigner{}
|
||||
|
||||
func NewFakeSigner(chainId *big.Int) Signer {
|
||||
signer := NewLondonSigner(chainId)
|
||||
ls, _ := signer.(londonSigner)
|
||||
return FakeSigner{londonSigner: ls}
|
||||
}
|
||||
|
||||
func (f FakeSigner) Sender(tx *Transaction) (common.Address, error) {
|
||||
return f.londonSigner.Sender(tx)
|
||||
}
|
||||
|
||||
func (f FakeSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error) {
|
||||
return f.londonSigner.SignatureValues(tx, sig)
|
||||
}
|
||||
|
||||
func (f FakeSigner) ChainID() *big.Int {
|
||||
return f.londonSigner.ChainID()
|
||||
}
|
||||
|
||||
// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
|
||||
// private key. This hash does not uniquely identify the transaction.
|
||||
func (f FakeSigner) Hash(tx *Transaction) common.Hash {
|
||||
return f.londonSigner.Hash(tx)
|
||||
}
|
||||
|
||||
// Equal returns true if the given signer is the same as the receiver.
|
||||
func (f FakeSigner) Equal(Signer) bool {
|
||||
// Always return true
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,8 +168,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
|
||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
||||
if eth.APIBackend.allowUnprotectedTxs {
|
||||
log.Debug(" ###########", "Unprotected transactions allowed")
|
||||
|
||||
log.Info("------Unprotected transactions allowed-------")
|
||||
config.TxPool.AllowUnprotectedTxs = true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue