mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
Changed parallel universe HF to Cancun HF and some important fixes (#1132)
* changed parallel universe HF to napoli HF
* integration-tests: update ipc path on ci tests (#1127)
* integration-tests: update ipc path on ci tests
* added devnetBorFlags in matic-cli-config.yml
---------
Co-authored-by: Pratik Patil <pratikspatil024@gmail.com>
* Revert "integration-tests: update ipc path on ci tests (#1127)"
This reverts commit 0660fac39b.
* using cancun for block-stm metadata instead of napoli
* added a check to verify tx dependencies and test cases
* fix in snapshot.chainConfig
* removed snapshot.*params.BorConfig using snapshot.chainConfig.Bor instead
* removed unnecessary if statement in ParallelStateProcessor.Process
* addressed comment
* small fix in commitTransactions
* dependency calculation bug fix in miner/worker.go
---------
Co-authored-by: Manav Darji <manavdarji.india@gmail.com>
Co-authored-by: Arpit Temani <temaniarpit27@gmail.com>
This commit is contained in:
parent
c559619c80
commit
f1e0b1d926
15 changed files with 148 additions and 138 deletions
|
|
@ -17,7 +17,6 @@
|
||||||
"bor": {
|
"bor": {
|
||||||
"jaipurBlock": 23850000,
|
"jaipurBlock": 23850000,
|
||||||
"delhiBlock": 38189056,
|
"delhiBlock": 38189056,
|
||||||
"parallelUniverseBlock": 0,
|
|
||||||
"indoreBlock": 44934656,
|
"indoreBlock": 44934656,
|
||||||
"stateSyncConfirmationDelay": {
|
"stateSyncConfirmationDelay": {
|
||||||
"44934656": 128
|
"44934656": 128
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
"bor": {
|
"bor": {
|
||||||
"jaipurBlock": 22770000,
|
"jaipurBlock": 22770000,
|
||||||
"delhiBlock": 29638656,
|
"delhiBlock": 29638656,
|
||||||
"parallelUniverseBlock": 0,
|
|
||||||
"indoreBlock": 37075456,
|
"indoreBlock": 37075456,
|
||||||
"stateSyncConfirmationDelay": {
|
"stateSyncConfirmationDelay": {
|
||||||
"37075456": 128
|
"37075456": 128
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head
|
||||||
isSprintEnd := IsSprintStart(number+1, c.config.CalculateSprint(number))
|
isSprintEnd := IsSprintStart(number+1, c.config.CalculateSprint(number))
|
||||||
|
|
||||||
// Ensure that the extra-data contains a signer list on checkpoint, but none otherwise
|
// Ensure that the extra-data contains a signer list on checkpoint, but none otherwise
|
||||||
signersBytes := len(header.GetValidatorBytes(c.config))
|
signersBytes := len(header.GetValidatorBytes(c.chainConfig))
|
||||||
|
|
||||||
if !isSprintEnd && signersBytes != 0 {
|
if !isSprintEnd && signersBytes != 0 {
|
||||||
return errExtraValidators
|
return errExtraValidators
|
||||||
|
|
@ -472,7 +472,7 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
|
||||||
|
|
||||||
sort.Sort(valset.ValidatorsByAddress(newValidators))
|
sort.Sort(valset.ValidatorsByAddress(newValidators))
|
||||||
|
|
||||||
headerVals, err := valset.ParseValidators(header.GetValidatorBytes(c.config))
|
headerVals, err := valset.ParseValidators(header.GetValidatorBytes(c.chainConfig))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -490,7 +490,7 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainHeaderReader, header *t
|
||||||
|
|
||||||
// verify the validator list in the last sprint block
|
// verify the validator list in the last sprint block
|
||||||
if IsSprintStart(number, c.config.CalculateSprint(number)) {
|
if IsSprintStart(number, c.config.CalculateSprint(number)) {
|
||||||
parentValidatorBytes := parent.GetValidatorBytes(c.config)
|
parentValidatorBytes := parent.GetValidatorBytes(c.chainConfig)
|
||||||
validatorsBytes := make([]byte, len(snap.ValidatorSet.Validators)*validatorHeaderBytesLength)
|
validatorsBytes := make([]byte, len(snap.ValidatorSet.Validators)*validatorHeaderBytesLength)
|
||||||
|
|
||||||
currentValidators := snap.ValidatorSet.Copy().Validators
|
currentValidators := snap.ValidatorSet.Copy().Validators
|
||||||
|
|
@ -521,7 +521,7 @@ func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash co
|
||||||
val := valset.NewValidator(signer, 1000)
|
val := valset.NewValidator(signer, 1000)
|
||||||
validatorset := valset.NewValidatorSet([]*valset.Validator{val})
|
validatorset := valset.NewValidatorSet([]*valset.Validator{val})
|
||||||
|
|
||||||
snapshot := newSnapshot(c.config, c.signatures, number, hash, validatorset.Validators)
|
snapshot := newSnapshot(c.chainConfig, c.signatures, number, hash, validatorset.Validators)
|
||||||
|
|
||||||
return snapshot, nil
|
return snapshot, nil
|
||||||
}
|
}
|
||||||
|
|
@ -541,7 +541,7 @@ func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash co
|
||||||
|
|
||||||
// If an on-disk checkpoint snapshot can be found, use that
|
// If an on-disk checkpoint snapshot can be found, use that
|
||||||
if number%checkpointInterval == 0 {
|
if number%checkpointInterval == 0 {
|
||||||
if s, err := loadSnapshot(c.config, c.signatures, c.db, hash); err == nil {
|
if s, err := loadSnapshot(c.chainConfig, c.config, c.signatures, c.db, hash); err == nil {
|
||||||
log.Trace("Loaded snapshot from disk", "number", number, "hash", hash)
|
log.Trace("Loaded snapshot from disk", "number", number, "hash", hash)
|
||||||
|
|
||||||
snap = s
|
snap = s
|
||||||
|
|
@ -570,7 +570,7 @@ func (c *Bor) snapshot(chain consensus.ChainHeaderReader, number uint64, hash co
|
||||||
}
|
}
|
||||||
|
|
||||||
// new snap shot
|
// new snap shot
|
||||||
snap = newSnapshot(c.config, c.signatures, number, hash, validators)
|
snap = newSnapshot(c.chainConfig, c.signatures, number, hash, validators)
|
||||||
if err := snap.store(c.db); err != nil {
|
if err := snap.store(c.db); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -742,7 +742,7 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e
|
||||||
// sort validator by address
|
// sort validator by address
|
||||||
sort.Sort(valset.ValidatorsByAddress(newValidators))
|
sort.Sort(valset.ValidatorsByAddress(newValidators))
|
||||||
|
|
||||||
if c.config.IsParallelUniverse(header.Number) {
|
if c.chainConfig.IsCancun(header.Number) {
|
||||||
var tempValidatorBytes []byte
|
var tempValidatorBytes []byte
|
||||||
|
|
||||||
for _, validator := range newValidators {
|
for _, validator := range newValidators {
|
||||||
|
|
@ -766,7 +766,7 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e
|
||||||
header.Extra = append(header.Extra, validator.HeaderBytes()...)
|
header.Extra = append(header.Extra, validator.HeaderBytes()...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if c.config.IsParallelUniverse(header.Number) {
|
} else if c.chainConfig.IsCancun(header.Number) {
|
||||||
blockExtraData := &types.BlockExtraData{
|
blockExtraData := &types.BlockExtraData{
|
||||||
ValidatorBytes: nil,
|
ValidatorBytes: nil,
|
||||||
TxDependency: nil,
|
TxDependency: nil,
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ import (
|
||||||
|
|
||||||
// Snapshot is the state of the authorization voting at a given point in time.
|
// Snapshot is the state of the authorization voting at a given point in time.
|
||||||
type Snapshot struct {
|
type Snapshot struct {
|
||||||
config *params.BorConfig // Consensus engine parameters to fine tune behavior
|
chainConfig *params.ChainConfig
|
||||||
|
|
||||||
sigcache *lru.ARCCache // Cache of recent block signatures to speed up ecrecover
|
sigcache *lru.ARCCache // Cache of recent block signatures to speed up ecrecover
|
||||||
|
|
||||||
Number uint64 `json:"number"` // Block number where the snapshot was created
|
Number uint64 `json:"number"` // Block number where the snapshot was created
|
||||||
|
|
@ -28,14 +29,14 @@ type Snapshot struct {
|
||||||
// method does not initialize the set of recent signers, so only ever use if for
|
// method does not initialize the set of recent signers, so only ever use if for
|
||||||
// the genesis block.
|
// the genesis block.
|
||||||
func newSnapshot(
|
func newSnapshot(
|
||||||
config *params.BorConfig,
|
chainConfig *params.ChainConfig,
|
||||||
sigcache *lru.ARCCache,
|
sigcache *lru.ARCCache,
|
||||||
number uint64,
|
number uint64,
|
||||||
hash common.Hash,
|
hash common.Hash,
|
||||||
validators []*valset.Validator,
|
validators []*valset.Validator,
|
||||||
) *Snapshot {
|
) *Snapshot {
|
||||||
snap := &Snapshot{
|
snap := &Snapshot{
|
||||||
config: config,
|
chainConfig: chainConfig,
|
||||||
sigcache: sigcache,
|
sigcache: sigcache,
|
||||||
Number: number,
|
Number: number,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
|
|
@ -47,7 +48,7 @@ func newSnapshot(
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadSnapshot loads an existing snapshot from the database.
|
// loadSnapshot loads an existing snapshot from the database.
|
||||||
func loadSnapshot(config *params.BorConfig, sigcache *lru.ARCCache, db ethdb.Database, hash common.Hash) (*Snapshot, error) {
|
func loadSnapshot(chainConfig *params.ChainConfig, config *params.BorConfig, sigcache *lru.ARCCache, db ethdb.Database, hash common.Hash) (*Snapshot, error) {
|
||||||
blob, err := db.Get(append([]byte("bor-"), hash[:]...))
|
blob, err := db.Get(append([]byte("bor-"), hash[:]...))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -61,7 +62,7 @@ func loadSnapshot(config *params.BorConfig, sigcache *lru.ARCCache, db ethdb.Dat
|
||||||
|
|
||||||
snap.ValidatorSet.UpdateValidatorMap()
|
snap.ValidatorSet.UpdateValidatorMap()
|
||||||
|
|
||||||
snap.config = config
|
snap.chainConfig = chainConfig
|
||||||
snap.sigcache = sigcache
|
snap.sigcache = sigcache
|
||||||
|
|
||||||
// update total voting power
|
// update total voting power
|
||||||
|
|
@ -85,7 +86,7 @@ func (s *Snapshot) store(db ethdb.Database) error {
|
||||||
// copy creates a deep copy of the snapshot, though not the individual votes.
|
// copy creates a deep copy of the snapshot, though not the individual votes.
|
||||||
func (s *Snapshot) copy() *Snapshot {
|
func (s *Snapshot) copy() *Snapshot {
|
||||||
cpy := &Snapshot{
|
cpy := &Snapshot{
|
||||||
config: s.config,
|
chainConfig: s.chainConfig,
|
||||||
sigcache: s.sigcache,
|
sigcache: s.sigcache,
|
||||||
Number: s.Number,
|
Number: s.Number,
|
||||||
Hash: s.Hash,
|
Hash: s.Hash,
|
||||||
|
|
@ -122,12 +123,12 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
|
||||||
number := header.Number.Uint64()
|
number := header.Number.Uint64()
|
||||||
|
|
||||||
// Delete the oldest signer from the recent list to allow it signing again
|
// Delete the oldest signer from the recent list to allow it signing again
|
||||||
if number >= s.config.CalculateSprint(number) {
|
if number >= s.chainConfig.Bor.CalculateSprint(number) {
|
||||||
delete(snap.Recents, number-s.config.CalculateSprint(number))
|
delete(snap.Recents, number-s.chainConfig.Bor.CalculateSprint(number))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the authorization key and check against signers
|
// Resolve the authorization key and check against signers
|
||||||
signer, err := ecrecover(header, s.sigcache, s.config)
|
signer, err := ecrecover(header, s.sigcache, s.chainConfig.Bor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -145,12 +146,12 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
|
||||||
snap.Recents[number] = signer
|
snap.Recents[number] = signer
|
||||||
|
|
||||||
// change validator set and change proposer
|
// change validator set and change proposer
|
||||||
if number > 0 && (number+1)%s.config.CalculateSprint(number) == 0 {
|
if number > 0 && (number+1)%s.chainConfig.Bor.CalculateSprint(number) == 0 {
|
||||||
if err := validateHeaderExtraField(header.Extra); err != nil {
|
if err := validateHeaderExtraField(header.Extra); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
validatorBytes := header.GetValidatorBytes(s.config)
|
validatorBytes := header.GetValidatorBytes(s.chainConfig)
|
||||||
|
|
||||||
// get validators from headers and use that for new validator set
|
// get validators from headers and use that for new validator set
|
||||||
newVals, _ := valset.ParseValidators(validatorBytes)
|
newVals, _ := valset.ParseValidators(validatorBytes)
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,11 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
||||||
|
|
||||||
deps := GetDeps(blockTxDependency)
|
deps := GetDeps(blockTxDependency)
|
||||||
|
|
||||||
|
if !VerifyDeps(deps) || len(blockTxDependency) != len(block.Transactions()) {
|
||||||
|
blockTxDependency = nil
|
||||||
|
deps = make(map[int][]int)
|
||||||
|
}
|
||||||
|
|
||||||
if blockTxDependency != nil {
|
if blockTxDependency != nil {
|
||||||
metadata = true
|
metadata = true
|
||||||
}
|
}
|
||||||
|
|
@ -308,7 +313,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
||||||
shouldDelayFeeCal = false
|
shouldDelayFeeCal = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(blockTxDependency) != len(block.Transactions()) {
|
|
||||||
task := &ExecutionTask{
|
task := &ExecutionTask{
|
||||||
msg: *msg,
|
msg: *msg,
|
||||||
config: p.config,
|
config: p.config,
|
||||||
|
|
@ -333,32 +337,6 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks = append(tasks, task)
|
tasks = append(tasks, task)
|
||||||
} else {
|
|
||||||
task := &ExecutionTask{
|
|
||||||
msg: *msg,
|
|
||||||
config: p.config,
|
|
||||||
gasLimit: block.GasLimit(),
|
|
||||||
blockNumber: blockNumber,
|
|
||||||
blockHash: blockHash,
|
|
||||||
tx: tx,
|
|
||||||
index: i,
|
|
||||||
cleanStateDB: cleansdb,
|
|
||||||
finalStateDB: statedb,
|
|
||||||
blockChain: p.bc,
|
|
||||||
header: header,
|
|
||||||
evmConfig: cfg,
|
|
||||||
shouldDelayFeeCal: &shouldDelayFeeCal,
|
|
||||||
sender: msg.From,
|
|
||||||
totalUsedGas: usedGas,
|
|
||||||
receipts: &receipts,
|
|
||||||
allLogs: &allLogs,
|
|
||||||
dependencies: nil,
|
|
||||||
coinbase: coinbase,
|
|
||||||
blockContext: blockContext,
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks = append(tasks, task)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
backupStateDB := statedb.Copy()
|
backupStateDB := statedb.Copy()
|
||||||
|
|
@ -427,3 +405,21 @@ func GetDeps(txDependency [][]uint64) map[int][]int {
|
||||||
|
|
||||||
return deps
|
return deps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if dependencies are correct
|
||||||
|
func VerifyDeps(deps map[int][]int) bool {
|
||||||
|
// number of transactions in the block
|
||||||
|
n := len(deps)
|
||||||
|
|
||||||
|
// Handle out-of-range and circular dependency problem
|
||||||
|
for i := 0; i <= n-1; i++ {
|
||||||
|
val := deps[i]
|
||||||
|
for _, depTx := range val {
|
||||||
|
if depTx >= n || depTx >= i {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
|
||||||
30
core/parallel_state_processor_test.go
Normal file
30
core/parallel_state_processor_test.go
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMetadata(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
correctTxDependency := [][]uint64{{}, {0}, {}, {1}, {3}, {}, {0, 2}, {5}, {}, {8}}
|
||||||
|
wrongTxDependency := [][]uint64{{0}}
|
||||||
|
wrongTxDependencyCircular := [][]uint64{{}, {2}, {1}}
|
||||||
|
wrongTxDependencyOutOfRange := [][]uint64{{}, {}, {3}}
|
||||||
|
|
||||||
|
var temp map[int][]int
|
||||||
|
|
||||||
|
temp = GetDeps(correctTxDependency)
|
||||||
|
assert.Equal(t, true, VerifyDeps(temp))
|
||||||
|
|
||||||
|
temp = GetDeps(wrongTxDependency)
|
||||||
|
assert.Equal(t, false, VerifyDeps(temp))
|
||||||
|
|
||||||
|
temp = GetDeps(wrongTxDependencyCircular)
|
||||||
|
assert.Equal(t, false, VerifyDeps(temp))
|
||||||
|
|
||||||
|
temp = GetDeps(wrongTxDependencyOutOfRange)
|
||||||
|
assert.Equal(t, false, VerifyDeps(temp))
|
||||||
|
}
|
||||||
|
|
@ -456,8 +456,8 @@ func (b *Block) GetTxDependency() [][]uint64 {
|
||||||
return blockExtraData.TxDependency
|
return blockExtraData.TxDependency
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Header) GetValidatorBytes(config *params.BorConfig) []byte {
|
func (h *Header) GetValidatorBytes(chainConfig *params.ChainConfig) []byte {
|
||||||
if !config.IsParallelUniverse(h.Number) {
|
if !chainConfig.IsCancun(h.Number) {
|
||||||
return h.Extra[ExtraVanityLength : len(h.Extra)-ExtraSealLength]
|
return h.Extra[ExtraVanityLength : len(h.Extra)-ExtraSealLength]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ func TestBlockEncoding(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a replica of `(h *Header) GetValidatorBytes` function
|
// This is a replica of `(h *Header) GetValidatorBytes` function
|
||||||
// This was needed because currently, `IsParallelUniverse` will always return false.
|
|
||||||
func GetValidatorBytesTest(h *Header) []byte {
|
func GetValidatorBytesTest(h *Header) []byte {
|
||||||
if len(h.Extra) < ExtraVanityLength+ExtraSealLength {
|
if len(h.Extra) < ExtraVanityLength+ExtraSealLength {
|
||||||
log.Error("length of extra less is than vanity and seal")
|
log.Error("length of extra less is than vanity and seal")
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ var mainnetBor = &Chain{
|
||||||
Bor: ¶ms.BorConfig{
|
Bor: ¶ms.BorConfig{
|
||||||
JaipurBlock: big.NewInt(23850000),
|
JaipurBlock: big.NewInt(23850000),
|
||||||
DelhiBlock: big.NewInt(38189056),
|
DelhiBlock: big.NewInt(38189056),
|
||||||
ParallelUniverseBlock: big.NewInt(0),
|
|
||||||
IndoreBlock: big.NewInt(44934656),
|
IndoreBlock: big.NewInt(44934656),
|
||||||
StateSyncConfirmationDelay: map[string]uint64{
|
StateSyncConfirmationDelay: map[string]uint64{
|
||||||
"44934656": 128,
|
"44934656": 128,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ var mumbaiTestnet = &Chain{
|
||||||
Bor: ¶ms.BorConfig{
|
Bor: ¶ms.BorConfig{
|
||||||
JaipurBlock: big.NewInt(22770000),
|
JaipurBlock: big.NewInt(22770000),
|
||||||
DelhiBlock: big.NewInt(29638656),
|
DelhiBlock: big.NewInt(29638656),
|
||||||
ParallelUniverseBlock: big.NewInt(0),
|
|
||||||
IndoreBlock: big.NewInt(37075456),
|
IndoreBlock: big.NewInt(37075456),
|
||||||
StateSyncConfirmationDelay: map[string]uint64{
|
StateSyncConfirmationDelay: map[string]uint64{
|
||||||
"37075456": 128,
|
"37075456": 128,
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,6 @@
|
||||||
},
|
},
|
||||||
"jaipurBlock": 22770000,
|
"jaipurBlock": 22770000,
|
||||||
"delhiBlock": 29638656,
|
"delhiBlock": 29638656,
|
||||||
"parallelUniverseBlock": 0,
|
|
||||||
"indoreBlock": 37075456,
|
"indoreBlock": 37075456,
|
||||||
"stateSyncConfirmationDelay": {
|
"stateSyncConfirmationDelay": {
|
||||||
"37075456": 128
|
"37075456": 128
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@
|
||||||
},
|
},
|
||||||
"jaipurBlock":22770000,
|
"jaipurBlock":22770000,
|
||||||
"delhiBlock": 29638656,
|
"delhiBlock": 29638656,
|
||||||
"parallelUniverseBlock": 0,
|
|
||||||
"indoreBlock": 37075456,
|
"indoreBlock": 37075456,
|
||||||
"stateSyncConfirmationDelay": {
|
"stateSyncConfirmationDelay": {
|
||||||
"37075456": 128
|
"37075456": 128
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,9 @@ type environment struct {
|
||||||
header *types.Header
|
header *types.Header
|
||||||
txs []*types.Transaction
|
txs []*types.Transaction
|
||||||
receipts []*types.Receipt
|
receipts []*types.Receipt
|
||||||
|
|
||||||
|
depsMVFullWriteList [][]blockstm.WriteDescriptor
|
||||||
|
mvReadMapList []map[blockstm.Key]blockstm.ReadDescriptor
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy creates a deep copy of environment.
|
// copy creates a deep copy of environment.
|
||||||
|
|
@ -120,6 +123,8 @@ func (env *environment) copy() *environment {
|
||||||
coinbase: env.coinbase,
|
coinbase: env.coinbase,
|
||||||
header: types.CopyHeader(env.header),
|
header: types.CopyHeader(env.header),
|
||||||
receipts: copyReceipts(env.receipts),
|
receipts: copyReceipts(env.receipts),
|
||||||
|
depsMVFullWriteList: env.depsMVFullWriteList,
|
||||||
|
mvReadMapList: env.mvReadMapList,
|
||||||
}
|
}
|
||||||
|
|
||||||
if env.gasPool != nil {
|
if env.gasPool != nil {
|
||||||
|
|
@ -854,6 +859,9 @@ func (w *worker) makeEnv(parent *types.Header, header *types.Header, coinbase co
|
||||||
// Keep track of transactions which return errors so they can be removed
|
// Keep track of transactions which return errors so they can be removed
|
||||||
env.tcount = 0
|
env.tcount = 0
|
||||||
|
|
||||||
|
env.depsMVFullWriteList = [][]blockstm.WriteDescriptor{}
|
||||||
|
env.mvReadMapList = []map[blockstm.Key]blockstm.ReadDescriptor{}
|
||||||
|
|
||||||
return env, nil
|
return env, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -903,36 +911,20 @@ func (w *worker) commitTransactions(env *environment, txs *transactionsByPriceAn
|
||||||
|
|
||||||
var coalescedLogs []*types.Log
|
var coalescedLogs []*types.Log
|
||||||
|
|
||||||
var depsMVReadList [][]blockstm.ReadDescriptor
|
|
||||||
|
|
||||||
var depsMVFullWriteList [][]blockstm.WriteDescriptor
|
|
||||||
|
|
||||||
var mvReadMapList []map[blockstm.Key]blockstm.ReadDescriptor
|
|
||||||
|
|
||||||
var deps map[int]map[int]bool
|
var deps map[int]map[int]bool
|
||||||
|
|
||||||
chDeps := make(chan blockstm.TxDep)
|
chDeps := make(chan blockstm.TxDep)
|
||||||
|
|
||||||
var count int
|
|
||||||
|
|
||||||
var depsWg sync.WaitGroup
|
var depsWg sync.WaitGroup
|
||||||
|
|
||||||
EnableMVHashMap := w.chainConfig.Bor.IsParallelUniverse(env.header.Number)
|
EnableMVHashMap := w.chainConfig.IsCancun(env.header.Number)
|
||||||
|
|
||||||
// create and add empty mvHashMap in statedb
|
// create and add empty mvHashMap in statedb
|
||||||
if EnableMVHashMap {
|
if EnableMVHashMap {
|
||||||
depsMVReadList = [][]blockstm.ReadDescriptor{}
|
|
||||||
|
|
||||||
depsMVFullWriteList = [][]blockstm.WriteDescriptor{}
|
|
||||||
|
|
||||||
mvReadMapList = []map[blockstm.Key]blockstm.ReadDescriptor{}
|
|
||||||
|
|
||||||
deps = map[int]map[int]bool{}
|
deps = map[int]map[int]bool{}
|
||||||
|
|
||||||
chDeps = make(chan blockstm.TxDep)
|
chDeps = make(chan blockstm.TxDep)
|
||||||
|
|
||||||
count = 0
|
|
||||||
|
|
||||||
depsWg.Add(1)
|
depsWg.Add(1)
|
||||||
|
|
||||||
go func(chDeps chan blockstm.TxDep) {
|
go func(chDeps chan blockstm.TxDep) {
|
||||||
|
|
@ -1064,18 +1056,20 @@ mainloop:
|
||||||
env.tcount++
|
env.tcount++
|
||||||
|
|
||||||
if EnableMVHashMap {
|
if EnableMVHashMap {
|
||||||
depsMVReadList = append(depsMVReadList, env.state.MVReadList())
|
env.depsMVFullWriteList = append(env.depsMVFullWriteList, env.state.MVFullWriteList())
|
||||||
depsMVFullWriteList = append(depsMVFullWriteList, env.state.MVFullWriteList())
|
env.mvReadMapList = append(env.mvReadMapList, env.state.MVReadMap())
|
||||||
mvReadMapList = append(mvReadMapList, env.state.MVReadMap())
|
|
||||||
|
if env.tcount > len(env.depsMVFullWriteList) {
|
||||||
|
log.Warn("blockstm - env.tcount > len(env.depsMVFullWriteList)", "env.tcount", env.tcount, "len(depsMVFullWriteList)", len(env.depsMVFullWriteList))
|
||||||
|
}
|
||||||
|
|
||||||
temp := blockstm.TxDep{
|
temp := blockstm.TxDep{
|
||||||
Index: env.tcount - 1,
|
Index: env.tcount - 1,
|
||||||
ReadList: depsMVReadList[count],
|
ReadList: env.state.MVReadList(),
|
||||||
FullWriteList: depsMVFullWriteList,
|
FullWriteList: env.depsMVFullWriteList,
|
||||||
}
|
}
|
||||||
|
|
||||||
chDeps <- temp
|
chDeps <- temp
|
||||||
count++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
txs.Shift()
|
txs.Shift()
|
||||||
|
|
@ -1107,8 +1101,8 @@ mainloop:
|
||||||
tempVanity := env.header.Extra[:types.ExtraVanityLength]
|
tempVanity := env.header.Extra[:types.ExtraVanityLength]
|
||||||
tempSeal := env.header.Extra[len(env.header.Extra)-types.ExtraSealLength:]
|
tempSeal := env.header.Extra[len(env.header.Extra)-types.ExtraSealLength:]
|
||||||
|
|
||||||
if len(mvReadMapList) > 0 {
|
if len(env.mvReadMapList) > 0 {
|
||||||
tempDeps := make([][]uint64, len(mvReadMapList))
|
tempDeps := make([][]uint64, len(env.mvReadMapList))
|
||||||
|
|
||||||
for j := range deps[0] {
|
for j := range deps[0] {
|
||||||
tempDeps[0] = append(tempDeps[0], uint64(j))
|
tempDeps[0] = append(tempDeps[0], uint64(j))
|
||||||
|
|
@ -1116,8 +1110,8 @@ mainloop:
|
||||||
|
|
||||||
delayFlag := true
|
delayFlag := true
|
||||||
|
|
||||||
for i := 1; i <= len(mvReadMapList)-1; i++ {
|
for i := 1; i <= len(env.mvReadMapList)-1; i++ {
|
||||||
reads := mvReadMapList[i-1]
|
reads := env.mvReadMapList[i-1]
|
||||||
|
|
||||||
_, ok1 := reads[blockstm.NewSubpathKey(env.coinbase, state.BalancePath)]
|
_, ok1 := reads[blockstm.NewSubpathKey(env.coinbase, state.BalancePath)]
|
||||||
_, ok2 := reads[blockstm.NewSubpathKey(common.HexToAddress(w.chainConfig.Bor.CalculateBurntContract(env.header.Number.Uint64())), state.BalancePath)]
|
_, ok2 := reads[blockstm.NewSubpathKey(common.HexToAddress(w.chainConfig.Bor.CalculateBurntContract(env.header.Number.Uint64())), state.BalancePath)]
|
||||||
|
|
|
||||||
|
|
@ -909,7 +909,7 @@ func BenchmarkBorMining(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// uses core.NewParallelBlockChain to use the dependencies present in the block header
|
// 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.
|
// params.BorUnittestChainConfig contains the NapoliBlock as big.NewInt(5), so the first 4 blocks will not have metadata.
|
||||||
// nolint: gocognit
|
// nolint: gocognit
|
||||||
func BenchmarkBorMiningBlockSTMMetadata(b *testing.B) {
|
func BenchmarkBorMiningBlockSTMMetadata(b *testing.B) {
|
||||||
chainConfig := params.BorUnittestChainConfig
|
chainConfig := params.BorUnittestChainConfig
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,6 @@ var (
|
||||||
BerlinBlock: big.NewInt(0),
|
BerlinBlock: big.NewInt(0),
|
||||||
LondonBlock: big.NewInt(0),
|
LondonBlock: big.NewInt(0),
|
||||||
Bor: &BorConfig{
|
Bor: &BorConfig{
|
||||||
ParallelUniverseBlock: big.NewInt(5),
|
|
||||||
Period: map[string]uint64{
|
Period: map[string]uint64{
|
||||||
"0": 1,
|
"0": 1,
|
||||||
},
|
},
|
||||||
|
|
@ -200,7 +199,6 @@ var (
|
||||||
Bor: &BorConfig{
|
Bor: &BorConfig{
|
||||||
JaipurBlock: big.NewInt(22770000),
|
JaipurBlock: big.NewInt(22770000),
|
||||||
DelhiBlock: big.NewInt(29638656),
|
DelhiBlock: big.NewInt(29638656),
|
||||||
ParallelUniverseBlock: big.NewInt(0),
|
|
||||||
IndoreBlock: big.NewInt(37075456),
|
IndoreBlock: big.NewInt(37075456),
|
||||||
StateSyncConfirmationDelay: map[string]uint64{
|
StateSyncConfirmationDelay: map[string]uint64{
|
||||||
"37075456": 128,
|
"37075456": 128,
|
||||||
|
|
@ -266,7 +264,6 @@ var (
|
||||||
Bor: &BorConfig{
|
Bor: &BorConfig{
|
||||||
JaipurBlock: big.NewInt(23850000),
|
JaipurBlock: big.NewInt(23850000),
|
||||||
DelhiBlock: big.NewInt(38189056),
|
DelhiBlock: big.NewInt(38189056),
|
||||||
ParallelUniverseBlock: big.NewInt(0),
|
|
||||||
IndoreBlock: big.NewInt(44934656),
|
IndoreBlock: big.NewInt(44934656),
|
||||||
StateSyncConfirmationDelay: map[string]uint64{
|
StateSyncConfirmationDelay: map[string]uint64{
|
||||||
"44934656": 128,
|
"44934656": 128,
|
||||||
|
|
@ -567,7 +564,6 @@ type BorConfig struct {
|
||||||
BurntContract map[string]string `json:"burntContract"` // governance contract where the token will be sent to and burnt in london fork
|
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)
|
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)
|
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)
|
|
||||||
IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on indore)
|
IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on indore)
|
||||||
StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to`
|
StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to`
|
||||||
}
|
}
|
||||||
|
|
@ -609,16 +605,16 @@ func (c *BorConfig) CalculateStateSyncDelay(number uint64) uint64 {
|
||||||
return borKeyValueConfigHelper(c.StateSyncConfirmationDelay, number)
|
return borKeyValueConfigHelper(c.StateSyncConfirmationDelay, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: modify this function once the block number is finalized
|
// // TODO: modify this function once the block number is finalized
|
||||||
func (c *BorConfig) IsParallelUniverse(number *big.Int) bool {
|
// func (c *BorConfig) IsNapoli(number *big.Int) bool {
|
||||||
if c.ParallelUniverseBlock != nil {
|
// if c.NapoliBlock != nil {
|
||||||
if c.ParallelUniverseBlock.Cmp(big.NewInt(0)) == 0 {
|
// if c.NapoliBlock.Cmp(big.NewInt(0)) == 0 {
|
||||||
return false
|
// return false
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
return isBlockForked(c.ParallelUniverseBlock, number)
|
// return isBlockForked(c.NapoliBlock, number)
|
||||||
}
|
// }
|
||||||
|
|
||||||
func (c *BorConfig) IsSprintStart(number uint64) bool {
|
func (c *BorConfig) IsSprintStart(number uint64) bool {
|
||||||
return number%c.CalculateSprint(number) == 0
|
return number%c.CalculateSprint(number) == 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue