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

internal/ethapi: disable sending of non eip155 replay protected tx #22339

Merged
merged 9 commits into from
Feb 23, 2021
5 changes: 3 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,9 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
if ctx.GlobalIsSet(HTTPPathPrefixFlag.Name) {
cfg.HTTPPathPrefix = ctx.GlobalString(HTTPPathPrefixFlag.Name)
}

cfg.UnprotectedAllowed = ctx.GlobalBool(AllowUnprotectedTxs.Name)
if ctx.GlobalIsSet(HTTPPathPrefixFlag.Name) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this tied to the http flag?

cfg.AllowUnprotectedTxs = ctx.GlobalBool(AllowUnprotectedTxs.Name)
}
}

// setGraphQL creates the GraphQL listener interface string from the set
Expand Down
10 changes: 5 additions & 5 deletions eth/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import (

// EthAPIBackend implements ethapi.Backend for full nodes
type EthAPIBackend struct {
extRPCEnabled bool
unprotectedAllowed bool
eth *Ethereum
gpo *gasprice.Oracle
extRPCEnabled bool
allowUnprotectedTxs bool
eth *Ethereum
gpo *gasprice.Oracle
}

// ChainConfig returns the active chain configuration.
Expand Down Expand Up @@ -294,7 +294,7 @@ func (b *EthAPIBackend) ExtRPCEnabled() bool {
}

func (b *EthAPIBackend) UnprotectedAllowed() bool {
return b.unprotectedAllowed
return b.allowUnprotectedTxs
}

func (b *EthAPIBackend) RPCGasCap() uint64 {
Expand Down
3 changes: 2 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))

eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().UnprotectedAllowed, eth, nil}
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
log.Info("Unprotected TXs allowed", "value", eth.APIBackend.allowUnprotectedTxs)
Copy link
Member

Choose a reason for hiding this comment

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

please type it out, transactions :P

gpoParams := config.GPO
if gpoParams.Default == nil {
gpoParams.Default = config.Miner.GasPrice
Expand Down
10 changes: 5 additions & 5 deletions les/api_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ import (
)

type LesApiBackend struct {
extRPCEnabled bool
unprotectedAllowed bool
eth *LightEthereum
gpo *gasprice.Oracle
extRPCEnabled bool
allowUnprotectedTxs bool
eth *LightEthereum
gpo *gasprice.Oracle
}

func (b *LesApiBackend) ChainConfig() *params.ChainConfig {
Expand Down Expand Up @@ -265,7 +265,7 @@ func (b *LesApiBackend) ExtRPCEnabled() bool {
}

func (b *LesApiBackend) UnprotectedAllowed() bool {
return b.unprotectedAllowed
return b.allowUnprotectedTxs
}

func (b *LesApiBackend) RPCGasCap() uint64 {
Expand Down
2 changes: 1 addition & 1 deletion les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*LightEthereum, error) {
rawdb.WriteChainConfig(chainDb, genesisHash, chainConfig)
}

leth.ApiBackend = &LesApiBackend{stack.Config().ExtRPCEnabled(), stack.Config().UnprotectedAllowed, leth, nil}
leth.ApiBackend = &LesApiBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, leth, nil}
gpoParams := config.GPO
if gpoParams.Default == nil {
gpoParams.Default = config.Miner.GasPrice
Expand Down
4 changes: 2 additions & 2 deletions node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ type Config struct {
trustedNodesWarning bool
oldGethResourceWarning bool

// UnprotectedAllowed allows non EIP-155 protected transactions to be send over RPC.
UnprotectedAllowed bool `toml:",omitempty"`
// AllowUnprotectedTxs allows non EIP-155 protected transactions to be send over RPC.
AllowUnprotectedTxs bool `toml:",omitempty"`
}

// IPCEndpoint resolves an IPC endpoint based on a configured value, taking into
Expand Down