Compare commits
2 Commits
bc-fusion-
...
fusion-aud
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65baf18031 | ||
|
|
13f17f2970 |
@@ -198,6 +198,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
|
||||
v := ctx.Uint64(utils.OverrideVerkle.Name)
|
||||
cfg.Eth.OverrideVerkle = &v
|
||||
}
|
||||
if ctx.IsSet(utils.OverrideFeynman.Name) {
|
||||
v := ctx.Uint64(utils.OverrideFeynman.Name)
|
||||
cfg.Eth.OverrideFeynman = &v
|
||||
}
|
||||
backend, _ := utils.RegisterEthService(stack, &cfg.Eth)
|
||||
|
||||
// Configure log filter RPC API.
|
||||
|
||||
@@ -74,6 +74,7 @@ var (
|
||||
utils.OverrideKepler,
|
||||
utils.OverrideCancun,
|
||||
utils.OverrideVerkle,
|
||||
utils.OverrideFeynman,
|
||||
utils.EnablePersonal,
|
||||
utils.TxPoolLocalsFlag,
|
||||
utils.TxPoolNoLocalsFlag,
|
||||
|
||||
@@ -315,6 +315,11 @@ var (
|
||||
Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting",
|
||||
Category: flags.EthCategory,
|
||||
}
|
||||
OverrideFeynman = &cli.Uint64Flag{
|
||||
Name: "override.feynman",
|
||||
Usage: "Manually specify the Feynman fork timestamp, overriding the bundled setting",
|
||||
Category: flags.EthCategory,
|
||||
}
|
||||
SyncModeFlag = &flags.TextMarshalerFlag{
|
||||
Name: "syncmode",
|
||||
Usage: `Blockchain sync mode ("snap" or "full")`,
|
||||
|
||||
@@ -1126,6 +1126,15 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
|
||||
|
||||
cx := chainContext{Chain: chain, parlia: p}
|
||||
|
||||
parent := chain.GetHeaderByHash(header.ParentHash)
|
||||
if parent == nil {
|
||||
return errors.New("parent not found")
|
||||
}
|
||||
|
||||
if p.chainConfig.IsFeynman(header.Number, header.Time) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state)
|
||||
}
|
||||
|
||||
// No block rewards in PoA, so the state remains as is and uncles are dropped
|
||||
if header.Number.Cmp(common.Big1) == 0 {
|
||||
err := p.initContract(state, header, cx, txs, receipts, systemTxs, usedGas, false)
|
||||
@@ -1168,17 +1177,10 @@ func (p *Parlia) Finalize(chain consensus.ChainHeaderReader, header *types.Heade
|
||||
}
|
||||
}
|
||||
|
||||
parent := chain.GetHeaderByHash(header.ParentHash)
|
||||
if parent == nil {
|
||||
return errors.New("parent not found")
|
||||
}
|
||||
|
||||
log.Info("!!! DEBUG Finalize block time", "number", header.Number, "time", header.Time, "parent time", parent.Time)
|
||||
if p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
|
||||
err := p.initializeFeynmanContract(state, header, cx, txs, receipts, systemTxs, usedGas, false)
|
||||
if err != nil {
|
||||
log.Error("init feynman contract failed", "error", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1210,6 +1212,16 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
|
||||
if receipts == nil {
|
||||
receipts = make([]*types.Receipt, 0)
|
||||
}
|
||||
|
||||
parent := chain.GetHeaderByHash(header.ParentHash)
|
||||
if parent == nil {
|
||||
return nil, nil, errors.New("parent not found")
|
||||
}
|
||||
|
||||
if p.chainConfig.IsFeynman(header.Number, header.Time) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(p.chainConfig, header.Number, parent.Time, header.Time, state)
|
||||
}
|
||||
|
||||
if header.Number.Cmp(common.Big1) == 0 {
|
||||
err := p.initContract(state, header, cx, &txs, &receipts, nil, &header.GasUsed, true)
|
||||
if err != nil {
|
||||
@@ -1245,27 +1257,19 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
|
||||
|
||||
err := p.distributeIncoming(p.val, state, header, cx, &txs, &receipts, nil, &header.GasUsed, true)
|
||||
if err != nil {
|
||||
log.Error("p.distributeIncoming failed", "err", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if p.chainConfig.IsPlato(header.Number) {
|
||||
if err := p.distributeFinalityReward(chain, state, header, cx, &txs, &receipts, nil, &header.GasUsed, true); err != nil {
|
||||
log.Error("p.p.distributeFinalityReward after Plato failed", "err", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
parent := chain.GetHeaderByHash(header.ParentHash)
|
||||
if parent == nil {
|
||||
return nil, nil, errors.New("parent not found")
|
||||
}
|
||||
log.Info("!!! DEBUG FinalizeAndAssemble block time", "number", header.Number, "time", header.Time, "parent time", parent.Time)
|
||||
if p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
|
||||
err := p.initializeFeynmanContract(state, header, cx, &txs, &receipts, nil, &header.GasUsed, true)
|
||||
if err != nil {
|
||||
log.Error("init feynman contract failed", "error", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1274,7 +1278,6 @@ func (p *Parlia) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *
|
||||
// we should avoid update validators in the Feynman upgrade block
|
||||
if !p.chainConfig.IsOnFeynman(header.Number, parent.Time, header.Time) {
|
||||
if err := p.updateValidatorSetV2(state, header, cx, &txs, &receipts, nil, &header.GasUsed, true); err != nil {
|
||||
log.Error("p.updateValidatorSetV2 after Feynman failed", "err", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,11 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(b.header.Number) == 0 {
|
||||
misc.ApplyDAOHardFork(statedb)
|
||||
}
|
||||
systemcontracts.UpgradeBuildInSystemContract(config, b.header.Number, parent.Time(), b.header.Time, statedb)
|
||||
|
||||
if !config.IsFeynman(b.header.Number, b.header.Time) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(config, b.header.Number, parent.Time(), b.header.Time, statedb)
|
||||
}
|
||||
|
||||
// Execute any user modifications to the block
|
||||
if gen != nil {
|
||||
gen(i, b)
|
||||
|
||||
@@ -280,6 +280,7 @@ type ChainOverrides struct {
|
||||
OverrideKepler *uint64
|
||||
OverrideCancun *uint64
|
||||
OverrideVerkle *uint64
|
||||
OverrideFeynman *uint64
|
||||
}
|
||||
|
||||
// SetupGenesisBlock writes or updates the genesis block in db.
|
||||
@@ -317,6 +318,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
|
||||
if overrides != nil && overrides.OverrideVerkle != nil {
|
||||
config.VerkleTime = overrides.OverrideVerkle
|
||||
}
|
||||
if overrides != nil && overrides.OverrideFeynman != nil {
|
||||
config.FeynmanTime = overrides.OverrideFeynman
|
||||
}
|
||||
}
|
||||
}
|
||||
// Just commit the new block if there is no stored genesis block.
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
@@ -74,12 +73,15 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||
if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 {
|
||||
misc.ApplyDAOHardFork(statedb)
|
||||
}
|
||||
// Handle upgrade build-in system contract code
|
||||
|
||||
lastBlock := p.bc.GetBlockByHash(block.ParentHash())
|
||||
if lastBlock == nil {
|
||||
return statedb, nil, nil, 0, fmt.Errorf("could not get parent block")
|
||||
}
|
||||
systemcontracts.UpgradeBuildInSystemContract(p.config, blockNumber, lastBlock.Time(), block.Time(), statedb)
|
||||
if !p.config.IsFeynman(block.Number(), block.Time()) {
|
||||
// Handle upgrade build-in system contract code
|
||||
systemcontracts.UpgradeBuildInSystemContract(p.config, blockNumber, lastBlock.Time(), block.Time(), statedb)
|
||||
}
|
||||
|
||||
var (
|
||||
context = NewEVMBlockContext(header, p.bc, nil)
|
||||
@@ -135,7 +137,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
||||
err := p.engine.Finalize(p.bc, header, statedb, &commonTxs, block.Uncles(), withdrawals, &receipts, &systemTxs, usedGas)
|
||||
if err != nil {
|
||||
log.Error("!!!DEBUG!!! Failed to p.engine.Finalize block", "err", err)
|
||||
return statedb, receipts, allLogs, *usedGas, err
|
||||
}
|
||||
for _, receipt := range receipts {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -12,10 +12,8 @@ import (
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
|
||||
//nolint:staticcheck
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
v1 "github.com/ethereum/go-ethereum/core/vm/lightclient/v1"
|
||||
v2 "github.com/ethereum/go-ethereum/core/vm/lightclient/v2"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
@@ -423,7 +421,6 @@ func (c *secp256k1SignatureRecover) Run(input []byte) (result []byte, err error)
|
||||
return nil, fmt.Errorf("invalid input")
|
||||
}
|
||||
|
||||
log.Warn("!!!DEBUG!! secp256k1SignatureRecover", "input", hexutil.Encode(input))
|
||||
return c.runTMSecp256k1Signature(
|
||||
input[:tmPubKeyLength],
|
||||
input[tmPubKeyLength:tmPubKeyLength+tmSignatureLength],
|
||||
@@ -434,10 +431,8 @@ func (c *secp256k1SignatureRecover) Run(input []byte) (result []byte, err error)
|
||||
func (c *secp256k1SignatureRecover) runTMSecp256k1Signature(pubkey, signatureStr, msgHash []byte) (result []byte, err error) {
|
||||
tmPubKey := secp256k1.PubKeySecp256k1(pubkey)
|
||||
ok := tmPubKey.VerifyBytesWithMsgHash(msgHash, signatureStr)
|
||||
log.Warn("!!!DEBUG!! secp256k1SignatureRecover", "ok", ok)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid signature")
|
||||
}
|
||||
log.Warn("!!!DEBUG!! secp256k1SignatureRecover", "address", hexutil.Encode(tmPubKey.Address().Bytes()))
|
||||
return tmPubKey.Address().Bytes(), nil
|
||||
}
|
||||
|
||||
@@ -183,6 +183,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||
chainConfig.VerkleTime = config.OverrideVerkle
|
||||
overrides.OverrideVerkle = config.OverrideVerkle
|
||||
}
|
||||
if config.OverrideFeynman != nil {
|
||||
chainConfig.FeynmanTime = config.OverrideFeynman
|
||||
overrides.OverrideFeynman = config.OverrideFeynman
|
||||
}
|
||||
|
||||
eth := &Ethereum{
|
||||
config: config,
|
||||
|
||||
@@ -193,6 +193,9 @@ type Config struct {
|
||||
|
||||
// OverrideVerkle (TODO: remove after the fork)
|
||||
OverrideVerkle *uint64 `toml:",omitempty"`
|
||||
|
||||
// OverrideFeynman (TODO: remove after the fork)
|
||||
OverrideFeynman *uint64 `toml:",omitempty"`
|
||||
}
|
||||
|
||||
// CreateConsensusEngine creates a consensus engine for the given chain config.
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/systemcontracts"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
||||
@@ -522,12 +523,18 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
|
||||
}
|
||||
defer release()
|
||||
|
||||
// upgrade build-in system contract before tracing non-system tx if Feynman is not enabled
|
||||
if !api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
|
||||
var (
|
||||
roots []common.Hash
|
||||
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number(), block.Time())
|
||||
chainConfig = api.backend.ChainConfig()
|
||||
vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||
deleteEmptyObjects = chainConfig.IsEIP158(block.Number())
|
||||
beforeSystemTx = true
|
||||
)
|
||||
for i, tx := range block.Transactions() {
|
||||
if err := ctx.Err(); err != nil {
|
||||
@@ -546,6 +553,11 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
|
||||
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
|
||||
statedb.AddBalance(vmctx.Coinbase, balance)
|
||||
}
|
||||
|
||||
if beforeSystemTx && api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
beforeSystemTx = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,6 +614,11 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
||||
}
|
||||
defer release()
|
||||
|
||||
// upgrade build-in system contract before tracing non-system tx if Feynman is not enabled
|
||||
if !api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
|
||||
// JS tracers have high overhead. In this case run a parallel
|
||||
// process that generates states in one thread and traces txes
|
||||
// in separate worker threads.
|
||||
@@ -610,18 +627,33 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
|
||||
return api.traceBlockParallel(ctx, block, statedb, config)
|
||||
}
|
||||
}
|
||||
|
||||
// Native tracers have low overhead
|
||||
var (
|
||||
txs = block.Transactions()
|
||||
blockHash = block.Hash()
|
||||
is158 = api.backend.ChainConfig().IsEIP158(block.Number())
|
||||
blockCtx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number(), block.Time())
|
||||
results = make([]*txTraceResult, len(txs))
|
||||
txs = block.Transactions()
|
||||
blockHash = block.Hash()
|
||||
is158 = api.backend.ChainConfig().IsEIP158(block.Number())
|
||||
blockCtx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||
signer = types.MakeSigner(api.backend.ChainConfig(), block.Number(), block.Time())
|
||||
results = make([]*txTraceResult, len(txs))
|
||||
beforeSystemTx = true
|
||||
)
|
||||
for i, tx := range txs {
|
||||
// upgrade build-in system contract before tracing system tx if Feynman is enabled
|
||||
if posa, ok := api.backend.Engine().(consensus.PoSA); ok {
|
||||
if isSystem, _ := posa.IsSystemTransaction(tx, block.Header()); isSystem {
|
||||
if beforeSystemTx {
|
||||
if api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
beforeSystemTx = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the next state snapshot fast without tracing
|
||||
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
|
||||
|
||||
txctx := &Context{
|
||||
BlockHash: blockHash,
|
||||
BlockNumber: block.Number(),
|
||||
@@ -682,10 +714,36 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
|
||||
})
|
||||
}
|
||||
|
||||
// upgrade build-in system contract before tracing non-system tx if Feynman is not enabled
|
||||
parent, err := api.blockByNumberAndHash(ctx, rpc.BlockNumber(block.NumberU64()-1), block.ParentHash())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
|
||||
// Feed the transactions into the tracers and return
|
||||
var failed error
|
||||
var (
|
||||
failed error
|
||||
beforeSystemTx = true
|
||||
)
|
||||
txloop:
|
||||
for i, tx := range txs {
|
||||
var isSystem bool
|
||||
// upgrade build-in system contract before tracing system tx if Feynman is enabled
|
||||
if posa, ok := api.backend.Engine().(consensus.PoSA); ok {
|
||||
isSystem, _ = posa.IsSystemTransaction(tx, block.Header())
|
||||
if isSystem {
|
||||
if beforeSystemTx {
|
||||
if api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
beforeSystemTx = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send the trace task over for execution
|
||||
task := &txTraceTask{statedb: statedb.Copy(), index: i}
|
||||
select {
|
||||
@@ -697,13 +755,11 @@ txloop:
|
||||
|
||||
// Generate the next state snapshot fast without tracing
|
||||
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
|
||||
if posa, ok := api.backend.Engine().(consensus.PoSA); ok {
|
||||
if isSystem, _ := posa.IsSystemTransaction(tx, block.Header()); isSystem {
|
||||
balance := statedb.GetBalance(consensus.SystemAddress)
|
||||
if balance.Cmp(common.Big0) > 0 {
|
||||
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
|
||||
statedb.AddBalance(block.Header().Coinbase, balance)
|
||||
}
|
||||
if isSystem {
|
||||
balance := statedb.GetBalance(consensus.SystemAddress)
|
||||
if balance.Cmp(common.Big0) > 0 {
|
||||
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
|
||||
statedb.AddBalance(block.Header().Coinbase, balance)
|
||||
}
|
||||
}
|
||||
statedb.SetTxContext(tx.Hash(), i)
|
||||
@@ -754,6 +810,11 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
||||
}
|
||||
defer release()
|
||||
|
||||
// upgrade build-in system contract before tracing non-system tx if Feynman is not enabled
|
||||
if !api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
|
||||
// Retrieve the tracing configurations, or use default values
|
||||
var (
|
||||
logConfig logger.Config
|
||||
@@ -782,7 +843,23 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
||||
// Note: This copies the config, to not screw up the main config
|
||||
chainConfig, canon = overrideConfig(chainConfig, config.Overrides)
|
||||
}
|
||||
|
||||
beforeSystemTx := true
|
||||
for i, tx := range block.Transactions() {
|
||||
// upgrade build-in system contract before tracing system tx if Feynman is enabled
|
||||
var isSystem bool
|
||||
if posa, ok := api.backend.Engine().(consensus.PoSA); ok {
|
||||
isSystem, _ = posa.IsSystemTransaction(tx, block.Header())
|
||||
if isSystem {
|
||||
if beforeSystemTx {
|
||||
if api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
beforeSystemTx = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare the transaction for un-traced execution
|
||||
var (
|
||||
msg, _ = core.TransactionToMessage(tx, signer, block.BaseFee())
|
||||
@@ -814,13 +891,11 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
|
||||
}
|
||||
// Execute the transaction and flush any traces to disk
|
||||
vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf)
|
||||
if posa, ok := api.backend.Engine().(consensus.PoSA); ok {
|
||||
if isSystem, _ := posa.IsSystemTransaction(tx, block.Header()); isSystem {
|
||||
balance := statedb.GetBalance(consensus.SystemAddress)
|
||||
if balance.Cmp(common.Big0) > 0 {
|
||||
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
|
||||
statedb.AddBalance(vmctx.Coinbase, balance)
|
||||
}
|
||||
if isSystem {
|
||||
balance := statedb.GetBalance(consensus.SystemAddress)
|
||||
if balance.Cmp(common.Big0) > 0 {
|
||||
statedb.SetBalance(consensus.SystemAddress, big.NewInt(0))
|
||||
statedb.AddBalance(vmctx.Coinbase, balance)
|
||||
}
|
||||
}
|
||||
statedb.SetTxContext(tx.Hash(), i)
|
||||
@@ -887,6 +962,22 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
|
||||
}
|
||||
defer release()
|
||||
|
||||
parent, err := api.blockByNumberAndHash(ctx, rpc.BlockNumber(block.NumberU64()-1), block.ParentHash())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
// upgrade build-in system contract before trace if Feynman is not enabled
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
} else {
|
||||
// upgrade build-in system contract before trace system tx if Feynman is enabled
|
||||
if posa, ok := api.backend.Engine().(consensus.PoSA); ok {
|
||||
if isSystem, _ := posa.IsSystemTransaction(tx, block.Header()); isSystem {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
txctx := &Context{
|
||||
BlockHash: blockHash,
|
||||
BlockNumber: block.Number(),
|
||||
@@ -934,6 +1025,15 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
|
||||
}
|
||||
defer release()
|
||||
|
||||
// upgrade build-in system contract before tracing if Feynman is not enabled
|
||||
parent, err := api.blockByNumberAndHash(ctx, rpc.BlockNumber(block.NumberU64()-1), block.ParentHash())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !api.backend.ChainConfig().IsFeynman(block.Number(), block.Time()) {
|
||||
systemcontracts.UpgradeBuildInSystemContract(api.backend.ChainConfig(), block.Number(), parent.Time(), block.Time(), statedb)
|
||||
}
|
||||
|
||||
vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil)
|
||||
// Apply the customization rules if required.
|
||||
if config != nil {
|
||||
|
||||
@@ -913,8 +913,10 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Handle upgrade build-in system contract code
|
||||
systemcontracts.UpgradeBuildInSystemContract(w.chainConfig, header.Number, parent.Time, header.Time, env.state)
|
||||
if !w.chainConfig.IsFeynman(header.Number, header.Time) {
|
||||
// Handle upgrade build-in system contract code
|
||||
systemcontracts.UpgradeBuildInSystemContract(w.chainConfig, header.Number, parent.Time, header.Time, env.state)
|
||||
}
|
||||
|
||||
return env, nil
|
||||
}
|
||||
@@ -974,7 +976,6 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, *big.Int, e
|
||||
fees := work.state.GetBalance(consensus.SystemAddress)
|
||||
block, _, err := w.engine.FinalizeAndAssemble(w.chain, work.header, work.state, work.txs, nil, work.receipts, params.withdrawals)
|
||||
if err != nil {
|
||||
log.Error("!!!DEBUG!!! Failed to assemble block in generateWork", "err", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
return block, fees, nil
|
||||
@@ -1177,7 +1178,6 @@ func (w *worker) commit(env *environment, interval func(), update bool, start ti
|
||||
finalizeStart := time.Now()
|
||||
block, receipts, err := w.engine.FinalizeAndAssemble(w.chain, types.CopyHeader(env.header), env.state, env.txs, nil, env.receipts, nil)
|
||||
if err != nil {
|
||||
log.Error("!!!DEBUG!!! Failed to assemble block in commit", "err", err)
|
||||
return err
|
||||
}
|
||||
// env.receipts = receipts
|
||||
|
||||
@@ -66,27 +66,6 @@ var (
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
||||
// just for prysm compile pass
|
||||
// RopstenChainConfig contains the chain parameters to run a node on the Ropsten test network.
|
||||
RopstenChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(3),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
EIP155Block: big.NewInt(10),
|
||||
EIP158Block: big.NewInt(10),
|
||||
ByzantiumBlock: big.NewInt(1_700_000),
|
||||
ConstantinopleBlock: big.NewInt(4_230_000),
|
||||
PetersburgBlock: big.NewInt(4_939_394),
|
||||
IstanbulBlock: big.NewInt(6_485_846),
|
||||
MuirGlacierBlock: big.NewInt(7_117_117),
|
||||
BerlinBlock: big.NewInt(9_812_189),
|
||||
LondonBlock: big.NewInt(10_499_401),
|
||||
TerminalTotalDifficulty: new(big.Int).SetUint64(50_000_000_000_000_000),
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
||||
// just for prysm compile pass
|
||||
// SepoliaChainConfig contains the chain parameters to run a node on the Sepolia test network.
|
||||
SepoliaChainConfig = &ChainConfig{
|
||||
@@ -209,7 +188,7 @@ var (
|
||||
KeplerTime: newUint64(1702972800),
|
||||
|
||||
// TODO
|
||||
FeynmanTime: _rialto_upgrade_height_,
|
||||
FeynmanTime: nil,
|
||||
|
||||
Parlia: &ParliaConfig{
|
||||
Period: 3,
|
||||
@@ -217,6 +196,7 @@ var (
|
||||
},
|
||||
}
|
||||
|
||||
// used to test hard fork upgrade, following https://github.com/bnb-chain/bsc-genesis-contract/blob/master/genesis.json
|
||||
RialtoChainConfig = &ChainConfig{
|
||||
ChainID: big.NewInt(714),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
@@ -233,9 +213,9 @@ var (
|
||||
MirrorSyncBlock: big.NewInt(1),
|
||||
BrunoBlock: big.NewInt(1),
|
||||
EulerBlock: big.NewInt(2),
|
||||
GibbsBlock: big.NewInt(3),
|
||||
NanoBlock: nil,
|
||||
MoranBlock: big.NewInt(4),
|
||||
NanoBlock: big.NewInt(3),
|
||||
MoranBlock: big.NewInt(3),
|
||||
GibbsBlock: big.NewInt(4),
|
||||
PlanckBlock: big.NewInt(5),
|
||||
LubanBlock: big.NewInt(6),
|
||||
PlatoBlock: big.NewInt(7),
|
||||
@@ -243,15 +223,13 @@ var (
|
||||
LondonBlock: big.NewInt(8),
|
||||
HertzBlock: big.NewInt(8),
|
||||
HertzfixBlock: big.NewInt(8),
|
||||
|
||||
// TODO
|
||||
ShanghaiTime: _rialto_upgrade_height_,
|
||||
KeplerTime: _rialto_upgrade_height_,
|
||||
FeynmanTime: _rialto_upgrade_height_,
|
||||
ShanghaiTime: newUint64(0),
|
||||
KeplerTime: newUint64(0),
|
||||
FeynmanTime: newUint64(0),
|
||||
|
||||
Parlia: &ParliaConfig{
|
||||
Period: _rialto_parlia_period_,
|
||||
Epoch: _rialto_parlia_epoch_,
|
||||
Period: 3,
|
||||
Epoch: 200,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -458,10 +436,10 @@ var NetworkNames = map[string]string{
|
||||
type ChainConfig struct {
|
||||
ChainID *big.Int `json:"chainId"` // chainId identifies the current chain and is used for replay protection
|
||||
|
||||
HomesteadBlock *big.Int `json:"homesteadBlock,omitempty" toml:",omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
|
||||
HomesteadBlock *big.Int `json:"homesteadBlock,omitempty"` // Homestead switch block (nil = no fork, 0 = already homestead)
|
||||
|
||||
DAOForkBlock *big.Int `json:"daoForkBlock,omitempty" toml:",omitempty"` // TheDAO hard-fork switch block (nil = no fork)
|
||||
DAOForkSupport bool `json:"daoForkSupport,omitempty" toml:",omitempty"` // Whether the nodes supports or opposes the DAO hard-fork
|
||||
DAOForkBlock *big.Int `json:"daoForkBlock,omitempty"` // TheDAO hard-fork switch block (nil = no fork)
|
||||
DAOForkSupport bool `json:"daoForkSupport,omitempty"` // Whether the nodes supports or opposes the DAO hard-fork
|
||||
|
||||
// EIP150 implements the Gas price changes (https://github.com/ethereum/EIPs/issues/150)
|
||||
EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
|
||||
@@ -483,12 +461,12 @@ type ChainConfig struct {
|
||||
|
||||
// Fork scheduling was switched from blocks to timestamps here
|
||||
|
||||
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty" toml:",omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
||||
KeplerTime *uint64 `json:"keplerTime,omitempty" toml:",omitempty"` // Kepler switch time (nil = no fork, 0 = already activated)
|
||||
FeynmanTime *uint64 `json:"feynmanTime,omitempty" toml:",omitempty"` // Feynman switch time (nil = no fork, 0 = already activated)
|
||||
CancunTime *uint64 `json:"cancunTime,omitempty" toml:",omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
|
||||
PragueTime *uint64 `json:"pragueTime,omitempty" toml:",omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
||||
VerkleTime *uint64 `json:"verkleTime,omitempty" toml:",omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
||||
ShanghaiTime *uint64 `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
|
||||
KeplerTime *uint64 `json:"keplerTime,omitempty"` // Kepler switch time (nil = no fork, 0 = already activated)
|
||||
FeynmanTime *uint64 `json:"feynmanTime,omitempty"` // Feynman switch time (nil = no fork, 0 = already activated)
|
||||
CancunTime *uint64 `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
|
||||
PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
|
||||
VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle)
|
||||
|
||||
// TerminalTotalDifficulty is the amount of total difficulty reached by
|
||||
// the network that triggers the consensus upgrade.
|
||||
@@ -499,23 +477,23 @@ type ChainConfig struct {
|
||||
// even without having seen the TTD locally (safer long term).
|
||||
TerminalTotalDifficultyPassed bool `json:"terminalTotalDifficultyPassed,omitempty"`
|
||||
|
||||
RamanujanBlock *big.Int `json:"ramanujanBlock,omitempty" toml:",omitempty"` // ramanujanBlock switch block (nil = no fork, 0 = already activated)
|
||||
NielsBlock *big.Int `json:"nielsBlock,omitempty" toml:",omitempty"` // nielsBlock switch block (nil = no fork, 0 = already activated)
|
||||
MirrorSyncBlock *big.Int `json:"mirrorSyncBlock,omitempty" toml:",omitempty"` // mirrorSyncBlock switch block (nil = no fork, 0 = already activated)
|
||||
BrunoBlock *big.Int `json:"brunoBlock,omitempty" toml:",omitempty"` // brunoBlock switch block (nil = no fork, 0 = already activated)
|
||||
EulerBlock *big.Int `json:"eulerBlock,omitempty" toml:",omitempty"` // eulerBlock switch block (nil = no fork, 0 = already activated)
|
||||
GibbsBlock *big.Int `json:"gibbsBlock,omitempty" toml:",omitempty"` // gibbsBlock switch block (nil = no fork, 0 = already activated)
|
||||
NanoBlock *big.Int `json:"nanoBlock,omitempty" toml:",omitempty"` // nanoBlock switch block (nil = no fork, 0 = already activated)
|
||||
MoranBlock *big.Int `json:"moranBlock,omitempty" toml:",omitempty"` // moranBlock switch block (nil = no fork, 0 = already activated)
|
||||
PlanckBlock *big.Int `json:"planckBlock,omitempty" toml:",omitempty"` // planckBlock switch block (nil = no fork, 0 = already activated)
|
||||
LubanBlock *big.Int `json:"lubanBlock,omitempty" toml:",omitempty"` // lubanBlock switch block (nil = no fork, 0 = already activated)
|
||||
PlatoBlock *big.Int `json:"platoBlock,omitempty" toml:",omitempty"` // platoBlock switch block (nil = no fork, 0 = already activated)
|
||||
HertzBlock *big.Int `json:"hertzBlock,omitempty" toml:",omitempty"` // hertzBlock switch block (nil = no fork, 0 = already activated)
|
||||
HertzfixBlock *big.Int `json:"hertzfixBlock,omitempty" toml:",omitempty"` // hertzfixBlock switch block (nil = no fork, 0 = already activated)
|
||||
RamanujanBlock *big.Int `json:"ramanujanBlock,omitempty"` // ramanujanBlock switch block (nil = no fork, 0 = already activated)
|
||||
NielsBlock *big.Int `json:"nielsBlock,omitempty"` // nielsBlock switch block (nil = no fork, 0 = already activated)
|
||||
MirrorSyncBlock *big.Int `json:"mirrorSyncBlock,omitempty"` // mirrorSyncBlock switch block (nil = no fork, 0 = already activated)
|
||||
BrunoBlock *big.Int `json:"brunoBlock,omitempty"` // brunoBlock switch block (nil = no fork, 0 = already activated)
|
||||
EulerBlock *big.Int `json:"eulerBlock,omitempty"` // eulerBlock switch block (nil = no fork, 0 = already activated)
|
||||
GibbsBlock *big.Int `json:"gibbsBlock,omitempty"` // gibbsBlock switch block (nil = no fork, 0 = already activated)
|
||||
NanoBlock *big.Int `json:"nanoBlock,omitempty"` // nanoBlock switch block (nil = no fork, 0 = already activated)
|
||||
MoranBlock *big.Int `json:"moranBlock,omitempty"` // moranBlock switch block (nil = no fork, 0 = already activated)
|
||||
PlanckBlock *big.Int `json:"planckBlock,omitempty"` // planckBlock switch block (nil = no fork, 0 = already activated)
|
||||
LubanBlock *big.Int `json:"lubanBlock,omitempty"` // lubanBlock switch block (nil = no fork, 0 = already activated)
|
||||
PlatoBlock *big.Int `json:"platoBlock,omitempty"` // platoBlock switch block (nil = no fork, 0 = already activated)
|
||||
HertzBlock *big.Int `json:"hertzBlock,omitempty"` // hertzBlock switch block (nil = no fork, 0 = already activated)
|
||||
HertzfixBlock *big.Int `json:"hertzfixBlock,omitempty"` // hertzfixBlock switch block (nil = no fork, 0 = already activated)
|
||||
// Various consensus engines
|
||||
Ethash *EthashConfig `json:"ethash,omitempty" toml:",omitempty"`
|
||||
Clique *CliqueConfig `json:"clique,omitempty" toml:",omitempty"`
|
||||
Parlia *ParliaConfig `json:"parlia,omitempty" toml:",omitempty"`
|
||||
Ethash *EthashConfig `json:"ethash,omitempty"`
|
||||
Clique *CliqueConfig `json:"clique,omitempty"`
|
||||
Parlia *ParliaConfig `json:"parlia,omitempty"`
|
||||
IsDevMode bool `json:"isDev,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user