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 1.1.0 #80

Merged
merged 30 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
93d16b9
add: fix getTransactionFromBlockIndex interface
bladehan1 Aug 17, 2023
0749135
add:statesync tx added to GetBlockTransactionCount rpc
bladehan1 Aug 17, 2023
d0105a0
fix get block error when meeting state-sync txns
ClarkChenc Aug 24, 2023
d829fbe
add GetSnapshotProposer and GetSnapshotProposerSequence
ClarkChenc Aug 24, 2023
2065d2e
add fingerprint cmd
ClarkChenc Aug 24, 2023
2e00f25
add: add check for empty lists in txpool
bladehan1 Aug 28, 2023
c15349e
add: add max code init size check in txpool
bladehan1 Aug 28, 2023
6264759
chg: only support full sync
bladehan1 Aug 28, 2023
e8e709a
optimize validatorset with map
ClarkChenc Aug 31, 2023
cbb2eac
add: pr tempalte
bladehan1 Sep 13, 2023
da0b46b
fix : prevent panic
bladehan1 Sep 13, 2023
e22bdc9
add: batch limit in http
bladehan1 Jan 12, 2024
b87e27e
Merge pull request #69 from bladehan1/fix-check-empty
bladehan1 Mar 6, 2024
e283013
chg: fix lint
bladehan1 Mar 6, 2024
d28b8bc
Merge pull request #67 from bladehan1/fea-prevent-snapsync
bladehan1 Mar 6, 2024
f2a5e32
Merge pull request #71 from ClarkChenc/opt-validator-set-with-map
bladehan1 Mar 6, 2024
18eb478
Merge pull request #66 from ClarkChenc/add_fingerprint_cmd
bladehan1 Mar 6, 2024
a2c6046
Merge pull request #65 from ClarkChenc/add_get_snapshot_proposer
bladehan1 Mar 6, 2024
20c6b1c
Merge pull request #64 from ClarkChenc/fix_get_block
bladehan1 Mar 6, 2024
240d1fa
Merge branch 'develop' into fea-optimize
bladehan1 Mar 6, 2024
4ac6d35
Merge pull request #72 from bladehan1/fix-GetTransactionReceiptsByBlock
bladehan1 Mar 6, 2024
50523f6
Merge pull request #73 from bladehan1/fea-pr-template
bladehan1 Mar 6, 2024
4c0cf76
chg:fix lint
bladehan1 Mar 6, 2024
fe60996
Merge pull request #56 from bladehan1/fea-optimize
bladehan1 Mar 6, 2024
b48bfb3
Merge pull request #68 from bladehan1/fea-size-check
bladehan1 Mar 6, 2024
c9984a2
Merge pull request #76 from bladehan1/batchLimitInhttp
bladehan1 Mar 7, 2024
eeb1dc6
chg: fix txHash
bladehan1 Apr 1, 2024
b23e0a6
chg: add check
bladehan1 Apr 2, 2024
9ce223e
chg: add check
bladehan1 Apr 2, 2024
0663952
Merge pull request #78 from bladehan1/fix-txHash
yuekun0707 Apr 2, 2024
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
42 changes: 42 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Description

Please provide a detailed description of what was done in this PR

# Changes

- [ ] Bugfix (non-breaking change that solves an issue)
- [ ] Hotfix (change that solves an urgent issue, and requires immediate attention)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality)

# Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

# Checklist

- [ ] I have added at least 1 reviewer to this PR
- [ ] I have added sufficient documentation in code
- [ ] I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply

# Cross repository changes

- [ ] This PR requires changes to delivery
- In case link the PR here:


## Testing

- [ ] I have added unit tests
- [ ] I have added tests to CI
- [ ] I have tested this code manually on local environment
- [ ] I have tested this code manually on remote devnet


### Manual tests

Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it

# Additional comments

Please post additional comments in this section if you have them, otherwise delete it
62 changes: 62 additions & 0 deletions cmd/geth/fingerprintcmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package main

import (
"fmt"
"math"

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/params"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
"github.com/shirou/gopsutil/host"
"github.com/shirou/gopsutil/mem"
"gopkg.in/urfave/cli.v1"

Check failure on line 13 in cmd/geth/fingerprintcmd.go

View workflow job for this annotation

GitHub Actions / build

"gopkg.in/urfave/cli.v1" imported but not used (typecheck)
)

