mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
added hardfork checks (#666)
This commit is contained in:
parent
6f16d006fd
commit
4968c08246
3 changed files with 40 additions and 15 deletions
|
|
@ -89,10 +89,6 @@ const (
|
|||
|
||||
// staleThreshold is the maximum depth of the acceptable stale block.
|
||||
staleThreshold = 7
|
||||
|
||||
// TODO: will be handled (and made mandatory) in a hardfork event
|
||||
// when true, will get the transaction dependencies for parallel execution, also set in `state_processor.go`
|
||||
EnableMVHashMap = true
|
||||
)
|
||||
|
||||
// metrics gauge to track total and empty blocks sealed by a miner
|
||||
|
|
@ -965,6 +961,14 @@ func (w *worker) commitTransactions(env *environment, txs *types.TransactionsByP
|
|||
|
||||
var depsWg sync.WaitGroup
|
||||
|
||||
var EnableMVHashMap bool
|
||||
|
||||
if w.chainConfig.Bor.IsParallelUniverse(env.header.Number) {
|
||||
EnableMVHashMap = true
|
||||
} else {
|
||||
EnableMVHashMap = false
|
||||
}
|
||||
|
||||
// create and add empty mvHashMap in statedb
|
||||
if EnableMVHashMap {
|
||||
depsMVReadList = [][]blockstm.ReadDescriptor{}
|
||||
|
|
|
|||
|
|
@ -716,6 +716,8 @@ func BenchmarkBorMining(b *testing.B) {
|
|||
}
|
||||
|
||||
// uses core.NewParallelBlockChain to use the dependencies present in the block header
|
||||
// params.BorUnittestChainConfig contains the ParallelUniverseBlock ad big.NewInt(5), so the first 4 blocks will not have metadata.
|
||||
// nolint: gocognit
|
||||
func BenchmarkBorMiningBlockSTMMetadata(b *testing.B) {
|
||||
chainConfig := params.BorUnittestChainConfig
|
||||
|
||||
|
|
@ -810,11 +812,17 @@ func BenchmarkBorMiningBlockSTMMetadata(b *testing.B) {
|
|||
b.Fatalf("failed to insert new mined block %d: %v", block.NumberU64(), err)
|
||||
}
|
||||
|
||||
// check for dependencies
|
||||
deps := block.TxDependency()
|
||||
for i := 1; i < block.Transactions().Len(); i++ {
|
||||
if deps[i][0] != uint64(i) || deps[i][1] != uint64(0) || deps[i][2] != uint64(i-1) || len(deps[i]) != 3 {
|
||||
b.Fatalf("wrong dependency")
|
||||
// check for dependencies for block number > 4
|
||||
if block.NumberU64() <= 4 {
|
||||
if block.TxDependency() != nil {
|
||||
b.Fatalf("dependency not nil")
|
||||
}
|
||||
} else {
|
||||
deps := block.TxDependency()
|
||||
for i := 1; i < block.Transactions().Len(); i++ {
|
||||
if deps[i][0] != uint64(i) || deps[i][1] != uint64(0) || deps[i][2] != uint64(i-1) || len(deps[i]) != 3 {
|
||||
b.Fatalf("wrong dependency")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ var (
|
|||
BerlinBlock: big.NewInt(0),
|
||||
LondonBlock: big.NewInt(0),
|
||||
Bor: &BorConfig{
|
||||
ParallelUniverseBlock: big.NewInt(5),
|
||||
Period: map[string]uint64{
|
||||
"0": 1,
|
||||
},
|
||||
|
|
@ -349,8 +350,9 @@ var (
|
|||
BerlinBlock: big.NewInt(13996000),
|
||||
LondonBlock: big.NewInt(22640000),
|
||||
Bor: &BorConfig{
|
||||
JaipurBlock: big.NewInt(22770000),
|
||||
DelhiBlock: big.NewInt(29638656),
|
||||
JaipurBlock: big.NewInt(22770000),
|
||||
DelhiBlock: big.NewInt(29638656),
|
||||
ParallelUniverseBlock: big.NewInt(0),
|
||||
Period: map[string]uint64{
|
||||
"0": 2,
|
||||
"25275000": 5,
|
||||
|
|
@ -403,7 +405,8 @@ var (
|
|||
BerlinBlock: big.NewInt(14750000),
|
||||
LondonBlock: big.NewInt(23850000),
|
||||
Bor: &BorConfig{
|
||||
JaipurBlock: big.NewInt(23850000),
|
||||
JaipurBlock: big.NewInt(23850000),
|
||||
ParallelUniverseBlock: big.NewInt(0),
|
||||
Period: map[string]uint64{
|
||||
"0": 2,
|
||||
},
|
||||
|
|
@ -580,9 +583,10 @@ type BorConfig struct {
|
|||
StateReceiverContract string `json:"stateReceiverContract"` // State receiver contract
|
||||
OverrideStateSyncRecords map[string]int `json:"overrideStateSyncRecords"` // override state records count
|
||||
BlockAlloc map[string]interface{} `json:"blockAlloc"`
|
||||
BurntContract map[string]string `json:"burntContract"` // governance contract where the token will be sent to and burnt in london fork
|
||||
JaipurBlock *big.Int `json:"jaipurBlock"` // Jaipur switch block (nil = no fork, 0 = already on jaipur)
|
||||
DelhiBlock *big.Int `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi)
|
||||
BurntContract map[string]string `json:"burntContract"` // governance contract where the token will be sent to and burnt in london fork
|
||||
JaipurBlock *big.Int `json:"jaipurBlock"` // Jaipur switch block (nil = no fork, 0 = already on jaipur)
|
||||
DelhiBlock *big.Int `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi)
|
||||
ParallelUniverseBlock *big.Int `json:"parallelUniverseBlock"` // TODO: update all occurrence, change name and finalize number (hardfork for block-stm related changes)
|
||||
}
|
||||
|
||||
// String implements the stringer interface, returning the consensus engine details.
|
||||
|
|
@ -614,6 +618,15 @@ func (c *BorConfig) IsDelhi(number *big.Int) bool {
|
|||
return isForked(c.DelhiBlock, number)
|
||||
}
|
||||
|
||||
// TODO: modify this function once the block number is finalized
|
||||
func (c *BorConfig) IsParallelUniverse(number *big.Int) bool {
|
||||
if c.ParallelUniverseBlock == big.NewInt(0) {
|
||||
return false
|
||||
}
|
||||
|
||||
return isForked(c.ParallelUniverseBlock, number)
|
||||
}
|
||||
|
||||
func (c *BorConfig) calculateBorConfigHelper(field map[string]uint64, number uint64) uint64 {
|
||||
keys := make([]string, 0, len(field))
|
||||
for k := range field {
|
||||
|
|
|
|||
Loading…
Reference in a new issue