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

release: v1.3.8 sentry #4

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,14 @@ func doLint(cmdline []string) {

linter := downloadLinter(*cachedir)
lflags := []string{"run", "--config", ".golangci.yml"}
build.MustRunCommand("./build/goimports.sh") // BX: add run of default goimports
build.MustRunCommand(linter, append(lflags, packages...)...)
fmt.Println("You have achieved perfection.")
}

// downloadLinter downloads and unpacks golangci-lint.
func downloadLinter(cachedir string) string {
const version = "1.52.2"
const version = "1.55.2"

csdb := build.MustLoadChecksums("build/checksums.txt")
arch := runtime.GOARCH
Expand Down
2 changes: 1 addition & 1 deletion build/goimports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ find_files() {
-o -path './crypto/bn256' \
-o -path '*/vendor/*' \
\) -prune \
\) -name '*.go'
\) -name '*.go' -not -name '*.pb.go' -not -name '*_rlp.go'
}

GOFMT="gofmt -s -w"
Expand Down
2 changes: 1 addition & 1 deletion cmd/clef/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ func signer(c *cli.Context) error {
if err != nil {
utils.Fatalf("Could not register API: %w", err)
}
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)
handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil, nil)

// set port
port := c.Int(rpcPortFlag.Name)
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/consolecmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

const (
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 parlia:1.0 rpc:1.0 txpool:1.0 web3:1.0"
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 mev:1.0 miner:1.0 net:1.0 parlia:1.0 rpc:1.0 txpool:1.0 web3:1.0"
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ var (
utils.BLSPasswordFileFlag,
utils.BLSWalletDirFlag,
utils.VoteJournalDirFlag,
}, utils.NetworkFlags, utils.DatabasePathFlags)
}, utils.NetworkFlags, utils.DatabasePathFlags, utils.SentryFlags, utils.HTTPSecuredFlags)

rpcFlags = []cli.Flag{
utils.HTTPEnabledFlag,
Expand Down
2 changes: 2 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
SetP2PConfig(ctx, &cfg.P2P)
setIPC(ctx, cfg)
setHTTP(ctx, cfg)
setHTTPSecuredIP(ctx, cfg)
setGraphQL(ctx, cfg)
setWS(ctx, cfg)
setNodeUserIdent(ctx, cfg)
Expand Down Expand Up @@ -1801,6 +1802,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
setMiner(ctx, &cfg.Miner)
setRequiredBlocks(ctx, cfg)
setLes(ctx, cfg)
setSentry(ctx, cfg)

// Cap the cache allowance and tune the garbage collector
mem, err := gopsutil.VirtualMemory()
Expand Down
95 changes: 95 additions & 0 deletions cmd/utils/flags_blxr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package utils

import (
"strings"

"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/node"
"github.com/urfave/cli/v2"
)

var (
SentryMinerUriFlag = &cli.StringFlag{
Name: "sentry.mineruri",
Usage: "Uri used by the proxy forwarding blocks from the relay to the validator",
}
SentryRelaysUriFlag = &cli.StringSliceFlag{
Name: "sentry.relaysuri",
Usage: "Slice of MEV relay uris sending the registration from the validator node",
}

SentryFlags = []cli.Flag{
SentryMinerUriFlag,
SentryRelaysUriFlag,
}
)

var (
HTTPSecuredIPPortFlag = &cli.IntFlag{
Name: "http.securedipport",
Usage: "HTTP-RPC server secured by IP listening port",
Value: node.DefaultHTTPSecuredIPPort,
Category: flags.APICategory,
}
HTTPSecuredIPAllowedIPsFlag = &cli.StringFlag{
Name: "http.securedipvallowedipss",
Usage: "Comma separated list of IPs from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: strings.Join(node.DefaultConfig.HTTPSecuredIPAllowedIPs, ","),
Category: flags.APICategory,
}
HTTPSecuredIPApiFlag = &cli.StringFlag{
Name: "http.securedipapi",
Usage: "Comma separated list of API's offered over the HTTP-RPC secured by IP interface",
Value: "",
Category: flags.APICategory,
}

HTTPSecuredFlags = []cli.Flag{
HTTPSecuredIPPortFlag,
HTTPSecuredIPAllowedIPsFlag,
HTTPSecuredIPApiFlag,
}
)

// setHTTPSecuredIP creates the HTTP MEV RPC listener interface string from the set
// command line flags, returning empty if the HTTP endpoint is disabled.
func setHTTPSecuredIP(ctx *cli.Context, cfg *node.Config) {
if ctx.Bool(HTTPEnabledFlag.Name) {
if cfg.HTTPHost == "" {
cfg.HTTPHost = "127.0.0.1"
}
if ctx.IsSet(HTTPListenAddrFlag.Name) {
cfg.HTTPHost = ctx.String(HTTPListenAddrFlag.Name)
}
}

if ctx.IsSet(HTTPSecuredIPPortFlag.Name) {
cfg.HTTPSecuredIPPort = ctx.Int(HTTPSecuredIPPortFlag.Name)
}

if ctx.IsSet(HTTPCORSDomainFlag.Name) {
cfg.HTTPCors = SplitAndTrim(ctx.String(HTTPCORSDomainFlag.Name))
}

if ctx.IsSet(HTTPSecuredIPApiFlag.Name) {
cfg.HTTPSecuredIPModules = SplitAndTrim(ctx.String(HTTPSecuredIPApiFlag.Name))
}

if ctx.IsSet(HTTPSecuredIPAllowedIPsFlag.Name) {
cfg.HTTPSecuredIPAllowedIPs = SplitAndTrim(ctx.String(HTTPSecuredIPAllowedIPsFlag.Name))
}

if ctx.IsSet(HTTPPathPrefixFlag.Name) {
cfg.HTTPPathPrefix = ctx.String(HTTPPathPrefixFlag.Name)
}
if ctx.IsSet(AllowUnprotectedTxs.Name) {
cfg.AllowUnprotectedTxs = ctx.Bool(AllowUnprotectedTxs.Name)
}
}

// setSentry configures the sentry settings from the command line flags.
func setSentry(ctx *cli.Context, cfg *ethconfig.Config) {
cfg.SentryMinerUri = ctx.String(SentryMinerUriFlag.Name)
cfg.SentryRelaysUri = ctx.StringSlice(SentryRelaysUriFlag.Name)
}
28 changes: 28 additions & 0 deletions eth/api_backend_blxr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package eth

import (
"context"
"encoding/json"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/rpc"
)

func (b *EthAPIBackend) RegisterValidator(ctx context.Context, args ethapi.RegisterValidatorArgs) error {
return b.eth.sentryProxy.RegisterValidator(ctx, args)
}

func (b *EthAPIBackend) ProposedBlock(ctx context.Context, args json.RawMessage) (any, error) {
return b.eth.sentryProxy.ProposedBlock(ctx, args)
}

func (b *EthAPIBackend) BlockNumber(ctx context.Context) (hexutil.Uint64, error) {
if b.eth.sentryProxy.miner != nil {
return b.eth.sentryProxy.BlockNumber(ctx)
}

// fallback to native implementation and returning the local blocknumber without proxying
header, _ := b.HeaderByNumber(context.Background(), rpc.LatestBlockNumber) // latest header should always be available
return hexutil.Uint64(header.Number.Uint64()), nil
}
4 changes: 4 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ type Ethereum struct {
shutdownTracker *shutdowncheck.ShutdownTracker // Tracks if and when the node has shutdown ungracefully

votePool *vote.VotePool

sentryProxy *SentryProxy
}

// New creates a new Ethereum object (including the
Expand Down Expand Up @@ -306,6 +308,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
return nil, err
}

