good morning!!!!

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • github/maticnetwork/bor
  • open/bor
2 results
Show changes
Showing
with 118 additions and 21 deletions
...@@ -8,3 +8,16 @@ import ( ...@@ -8,3 +8,16 @@ import (
type StateSyncEvent struct { type StateSyncEvent struct {
Data *types.StateSyncData Data *types.StateSyncData
} }
var (
Chain2HeadReorgEvent = "reorg"
Chain2HeadCanonicalEvent = "head"
Chain2HeadForkEvent = "fork"
)
// For tracking reorgs related information
type Chain2HeadEvent struct {
NewChain []*types.Block
OldChain []*types.Block
Type string
}
...@@ -151,8 +151,10 @@ func newFreezer(datadir string, namespace string, readonly bool, maxTableSize ui ...@@ -151,8 +151,10 @@ func newFreezer(datadir string, namespace string, readonly bool, maxTableSize ui
// This way they don't have to sync again from block 0 and still be compatible // This way they don't have to sync again from block 0 and still be compatible
// for block logs for future blocks. Note that already synced nodes // for block logs for future blocks. Note that already synced nodes
// won't have past block logs. Newly synced node will have all the data. // won't have past block logs. Newly synced node will have all the data.
if err := freezer.tables[freezerBorReceiptTable].Fill(freezer.tables[freezerHeaderTable].items); err != nil { if _, ok := freezer.tables[freezerBorReceiptTable]; ok {
return nil, err if err := freezer.tables[freezerBorReceiptTable].Fill(freezer.tables[freezerHeaderTable].items); err != nil {
return nil, err
}
} }
// Truncate all tables to common length. // Truncate all tables to common length.
......
...@@ -53,6 +53,7 @@ func TestStateProcessorErrors(t *testing.T) { ...@@ -53,6 +53,7 @@ func TestStateProcessorErrors(t *testing.T) {
BerlinBlock: big.NewInt(0), BerlinBlock: big.NewInt(0),
LondonBlock: big.NewInt(0), LondonBlock: big.NewInt(0),
Ethash: new(params.EthashConfig), Ethash: new(params.EthashConfig),
Bor: &params.BorConfig{BurntContract: map[string]string{"0": "0x000000000000000000000000000000000000dead"}},
} }
signer = types.LatestSigner(config) signer = types.LatestSigner(config)
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
......
...@@ -337,6 +337,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { ...@@ -337,6 +337,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee)) effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
} }
amount := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip) amount := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip)
if london {
burntContractAddress := common.HexToAddress(st.evm.ChainConfig().Bor.CalculateBurntContract(st.evm.Context.BlockNumber.Uint64()))
burnAmount := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee)
st.state.AddBalance(burntContractAddress, burnAmount)
}
st.state.AddBalance(st.evm.Context.Coinbase, amount) st.state.AddBalance(st.evm.Context.Coinbase, amount)
output1 := new(big.Int).SetBytes(input1.Bytes()) output1 := new(big.Int).SetBytes(input1.Bytes())
output2 := new(big.Int).SetBytes(input2.Bytes()) output2 := new(big.Int).SetBytes(input2.Bytes())
......
...@@ -19,18 +19,4 @@ $ bor server ...@@ -19,18 +19,4 @@ $ bor server
$ bor server --config ./legacy.toml $ bor server --config ./legacy.toml
``` ```
- Modules, vhost and Cors configuration are common for all jsonrpc endpoints.
Before:
```
$ bor --http --http.modules "eth,web" --ws --ws.modules "eth,web"
```
Now:
```
$ bor server --http --ws --jsonrpc.modules "eth,web"
```
- ```Admin```, ```Personal``` and account related endpoints in ```Eth``` are being removed from the JsonRPC interface. Some of this functionality will be moved to the new GRPC server for operational tasks. - ```Admin```, ```Personal``` and account related endpoints in ```Eth``` are being removed from the JsonRPC interface. Some of this functionality will be moved to the new GRPC server for operational tasks.
...@@ -15,4 +15,22 @@ ...@@ -15,4 +15,22 @@
- [```account import```](./account_import.md) - [```account import```](./account_import.md)
- [```chain```](./chain.md)
- [```chain sethead```](./chain_sethead.md)
- [```peers```](./peers.md)
- [```peers add```](./peers_add.md)
- [```peers list```](./peers_list.md)
- [```peers remove```](./peers_remove.md)
- [```peers status```](./peers_status.md)
- [```status```](./status.md)
- [```chain watch```](./chain_watch.md)
- [```version```](./version.md) - [```version```](./version.md)
# Chain
The ```chain``` command groups actions to interact with the blockchain in the client:
- [```chain sethead```](./chain_sethead.md): Set the current chain to a certain block.
# Chain sethead
The ```chain sethead <number>``` command sets the current chain to a certain block.
## Arguments
- ```number```: The block number to roll back.
## Options
- ```yes```: Force set head.
# Chain watch
The ```chain watch``` command is used to view the chainHead, reorg and fork events in real-time.
# Peers
The ```peers``` command groups actions to interact with peers:
- [```peers add```](./peers_add.md): Joins the local client to another remote peer.
- [```peers list```](./peers_list.md): Lists the connected peers to the Bor client.
- [```peers remove```](./peers_remove.md): Disconnects the local client from a connected peer if exists.
- [```peers status```](./peers_status.md): Display the status of a peer by its id.
# Peers add
The ```peers add <enode>``` command joins the local client to another remote peer.
## Arguments
- ```trusted```: Whether the peer is added as a trusted peer.
# Peers list
The ```peers list``` command lists the connected peers.
# Peers remove
The ```peers remove <enode>``` command disconnects the local client from a connected peer if exists.
# Peers status
The ```peers status <peer id>``` command displays the status of a peer by its id.
...@@ -109,8 +109,6 @@ The ```bor server``` command runs the Bor client. ...@@ -109,8 +109,6 @@ The ```bor server``` command runs the Bor client.
- ```jsonrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. - ```jsonrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```jsonrpc.modules```: API's offered over the HTTP-RPC interface.
- ```http```: Enable the HTTP-RPC server. - ```http```: Enable the HTTP-RPC server.
- ```http.addr```: HTTP-RPC server listening interface. - ```http.addr```: HTTP-RPC server listening interface.
...@@ -119,6 +117,8 @@ The ```bor server``` command runs the Bor client. ...@@ -119,6 +117,8 @@ The ```bor server``` command runs the Bor client.
- ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths. - ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```http.modules```: API's offered over the HTTP-RPC interface.
- ```ws```: Enable the WS-RPC server. - ```ws```: Enable the WS-RPC server.
- ```ws.addr```: WS-RPC server listening interface. - ```ws.addr```: WS-RPC server listening interface.
...@@ -127,6 +127,8 @@ The ```bor server``` command runs the Bor client. ...@@ -127,6 +127,8 @@ The ```bor server``` command runs the Bor client.
- ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths. - ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```ws.modules```: API's offered over the WS-RPC interface.
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well. - ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.
### P2P Options ### P2P Options
......
# Status
The ```status``` command outputs the status of the client.
...@@ -581,10 +581,12 @@ func (s *Ethereum) Stop() error { ...@@ -581,10 +581,12 @@ func (s *Ethereum) Stop() error {
// Then stop everything else. // Then stop everything else.
s.bloomIndexer.Close() s.bloomIndexer.Close()
close(s.closeBloomHandler) close(s.closeBloomHandler)
// closing consensus engine first, as miner has deps on it
s.engine.Close()
s.txPool.Stop() s.txPool.Stop()
s.miner.Close()
s.blockchain.Stop() s.blockchain.Stop()
s.engine.Close() s.miner.Close()
rawdb.PopUncleanShutdownMarker(s.chainDb) rawdb.PopUncleanShutdownMarker(s.chainDb)
s.chainDb.Close() s.chainDb.Close()
s.eventMux.Stop() s.eventMux.Stop()
......
...@@ -67,3 +67,8 @@ func (b *EthAPIBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context, ...@@ -67,3 +67,8 @@ func (b *EthAPIBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context,
func (b *EthAPIBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription { func (b *EthAPIBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription {
return b.eth.BlockChain().SubscribeStateSyncEvent(ch) return b.eth.BlockChain().SubscribeStateSyncEvent(ch)
} }
// SubscribeChain2HeadEvent subscribes to reorg/head/fork event
func (b *EthAPIBackend) SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription {
return b.eth.BlockChain().SubscribeChain2HeadEvent(ch)
}
...@@ -110,6 +110,8 @@ func generateTestChainWithFork(n int, fork int) (*core.Genesis, []*types.Block, ...@@ -110,6 +110,8 @@ func generateTestChainWithFork(n int, fork int) (*core.Genesis, []*types.Block,
*/ */
func TestEth2AssembleBlock(t *testing.T) { func TestEth2AssembleBlock(t *testing.T) {
t.Skip("bor due to burn contract")
genesis, blocks := generateTestChain() genesis, blocks := generateTestChain()
n, ethservice := startEthService(t, genesis, blocks[1:9]) n, ethservice := startEthService(t, genesis, blocks[1:9])
defer n.Close() defer n.Close()
...@@ -137,6 +139,8 @@ func TestEth2AssembleBlock(t *testing.T) { ...@@ -137,6 +139,8 @@ func TestEth2AssembleBlock(t *testing.T) {
} }
func TestEth2AssembleBlockWithAnotherBlocksTxs(t *testing.T) { func TestEth2AssembleBlockWithAnotherBlocksTxs(t *testing.T) {
t.Skip("bor due to burn contract")
genesis, blocks := generateTestChain() genesis, blocks := generateTestChain()
n, ethservice := startEthService(t, genesis, blocks[1:9]) n, ethservice := startEthService(t, genesis, blocks[1:9])
defer n.Close() defer n.Close()
......
...@@ -229,7 +229,9 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et ...@@ -229,7 +229,9 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
return clique.New(chainConfig.Clique, db) return clique.New(chainConfig.Clique, db)
} }
// If Matic bor consensus is requested, set it up // If Matic bor consensus is requested, set it up
if chainConfig.Bor != nil { // In order to pass the ethereum transaction tests, we need to set the burn contract which is in the bor config
// Then, bor != nil will also be enabled for ethash and clique. Only enable Bor for real if there is a validator contract present.
if chainConfig.Bor != nil && chainConfig.Bor.ValidatorContract != "" {
return bor.New(chainConfig, db, blockchainAPI, ethConfig.HeimdallURL, ethConfig.WithoutHeimdall) return bor.New(chainConfig, db, blockchainAPI, ethConfig.HeimdallURL, ethConfig.WithoutHeimdall)
} }
// Otherwise assume proof-of-work // Otherwise assume proof-of-work
......