Skip to content

Commit

Permalink
core/systemcontracts: modify func name
Browse files Browse the repository at this point in the history
  • Loading branch information
buddh0 committed Nov 29, 2024
1 parent b9530c8 commit 02121b6
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
return errors.New("parent not found")
}

systemcontracts.ModifyBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state, false)
systemcontracts.TryUpdateBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state, false)

if p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
err := p.initializeFeynmanContract(state, header, cx, txs, receipts, systemTxs, usedGas, false)
Expand Down Expand Up @@ -1372,7 +1372,7 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
return nil, nil, errors.New("parent not found")
}

systemcontracts.ModifyBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state, false)
systemcontracts.TryUpdateBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state, false)

if p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
err := p.initializeFeynmanContract(state, header, cx, &body.Transactions, &receipts, nil, &header.GasUsed, true)
Expand Down
2 changes: 1 addition & 1 deletion core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
misc.ApplyDAOHardFork(statedb)
}

systemcontracts.ModifyBuildInSystemContract(config, b.header.Number, parent.Time(), b.header.Time, statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(config, b.header.Number, parent.Time(), b.header.Time, statedb, true)

// Execute any user modifications to the block
if gen != nil {
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
return nil, errors.New("could not get parent block")
}
// Handle upgrade build-in system contract code
systemcontracts.ModifyBuildInSystemContract(p.config, blockNumber, lastBlock.Time, block.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(p.config, blockNumber, lastBlock.Time, block.Time(), statedb, true)

var (
context vm.BlockContext
Expand Down
2 changes: 1 addition & 1 deletion core/systemcontracts/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ func init() {
}
}

func ModifyBuildInSystemContract(config *params.ChainConfig, blockNumber *big.Int, lastBlockTime uint64, blockTime uint64, statedb vm.StateDB, atBlockBegin bool) {
func TryUpdateBuildInSystemContract(config *params.ChainConfig, blockNumber *big.Int, lastBlockTime uint64, blockTime uint64, statedb vm.StateDB, atBlockBegin bool) {
if atBlockBegin {
if !config.IsFeynman(blockNumber, lastBlockTime) {
upgradeBuildInSystemContract(config, blockNumber, lastBlockTime, blockTime, statedb)
Expand Down
4 changes: 2 additions & 2 deletions eth/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
return nil, vm.BlockContext{}, nil, nil, err
}
// upgrade build-in system contract before normal txs if Feynman is not enabled
systemcontracts.ModifyBuildInSystemContract(eth.blockchain.Config(), block.Number(), parent.Time(), block.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(eth.blockchain.Config(), block.Number(), parent.Time(), block.Time(), statedb, true)
// Insert parent beacon block root in the state as per EIP-4788.
if beaconRoot := block.BeaconRoot(); beaconRoot != nil {
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil)
Expand Down Expand Up @@ -275,7 +275,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
statedb.AddBalance(block.Header().Coinbase, balance, tracing.BalanceChangeUnspecified)
}

systemcontracts.ModifyBuildInSystemContract(eth.blockchain.Config(), block.Number(), parent.Time(), block.Time(), statedb, false)
systemcontracts.TryUpdateBuildInSystemContract(eth.blockchain.Config(), block.Number(), parent.Time(), block.Time(), statedb, false)
beforeSystemTx = false
}
}
Expand Down
20 changes: 10 additions & 10 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
task.statedb.AddBalance(blockCtx.Coinbase, balance, tracing.BalanceChangeUnspecified)
}

systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), task.block.Number(), task.parent.Time(), task.block.Time(), task.statedb, false)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), task.block.Number(), task.parent.Time(), task.block.Time(), task.statedb, false)
beforeSystemTx = false
}
}
Expand Down Expand Up @@ -402,7 +402,7 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
}

// upgrade build-in system contract before normal txs if Feynman is not enabled
systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), next.Number(), block.Time(), next.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), next.Number(), block.Time(), next.Time(), statedb, true)

// Insert block's parent beacon block root in the state
// as per EIP-4788.
Expand Down Expand Up @@ -560,7 +560,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
defer release()

// upgrade build-in system contract before normal txs if Feynman is not enabled
systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)

var (
roots []common.Hash
Expand Down Expand Up @@ -596,7 +596,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
}

if beforeSystemTx {
systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
beforeSystemTx = false
}
}
Expand Down Expand Up @@ -656,7 +656,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
defer release()

// upgrade build-in system contract before normal txs if Feynman is not enabled
systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)

// JS tracers have high overhead. In this case run a parallel
// process that generates states in one thread and traces txes
Expand Down Expand Up @@ -695,7 +695,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
statedb.AddBalance(blockCtx.Coinbase, balance, tracing.BalanceChangeUnspecified)
}

systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
beforeSystemTx = false
}
}
Expand Down Expand Up @@ -786,7 +786,7 @@ txloop:
statedb.AddBalance(block.Header().Coinbase, balance, tracing.BalanceChangeUnspecified)
}

systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
beforeSystemTx = false
}
}
Expand Down Expand Up @@ -852,7 +852,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
defer release()

// upgrade build-in system contract before normal txs if Feynman is not enabled
systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)

// Retrieve the tracing configurations, or use default values
var (
Expand Down Expand Up @@ -902,7 +902,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
statedb.AddBalance(vmctx.Coinbase, balance, tracing.BalanceChangeUnspecified)
}

systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, false)
beforeSystemTx = false
}
}
Expand Down Expand Up @@ -1084,7 +1084,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
if err != nil {
return nil, err
}
systemcontracts.ModifyBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)
systemcontracts.TryUpdateBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb, true)
}

vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
Expand Down
2 changes: 1 addition & 1 deletion miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ func (w *worker) prepareWork(genParams *generateParams, witness bool) (*environm
}

// Handle upgrade build-in system contract code
systemcontracts.ModifyBuildInSystemContract(w.chainConfig, header.Number, parent.Time, header.Time, env.state, true)
systemcontracts.TryUpdateBuildInSystemContract(w.chainConfig, header.Number, parent.Time, header.Time, env.state, true)

if header.ParentBeaconRoot != nil {
context := core.NewEVMBlockContext(header, w.chain, nil)
Expand Down

0 comments on commit 02121b6

Please sign in to comment.