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

Merge v0.10.7 into dev #74

Merged
merged 14 commits into from
Feb 1, 2024
Merged
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: 3 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ var (
utils.BlockMinBuildTime,
utils.BlockMinBuildTxs,
utils.BlockTrailTime,
utils.PublicRequestsCacheLocation,
utils.MaxPublicRequests,
utils.BootnodeCount,
}
)

Expand Down
51 changes: 49 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math"
"math/big"
"math/rand"
"os"
"path/filepath"
godebug "runtime/debug"
Expand Down Expand Up @@ -1086,6 +1087,21 @@ var (
Value: params.BlockTrailTime,
Category: flags.WemixCategory,
}
PublicRequestsCacheLocation = &cli.StringFlag{
Name: "wemix.publicrequests.cache",
Usage: "Public requests cache location",
Value: params.PublicRequestsCacheLocation,
}
MaxPublicRequests = &cli.Int64Flag{
Name: "wemix.publicrequests.max",
Usage: "Max # of concurrent public requests",
Value: params.MaxPublicRequests,
}
BootnodeCount = &cli.IntFlag{
Name: "wemix.bootnodecount",
Usage: "Default bootnode peer count",
Value: params.BootnodeCount,
}
)

var (
Expand Down Expand Up @@ -1172,15 +1188,40 @@ func setNodeUserIdent(ctx *cli.Context, cfg *node.Config) {
}
}

// setRandomBootstrapNodes setting a random list of bootstrap nodes using the command line
func setRandomBootstrapNodes(ctx *cli.Context, bootnodes []string) []string {
rand.Seed(time.Now().UnixNano())
bootnodeslen := len(bootnodes)

// check command line
if ctx.IsSet(BootnodeCount.Name) {
setcount := ctx.Int(BootnodeCount.Name)
if setcount > 0 && setcount <= bootnodeslen {
params.BootnodeCount = setcount
}
}
// select random bootnodes
selectcount := params.BootnodeCount
urls := make([]string, selectcount)
tempnode := make([]string, bootnodeslen)
copy(tempnode, bootnodes)
for i := 0; i < selectcount; i++ {
index := rand.Intn(len(tempnode))
urls = append(urls, tempnode[index])
tempnode = append(tempnode[:index], tempnode[index+1:]...)
}
return urls
}

// setBootstrapNodes creates a list of bootstrap nodes from the command line
// flags, reverting to pre-configured ones if none have been specified.
func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls := params.WemixMainnetBootnodes
urls := setRandomBootstrapNodes(ctx, params.WemixMainnetBootnodes)
switch {
case ctx.IsSet(BootnodesFlag.Name):
urls = SplitAndTrim(ctx.String(BootnodesFlag.Name))
case ctx.Bool(WemixTestnetFlag.Name):
urls = params.WemixTestnetBootnodes
urls = setRandomBootstrapNodes(ctx, params.WemixTestnetBootnodes)
case ctx.Bool(RopstenFlag.Name):
urls = params.RopstenBootnodes
case ctx.Bool(SepoliaFlag.Name):
Expand Down Expand Up @@ -2152,6 +2193,12 @@ func SetWemixConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if ctx.IsSet(BlockTrailTime.Name) {
params.BlockTrailTime = ctx.Int64(BlockTrailTime.Name)
}
if ctx.IsSet(PublicRequestsCacheLocation.Name) {
params.PublicRequestsCacheLocation = ctx.String(PublicRequestsCacheLocation.Name)
}
if ctx.IsSet(MaxPublicRequests.Name) {
params.MaxPublicRequests = ctx.Int64(MaxPublicRequests.Name)
}

if params.ConsensusMethod == params.ConsensusInvalid {
params.ConsensusMethod = params.ConsensusPoW
Expand Down
2 changes: 1 addition & 1 deletion eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (api *DebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error)
} else {
blockRlp = fmt.Sprintf("%#x", rlpBytes)
}
if blockJSON, err = ethapi.RPCMarshalBlock(block, true, true, api.eth.APIBackend.ChainConfig()); err != nil {
if blockJSON, err = ethapi.RPCMarshalBlock(ctx, block, true, true, api.eth.APIBackend.ChainConfig()); err != nil {
blockJSON = map[string]interface{}{"error": err.Error()}
}
results = append(results, &BadBlockArgs{
Expand Down
2 changes: 1 addition & 1 deletion eth/protocols/eth/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
const (
// maxKnownTxs is the maximum transactions hashes to keep in the known list
// before starting to randomly evict them.
maxKnownTxs = 2000000
maxKnownTxs = 100000

// maxKnownBlocks is the maximum block hashes to keep in the known list
// before starting to randomly evict them.
Expand Down
Loading
Loading