var (
fingerprintCommand = cli.Command{

Check failure on line 17 in cmd/geth/fingerprintcmd.go

View workflow job for this annotation

GitHub Actions / build

undeclared name: `cli` (typecheck)
Name: "fingerprint",
Usage: "Display the system fingerprint",
ArgsUsage: "",
Action: utils.MigrateFlags(showFingerprint),
Category: "FINGERPRINT COMMANDS",
}
)

func getCoresCount(cp []cpu.InfoStat) int {
cores := 0
for i := 0; i < len(cp); i++ {
cores += int(cp[i].Cores)
}
return cores
}

// Run implements the cli.Command interface
func showFingerprint(_ *cli.Context) error {

Check failure on line 35 in cmd/geth/fingerprintcmd.go

View workflow job for this annotation

GitHub Actions / build

undeclared name: `cli` (typecheck)
v, _ := mem.VirtualMemory()
h, _ := host.Info()
cp, _ := cpu.Info()
d, _ := disk.Usage("/")

osName := h.OS
osVer := h.Platform + " - " + h.PlatformVersion + " - " + h.KernelArch
totalMem := math.Floor(float64(v.Total)/(1024*1024*1024)*100) / 100
availableMem := math.Floor(float64(v.Available)/(1024*1024*1024)*100) / 100
usedMem := math.Floor(float64(v.Used)/(1024*1024*1024)*100) / 100
totalDisk := math.Floor(float64(d.Total)/(1024*1024*1024)*100) / 100
availableDisk := math.Floor(float64(d.Free)/(1024*1024*1024)*100) / 100
usedDisk := math.Floor(float64(d.Used)/(1024*1024*1024)*100) / 100

borDetails := fmt.Sprintf("Bor Version : %s", params.VersionWithMeta)
cpuDetails := fmt.Sprintf("CPU : %d cores", getCoresCount(cp))
osDetails := fmt.Sprintf("OS : %s %s ", osName, osVer)
memDetails := fmt.Sprintf("RAM :: total : %v GB, free : %v GB, used : %v GB", totalMem, availableMem, usedMem)
diskDetails := fmt.Sprintf("STORAGE :: total : %v GB, free : %v GB, used : %v GB", totalDisk, availableDisk, usedDisk)

fmt.Println(borDetails)
fmt.Println(cpuDetails)
fmt.Println(osDetails)
fmt.Println(memDetails)
fmt.Println(diskDetails)
return nil
}
8 changes: 8 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ var (
utils.RPCGlobalGasCapFlag,
utils.RPCGlobalTxFeeCapFlag,
utils.AllowUnprotectedTxs,
utils.BatchRequestLimit,
}

