Skip to content

Commit

Permalink
Simulate Tx (bnb-chain#15)
Browse files Browse the repository at this point in the history
* SimTx

* Log

* Sim

* 1

* LogTime

* 1

* toml

* 新增Config Trust Peer && RPC Server toml

* 1

* log

* main

* RM Log

* Sim添加错误缓存 && TxCal Simulate打印

* 1

* 新增热更新SimulateTx列表 && SimTx 上报

* db

* 新增BlockValidator打印

* 更新Config

* 新增Log

* 新增Log

* Service tx DB添加字段

* Simulate Tx
  • Loading branch information
swlfigo authored Apr 26, 2023
1 parent ec2f4c4 commit 904b143
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cmd/arb
Submodule arb updated from 4ee444 to ce3179
3 changes: 3 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ var (
utils.BaseDifficultyFlag,
utils.BlockIntervalFlag,
utils.BlockBroadcastIntervalFlag,
utils.ServerType,
utils.RegionType,
utils.InternalType,
//sylarChange //end
utils.IdentityFlag,
utils.UnlockedAccountFlag,
Expand Down
3 changes: 3 additions & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.BaseDifficultyFlag,
utils.BlockIntervalFlag,
utils.BlockBroadcastIntervalFlag,
utils.ServerType,
utils.RegionType,
utils.InternalType,
//sylarChange //end
},
},
Expand Down
23 changes: 23 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ var (
Name: "block.broadcast.interval",
Usage: "区块广播间隔",
}
ServerType = cli.StringFlag{
Name: "server.type",
Usage: "服务器类型", //如Aws,Ali等
}
RegionType = cli.StringFlag{
Name: "region.type",
Usage: "服务器地区", //A.B.C.D....
}
InternalType = cli.BoolFlag{
Name: "rpc.internal.type",
Usage: "是否使用内网地址,默认内网地址",
}
// General settings
DataDirFlag = DirectoryFlag{
Name: "datadir",
Expand Down Expand Up @@ -1673,6 +1685,17 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.GlobalIsSet(BlockBroadcastIntervalFlag.Name) {
cfg.BlockBroadcastInterval = ctx.GlobalInt(BlockBroadcastIntervalFlag.Name)
}
if ctx.GlobalIsSet(ServerType.Name) {
cfg.ServerType = ctx.GlobalString(ServerType.Name)
}
if ctx.GlobalIsSet(RegionType.Name) {
cfg.RegionType = ctx.GlobalString(RegionType.Name)
}
if ctx.GlobalIsSet(InternalType.Name) {
cfg.InternalType = ctx.GlobalBool(InternalType.Name)
} else {
cfg.InternalType = true
}
//sylarChange //end

if ctx.GlobalIsSet(PipeCommitFlag.Name) {
Expand Down
94 changes: 77 additions & 17 deletions config.toml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ type Config struct {
OverrideBerlin *big.Int `toml:",omitempty"`

//sylarChange
BaseDifficulty *big.Int

BaseHash common.Hash

BlockInterval int

BaseDifficulty *big.Int
ServerType string
RegionType string
InternalType bool
BaseHash common.Hash
BlockInterval int
BlockBroadcastInterval int

// Arrow Glacier block override (TODO: remove after the fork)
Expand Down
3 changes: 3 additions & 0 deletions eth/protocols/eth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package eth
import (
"encoding/json"
"fmt"
"github.com/ethereum/go-ethereum/cmd/arb/Block"
"github.com/ethereum/go-ethereum/cmd/arb/Global"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -331,6 +332,7 @@ func handleNewBlockhashes(backend Backend, msg Decoder, peer *Peer) error { //
peer.markBlock(block.Hash)
//sylarChange
peerFilter.NotifyWithPeer(peer, block.Number)
Block.GetBlockManagerInstance().ConfigBlockNumber(block.Number)
}
// Deliver them all to the backend for queuing
return backend.Handle(peer, ann)
Expand Down Expand Up @@ -361,6 +363,7 @@ func handleNewBlock(backend Backend, msg Decoder, peer *Peer) error { //新区

//sylarChange
peerFilter.NotifyWithPeer(peer, ann.Block.NumberU64())
Block.GetBlockManagerInstance().ConfigBlockNumber(ann.Block.NumberU64())
return backend.Handle(peer, ann)
}

Expand Down

0 comments on commit 904b143

Please sign in to comment.