eth.sentryProxy = NewSentryProxy(config)

eth.miner = miner.New(eth, &config.Miner, eth.blockchain.Config(), eth.EventMux(), eth.engine, eth.isLocalBlock)
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))

Expand Down
6 changes: 6 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ type Config struct {

// OverrideVerkle (TODO: remove after the fork)
OverrideVerkle *uint64 `toml:",omitempty"`

// SentryMinerUri is the sentry miner uri
SentryMinerUri string `toml:",omitempty"`

// SentryRelaysUri is the list of sentry relay uri
SentryRelaysUri []string `toml:",omitempty"`
}

// CreateConsensusEngine creates a consensus engine for the given chain config.
Expand Down
8 changes: 4 additions & 4 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ func TestVoteSubscription(t *testing.T) {
backend, sys = newTestFilterSystem(t, db, Config{Timeout: 5 * time.Minute})
api = NewFilterAPI(sys, false)
votes = []*types.VoteEnvelope{
&types.VoteEnvelope{
{
VoteAddress: types.BLSPublicKey{},
Signature: types.BLSSignature{},
Data: &types.VoteData{
Expand All @@ -843,7 +843,7 @@ func TestVoteSubscription(t *testing.T) {
TargetHash: common.BytesToHash(common.Hex2Bytes(string(rune(1)))),
},
},
&types.VoteEnvelope{
{
VoteAddress: types.BLSPublicKey{},
Signature: types.BLSSignature{},
Data: &types.VoteData{
Expand All @@ -853,7 +853,7 @@ func TestVoteSubscription(t *testing.T) {
TargetHash: common.BytesToHash(common.Hex2Bytes(string(rune(2)))),
},
},
&types.VoteEnvelope{
{
VoteAddress: types.BLSPublicKey{},
Signature: types.BLSSignature{},
Data: &types.VoteData{
Expand All @@ -863,7 +863,7 @@ func TestVoteSubscription(t *testing.T) {
TargetHash: common.BytesToHash(common.Hex2Bytes(string(rune(3)))),
},
},
&types.VoteEnvelope{
{
VoteAddress: types.BLSPublicKey{},
Signature: types.BLSSignature{},
Data: &types.VoteData{
Expand Down
Loading
Loading