metricsFlags = []cli.Flag{
Expand Down Expand Up @@ -241,6 +242,7 @@ func init() {
utils.ShowDeprecated,
// See snapshot.go
snapshotCommand,
fingerprintCommand,
}
sort.Sort(cli.CommandsByName(app.Commands))

Expand Down Expand Up @@ -273,6 +275,12 @@ func main() {
// prepare manipulates memory cache allowance and setups metric system.
// This function should be called before launching devp2p stack.
func prepare(ctx *cli.Context) {
//only support full sync
err := ctx.Set(utils.SyncModeFlag.Name, "full")
if err != nil {
log.Warn("Failed to set sync mode to full")
}

// If we're running a known preset, log it for convenience.
switch {
case ctx.GlobalIsSet(utils.RopstenFlag.Name):
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.WSApiFlag,
utils.WSPathPrefixFlag,
utils.WSAllowedOriginsFlag,
utils.BatchRequestLimit,
utils.GraphQLEnabledFlag,
utils.GraphQLCORSDomainFlag,
utils.GraphQLVirtualHostsFlag,
Expand Down
12 changes: 10 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ var (
defaultSyncMode = ethconfig.Defaults.SyncMode
SyncModeFlag = TextMarshalerFlag{
Name: "syncmode",
Usage: `Blockchain sync mode ("fast", "full", "snap" or "light")`,
Usage: `Blockchain sync mode (only "full" sync supported)`,
Value: &defaultSyncMode,
}
GCModeFlag = cli.StringFlag{
Expand Down Expand Up @@ -621,7 +621,11 @@ var (
Name: "rpc.allow-unprotected-txs",
Usage: "Allow for unprotected (non EIP155 signed) transactions to be submitted via RPC",
}

BatchRequestLimit = cli.IntFlag{ //nolint:typecheck
Name: "rpc.batch-request-limit",
Usage: "Maximum number of requests in a batch(only supported in http)",
Value: node.DefaultConfig.BatchRequestLimit,
}
// Network Settings
MaxPeersFlag = cli.IntFlag{
Name: "maxpeers",
Expand Down Expand Up @@ -995,6 +999,10 @@ func setHTTP(ctx *cli.Context, cfg *node.Config) {
if ctx.GlobalIsSet(AllowUnprotectedTxs.Name) {
cfg.AllowUnprotectedTxs = ctx.GlobalBool(AllowUnprotectedTxs.Name)
}
if ctx.IsSet(BatchRequestLimit.Name) {
cfg.BatchRequestLimit = ctx.Int(BatchRequestLimit.Name)
}

}

// setGraphQL creates the GraphQL listener interface string from the set
Expand Down
50 changes: 50 additions & 0 deletions consensus/bor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,56 @@ func (api *API) GetAuthor(number *rpc.BlockNumber) (*common.Address, error) {
return &author, err
}

type BlockSigners struct {
Signers map[common.Address]uint64
Diff int
Author common.Address
}

// GetSnapshotProposerSequence retrieves the in-turn signers of all sprints in a span
func (api *API) GetSnapshotProposerSequence(number *rpc.BlockNumber) (BlockSigners, error) {

var difficulties = make(map[common.Address]uint64)
snap, err := api.GetSnapshot(number)
if err != nil {
return BlockSigners{}, err
}
proposer := snap.ValidatorSet.GetProposer().Address
proposerIndex, _ := snap.ValidatorSet.GetByAddress(proposer)

signers := snap.signers()
for i := 0; i < len(signers); i++ {
tempIndex := i
if tempIndex < proposerIndex {
tempIndex = tempIndex + len(signers)
}
difficulties[signers[i]] = uint64(len(signers) - (tempIndex - proposerIndex))
}

author, err := api.GetAuthor(number)
if err != nil {
return BlockSigners{}, err
}
diff := int(difficulties[*author])
blockSigners := &BlockSigners{
Signers: difficulties,
Diff: diff,
Author: *author,
}

return *blockSigners, nil
}

// GetSnapshotProposer retrieves the in-turn signer at a given block.
func (api *API) GetSnapshotProposer(number *rpc.BlockNumber) (common.Address, error) {
*number -= 1
snap, err := api.GetSnapshot(number)
if err != nil {
return common.Address{}, err
}
return snap.ValidatorSet.GetProposer().Address, nil
}

// GetSnapshotAtHash retrieves the state snapshot at a given block.
func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) {
header := api.chain.GetHeaderByHash(hash)
Expand Down
4 changes: 2 additions & 2 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func (c *Bor) verifySeal(chain consensus.ChainHeaderReader, header *types.Header
if err != nil {
return err
}
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
if !snap.ValidatorSet.HasAddress(signer) {
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, signer.Bytes()}
}
Expand Down Expand Up @@ -835,7 +835,7 @@ func (c *Bor) Seal(chain consensus.ChainHeaderReader, block *types.Block, result
}

// Bail out if we're unauthorized to sign a block
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
if !snap.ValidatorSet.HasAddress(signer) {
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, signer.Bytes()}
}
Expand Down
6 changes: 4 additions & 2 deletions consensus/bor/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ func loadSnapshot(config *params.BorConfig, sigcache *lru.ARCCache, db ethdb.Dat
if err := json.Unmarshal(blob, snap); err != nil {
return nil, err
}

snap.ValidatorSet.UpdateValidatorMap()
snap.config = config
snap.sigcache = sigcache
snap.ethAPI = ethAPI

// update total voting power
if err := snap.ValidatorSet.updateTotalVotingPower(); err != nil {
if err := snap.ValidatorSet.UpdateTotalVotingPower(); err != nil {
return nil, err
}

Expand Down Expand Up @@ -137,7 +139,7 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
}

// check if signer is in validator set
if !snap.ValidatorSet.HasAddress(signer.Bytes()) {
if !snap.ValidatorSet.HasAddress(signer) {
return nil, &UnauthorizedSignerError{number, signer.Bytes()}
}

Expand Down
Loading
Loading