Skip to content

Commit

Permalink
Merge pull request #33 from blocknative/0.3.3
Browse files Browse the repository at this point in the history
merge upstream 0.3.3
  • Loading branch information
ayazabbas authored Jan 12, 2023
2 parents 09afddc + f02366a commit 976709f
Show file tree
Hide file tree
Showing 43 changed files with 554 additions and 262 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/packager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ jobs:
- name: Removing systemd file
run: rm -rf packaging/deb/bor/lib/systemd/system/bor.service

- name: Updating the apt-get
run: sudo apt-get update -y

- name: Adding requirements for cross compile
run: sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu

Expand Down Expand Up @@ -730,4 +733,4 @@ jobs:
prerelease: true
files: |
packaging/deb/bor**.deb
binary/bo**
binary/bo**
7 changes: 5 additions & 2 deletions builder/files/genesis-mainnet-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
"londonBlock": 23850000,
"bor": {
"jaipurBlock": 23850000,
"delhiBlock": 38189056,
"period": {
"0": 2
},
"producerDelay": {
"0": 6
"0": 6,
"38189056": 4
},
"sprint": {
"0": 64
"0": 64,
"38189056": 16
},
"backupMultiplier": {
"0": 2
Expand Down
6 changes: 6 additions & 0 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var (
snapshotStorageReadTimer = metrics.NewRegisteredTimer("chain/snapshot/storage/reads", nil)
snapshotCommitTimer = metrics.NewRegisteredTimer("chain/snapshot/commits", nil)

blockImportTimer = metrics.NewRegisteredMeter("chain/imports", nil)
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil)
blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil)
Expand Down Expand Up @@ -1518,6 +1519,11 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals, setHead bool)
it := newInsertIterator(chain, results, bc.validator)
block, err := it.next()

// Update the block import meter; it will just record chains we've received
// from other peers. (Note that the actual chain which gets imported would be
// quite low).
blockImportTimer.Mark(int64(len(headers)))

