Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion conf/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ isParallel = false
enableAsyncCommit = false
maxConcurrency = 4
isBenchmarkMode = true
ignoreConflict = false
extraBalanceGas = 0
19 changes: 5 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,18 @@ import (
)

type Config struct {
IsParallel bool `yaml:"isParallel"`
MaxConcurrency int `yaml:"maxConcurrency"`
IsBenchmarkMode bool `yaml:"isBenchmarkMode"`
AsyncCommit bool `yaml:"asyncCommit"`
IgnoreConflict bool `yaml:"ignoreConflict"`
RateLimitConfig RateLimitConfig `yaml:"rateLimitConfig"`
ExtraBalanceGas uint64 `yaml:"extraBalanceGas"`
}

type RateLimitConfig struct {
GetReceipt int64 `yaml:"getReceipt"`
IsParallel bool `yaml:"isParallel"`
MaxConcurrency int `yaml:"maxConcurrency"`
IsBenchmarkMode bool `yaml:"isBenchmarkMode"`
AsyncCommit bool `yaml:"asyncCommit"`
ExtraBalanceGas uint64 `yaml:"extraBalanceGas"`
}

func defaultConfig() *Config {
return &Config{
AsyncCommit: false,
IsParallel: true,
MaxConcurrency: runtime.NumCPU(),
RateLimitConfig: RateLimitConfig{
GetReceipt: 2000,
},
}
}

Expand Down
16 changes: 0 additions & 16 deletions evm/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,12 @@ type Solidity struct {
coinbaseReward atomic.Uint64
}

func (s *Solidity) StateDB() *state.StateDB {
s.Lock()
defer s.Unlock()
return s.ethState.StateDB()
}

func (s *Solidity) StateDBCopy() *state.StateDB {
s.Lock()
defer s.Unlock()
return s.ethState.StateDB().Copy()
}

func (s *Solidity) GetStateDBState(addr common.Address, hash common.Hash) common.Hash {
s.Lock()
defer s.Unlock()
return s.ethState.StateDB().GetState(addr, hash)
}

func (s *Solidity) SetStateDB(d *state.StateDB) {
s.Lock()
defer s.Unlock()
Expand Down Expand Up @@ -200,10 +188,8 @@ func NewSolidity(gethConfig *GethConfig) *Solidity {

func (s *Solidity) StartBlock(block *yu_types.Block) {
metrics.SolidityCounter.WithLabelValues(startBlockLbl, statusSuccess).Inc()
s.Lock()
start := time.Now()
defer func() {
s.Unlock()
metrics.SolidityHist.WithLabelValues(startBlockLbl).Observe(float64(time.Since(start).Microseconds()))
}()
s.cfg.BlockNumber = big.NewInt(int64(block.Height))
Expand Down Expand Up @@ -267,10 +253,8 @@ func (s *Solidity) CheckGasfee(req *TxRequest) error {
// Execute sets up an in-memory, temporary, environment for the execution of
// the given code. It makes sure that it's restored to its original state afterwards.
func (s *Solidity) ExecuteTxn(ctx *context.WriteContext) (err error) {
s.Lock()
start := time.Now()
defer func() {
s.Unlock()
metrics.SolidityHist.WithLabelValues(executeTxnLbl).Observe(float64(time.Since(start).Microseconds()))
if err == nil {
metrics.SolidityCounter.WithLabelValues(executeTxnLbl, statusSuccess).Inc()
Expand Down
5 changes: 3 additions & 2 deletions parallel/evm_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (

type ParallelEVM struct {
*tripod.Tripod
db *state.StateDB
cpdb *state.StateDB
Solidity *evm.Solidity `tripod:"solidity"`
statManager *BlockTxnStatManager
objectInc map[common2.Address]int
Expand All @@ -49,7 +49,7 @@ func (k *ParallelEVM) setupProcessor() {

func (k *ParallelEVM) Execute(block *types.Block) error {
k.statManager = &BlockTxnStatManager{TxnCount: len(block.Txns)}
k.db = k.Solidity.StateDB()
k.cpdb = k.Solidity.StateDBCopy()
k.setupProcessor()
start := time.Now()
defer func() {
Expand All @@ -58,6 +58,7 @@ func (k *ParallelEVM) Execute(block *types.Block) error {
}()
k.processor.Prepare(block)
k.processor.Execute(block)
k.Solidity.SetStateDB(k.cpdb)
receipts := k.processor.Receipts(block)
return k.Commit(block, receipts)
}
Expand Down
4 changes: 2 additions & 2 deletions parallel/parallel_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (e *ParallelEvmExecutor) Prepare(block *types.Block) {
e.receipts = receipts
e.k.updateTxnObjInc(txnCtxList)
e.subTxnList = e.splitTxnCtxList(txnCtxList)
e.cpdb = e.k.Solidity.StateDBCopy()
e.cpdb = e.k.cpdb
}

func (e *ParallelEvmExecutor) Execute(block *types.Block) {
Expand Down Expand Up @@ -130,7 +130,7 @@ func (e *ParallelEvmExecutor) executeTxnCtxListInConcurrency(list []*txnCtx) []*
break
}
}
if conflict && !config.GetGlobalConfig().IgnoreConflict {
if conflict {
e.k.statManager.TxnBatchRedoCount++
metrics.BatchTxnCounter.WithLabelValues(batchTxnLabelRedo).Inc()
return e.k.executeTxnCtxListInOrder(e.cpdb, list, true)
Expand Down
2 changes: 1 addition & 1 deletion parallel/serial_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type SerialEvmExecutor struct {
func NewSerialEvmExecutor(evm *ParallelEVM) *SerialEvmExecutor {
return &SerialEvmExecutor{
k: evm,
db: evm.db,
db: evm.cpdb,
}
}

Expand Down
1 change: 0 additions & 1 deletion test/testx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func GenerateConfig(yuConfigPath, evmConfigPath, poaConfigPath string, isParalle
config.IsBenchmarkMode = true
config.IsParallel = isParallel
config.AsyncCommit = false
config.RateLimitConfig.GetReceipt = 0
poaCfg = poa.LoadCfgFromPath(poaConfigPath)
return yuCfg, poaCfg, evmConfig, config
}
26 changes: 0 additions & 26 deletions utils/ratelimit.go

This file was deleted.