// Check the validity of incoming chain
isValid, err1 := bc.forker.ValidateReorg(bc.CurrentBlock().Header(), headers)
if err1 != nil {
Expand Down
4 changes: 1 addition & 3 deletions core/forkchoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ func (f *ForkChoice) ReorgNeeded(current *types.Header, header *types.Header) (b
func (f *ForkChoice) ValidateReorg(current *types.Header, chain []*types.Header) (bool, error) {
// Call the bor chain validator service
if f.validator != nil {
if isValid := f.validator.IsValidChain(current, chain); !isValid {
return false, nil
}
return f.validator.IsValidChain(current, chain)
}

return true, nil
Expand Down
30 changes: 15 additions & 15 deletions core/forkchoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import (

// chainValidatorFake is a mock for the chain validator service
type chainValidatorFake struct {
validate func(currentHeader *types.Header, chain []*types.Header) bool
validate func(currentHeader *types.Header, chain []*types.Header) (bool, error)
}

// chainReaderFake is a mock for the chain reader service
type chainReaderFake struct {
getTd func(hash common.Hash, number uint64) *big.Int
}

func newChainValidatorFake(validate func(currentHeader *types.Header, chain []*types.Header) bool) *chainValidatorFake {
func newChainValidatorFake(validate func(currentHeader *types.Header, chain []*types.Header) (bool, error)) *chainValidatorFake {
return &chainValidatorFake{validate: validate}
}

Expand All @@ -46,18 +46,18 @@ func TestPastChainInsert(t *testing.T) {
getTd := func(hash common.Hash, number uint64) *big.Int {
return big.NewInt(int64(number))
}
validate := func(currentHeader *types.Header, chain []*types.Header) bool {
validate := func(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Put all explicit conditions here
// If canonical chain is empty and we're importing a chain of 64 blocks
if currentHeader.Number.Uint64() == uint64(0) && len(chain) == 64 {
return true
return true, nil
}
// If canonical chain is of len 64 and we're importing a past chain from 54-64, then accept it
if currentHeader.Number.Uint64() == uint64(64) && chain[0].Number.Uint64() == 55 && len(chain) == 10 {
return true
return true, nil
}

return false
return false, nil
}
mockChainReader := newChainReaderFake(getTd)
mockChainValidator := newChainValidatorFake(validate)
Expand Down Expand Up @@ -116,18 +116,18 @@ func TestFutureChainInsert(t *testing.T) {
getTd := func(hash common.Hash, number uint64) *big.Int {
return big.NewInt(int64(number))
}
validate := func(currentHeader *types.Header, chain []*types.Header) bool {
validate := func(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Put all explicit conditions here
// If canonical chain is empty and we're importing a chain of 64 blocks
if currentHeader.Number.Uint64() == uint64(0) && len(chain) == 64 {
return true
return true, nil
}
// If length of future chains > some value, they should not be accepted
if currentHeader.Number.Uint64() == uint64(64) && len(chain) <= 10 {
return true
return true, nil
}

return false
return false, nil
}
mockChainReader := newChainReaderFake(getTd)
mockChainValidator := newChainValidatorFake(validate)
Expand Down Expand Up @@ -174,18 +174,18 @@ func TestOverlappingChainInsert(t *testing.T) {
getTd := func(hash common.Hash, number uint64) *big.Int {
return big.NewInt(int64(number))
}
validate := func(currentHeader *types.Header, chain []*types.Header) bool {
validate := func(currentHeader *types.Header, chain []*types.Header) (bool, error) {
// Put all explicit conditions here
// If canonical chain is empty and we're importing a chain of 64 blocks
if currentHeader.Number.Uint64() == uint64(0) && len(chain) == 64 {
return true
return true, nil
}
// If length of chain is > some fixed value then don't accept it
if currentHeader.Number.Uint64() == uint64(64) && len(chain) <= 20 {
return true
return true, nil
}

return false
return false, nil
}
mockChainReader := newChainReaderFake(getTd)
mockChainValidator := newChainValidatorFake(validate)
Expand Down Expand Up @@ -227,7 +227,7 @@ func (c *chainReaderFake) GetTd(hash common.Hash, number uint64) *big.Int {
func (w *chainValidatorFake) IsValidPeer(remoteHeader *types.Header, fetchHeadersByNumber func(number uint64, amount int, skip int, reverse bool) ([]*types.Header, []common.Hash, error)) (bool, error) {
return true, nil
}
func (w *chainValidatorFake) IsValidChain(current *types.Header, headers []*types.Header) bool {
func (w *chainValidatorFake) IsValidChain(current *types.Header, headers []*types.Header) (bool, error) {
return w.validate(current, headers)
}
func (w *chainValidatorFake) ProcessCheckpoint(endBlockNum uint64, endBlockHash common.Hash) {}
Expand Down
4 changes: 3 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Documentation

- [The new command line interface](./cli)
[The new command line interface (CLI)](./cli) in this version of Bor aims to give users more control over the codebase when interacting with and starting a node. We have made every effort to keep most of the flags similar to the old CLI, except for a few notable changes. One major change is the use of the --config flag, which previously represented fields without available flags. It now represents all flags available to the user, and will overwrite any other flags if provided. As a node operator, you still have the flexibility to modify flags as needed. Please note that this change does not affect the internal functionality of the node, and it remains compatible with Geth and the Ethereum Virtual Machine (EVM).

## Additional notes

Expand All @@ -11,6 +11,8 @@
$ bor server <flags>
```

See [here](./cli/server.md) for more flag details.

- The `bor dumpconfig` sub-command prints the default configurations, in the TOML format, on the terminal. One can `pipe (>)` this to a file (say `config.toml`) and use it to start bor.

- A toml file now can be used instead of flags and can contain all configuration for the node to run. To simply run bor with a configuration file, the following command can be used.
Expand Down
4 changes: 4 additions & 0 deletions docs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@

- [```server```](./server.md)

- [```snapshot```](./snapshot.md)

- [```snapshot prune-state```](./snapshot_prune-state.md)

- [```status```](./status.md)

- [```version```](./version.md)
2 changes: 1 addition & 1 deletion docs/cli/account_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ The ```account import``` command imports an account in Json format to the Bor da

- ```datadir```: Path of the data directory to store information

- ```keystore```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys
2 changes: 1 addition & 1 deletion docs/cli/account_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ The `account list` command lists all the accounts in the Bor data directory.

- ```datadir```: Path of the data directory to store information

- ```keystore```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys
2 changes: 1 addition & 1 deletion docs/cli/account_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ The `account new` command creates a new local account file on the Bor data direc

- ```datadir```: Path of the data directory to store information

- ```keystore```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store keys
10 changes: 5 additions & 5 deletions docs/cli/bootnode.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

## Options

- ```listen-addr```: listening address of bootnode (<ip>:<port>)
- ```listen-addr```: listening address of bootnode (<ip>:<port>) (default: 0.0.0.0:30303)

- ```v5```: Enable UDP v5
- ```v5```: Enable UDP v5 (default: false)

- ```log-level```: Log level (trace|debug|info|warn|error|crit)
- ```log-level```: Log level (trace|debug|info|warn|error|crit) (default: info)

- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: none)

- ```node-key```: file or hex node key

- ```save-key```: path to save the ecdsa private key

- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode
- ```dry-run```: validates parameters and prints bootnode configurations, but does not start bootnode (default: false)
4 changes: 2 additions & 2 deletions docs/cli/chain_sethead.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ The ```chain sethead <number>``` command sets the current chain to a certain blo

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```yes```: Force set head
- ```yes```: Force set head (default: false)
2 changes: 1 addition & 1 deletion docs/cli/debug_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The ```bor debug block <number>``` command will create an archive containing tra

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```output```: Output directory
4 changes: 2 additions & 2 deletions docs/cli/debug_pprof.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ The ```debug pprof <enode>``` command will create an archive containing bor ppro

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```seconds```: seconds to trace
- ```seconds```: seconds to trace (default: 2)

- ```output```: Output directory
4 changes: 2 additions & 2 deletions docs/cli/peers_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The ```peers add <enode>``` command joins the local client to another remote pee

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```trusted```: Add the peer as a trusted
- ```trusted```: Add the peer as a trusted (default: false)
2 changes: 1 addition & 1 deletion docs/cli/peers_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The ```peers list``` command lists the connected peers.

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
4 changes: 2 additions & 2 deletions docs/cli/peers_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The ```peers remove <enode>``` command disconnects the local client from a conne

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```trusted```: Add the peer as a trusted
- ```trusted```: Add the peer as a trusted (default: false)
2 changes: 1 addition & 1 deletion docs/cli/peers_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ The ```peers status <peer id>``` command displays the status of a peer by its id

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
2 changes: 1 addition & 1 deletion docs/cli/removedb.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ The ```bor removedb``` command will remove the blockchain and state databases at

## Options

- ```address```: Address of the grpc endpoint
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)

- ```datadir```: Path of the data directory to store information
Loading

0 comments on commit 976709f

Please sign in to comment.