Skip to content
Merged
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
2 changes: 1 addition & 1 deletion cmd/platon/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func initGenesis(ctx *cli.Context) error {
}
var sdb snapshotdb.DB
if name == "chaindata" {
sdb, err = snapshotdb.Open(stack.ResolvePath(snapshotdb.DBPath), 0, 0, true)
sdb, err = snapshotdb.Open(stack.ResolvePath(snapshotdb.DBPath), 0, 0, true, false)
if err != nil {
utils.Fatalf("Failed to open snapshotdb: %v", err)
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/platon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, platonConfig) {
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
stack, cfg := makeConfigNode(ctx)
snapshotdb.SetDBPathWithNode(stack.ResolvePath(snapshotdb.DBPath))

snapshotdb.SetEnableArchiveWithNode(cfg.Eth.SnapshotArchive)
snapshotdb.SetArchiveTrieOversizeThreshold(cfg.Eth.SnapshotArchiveTrieOversizeThreshold)
snapshotdb.SetArchiveDatabaseCache(cfg.Eth.SnapshotArchiveDatabaseCache)
backend, eth := utils.RegisterEthService(stack, &cfg.Eth)
// Warn users to migrate if they have a legacy freezer format.
if eth != nil && !ctx.IsSet(utils.IgnoreLegacyReceiptsFlag.Name) {
Expand Down
3 changes: 3 additions & 0 deletions cmd/platon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ var (
utils.GpoIgnoreGasPriceFlag,
utils.IgnoreLegacyReceiptsFlag,
configFileFlag,
utils.SnapshotArchiveFlag,
utils.SnapshotArchiveTrieOversizeThresholdFlag,
utils.SnapshotArchiveDatabaseCacheFlag,
}, utils.NetworkFlags, utils.DatabasePathFlags)

rpcFlags = []cli.Flag{
Expand Down
29 changes: 28 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,24 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
Value: ethconfig.Defaults.VmTimeoutDuration,
Category: flags.VMCategory,
}
SnapshotArchiveFlag = &cli.BoolFlag{
Name: "snapshot.archive",
Usage: "Take a snapshot archive",
Value: ethconfig.Defaults.SnapshotArchive,
Category: flags.SnapshotDbCategory,
}
SnapshotArchiveTrieOversizeThresholdFlag = &cli.Uint64Flag{
Name: "snapshot.archive.triecache",
Usage: "Megabytes of memory allocated to trie cache",
Value: ethconfig.Defaults.SnapshotArchiveTrieOversizeThreshold,
Category: flags.SnapshotDbCategory,
}
SnapshotArchiveDatabaseCacheFlag = &cli.IntFlag{
Name: "snapshot.archive.dbcache",
Usage: "Megabytes of memory allocated to archive database cache",
Value: ethconfig.Defaults.SnapshotArchiveDatabaseCache,
Category: flags.SnapshotDbCategory,
}
)

var (
Expand Down Expand Up @@ -1527,6 +1545,15 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if ctx.IsSet(VmTimeoutDuration.Name) {
cfg.VmTimeoutDuration = ctx.Uint64(VmTimeoutDuration.Name)
}
if ctx.IsSet(SnapshotArchiveFlag.Name) {
cfg.SnapshotArchive = ctx.Bool(SnapshotArchiveFlag.Name)
}
if ctx.IsSet(SnapshotArchiveTrieOversizeThresholdFlag.Name) {
cfg.SnapshotArchiveTrieOversizeThreshold = ctx.Uint64(SnapshotArchiveTrieOversizeThresholdFlag.Name)
}
if ctx.IsSet(SnapshotArchiveDatabaseCacheFlag.Name) {
cfg.SnapshotArchiveDatabaseCache = ctx.Int(SnapshotArchiveDatabaseCacheFlag.Name)
}
}

// SetDNSDiscoveryDefaults configures DNS discovery with the given URL if
Expand Down Expand Up @@ -1780,7 +1807,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
//if err != nil {
// Fatalf("%v", err)
//}
basedb, err := snapshotdb.Open(stack.ResolvePath(snapshotdb.DBPath), 0, 0, true)
basedb, err := snapshotdb.Open(stack.ResolvePath(snapshotdb.DBPath), 0, 0, true, false)
if err != nil {
Fatalf("%v", err)
}
Expand Down
3 changes: 2 additions & 1 deletion consensus/bft_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/PlatONnetwork/PlatON-Go/core/rawdb"
"github.com/PlatONnetwork/PlatON-Go/core/snapshotdb"
"github.com/PlatONnetwork/PlatON-Go/params"

"github.com/PlatONnetwork/PlatON-Go/p2p/enode"
Expand Down Expand Up @@ -122,7 +123,7 @@ func (bm *BftMock) InsertChain(block *types.Block) error {
}

statedb, err := bm.chain.StateAt(root)
gov.AddActiveVersion(params.FORKVERSION_1_6_0, 1, statedb)
gov.NewGovDB(snapshotdb.Instance()).AddActiveVersion(params.FORKVERSION_1_6_0, 1, statedb)
if err != nil {
return err
}
Expand Down
6 changes: 2 additions & 4 deletions consensus/cbft/cbft_common_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (

"github.com/PlatONnetwork/PlatON-Go/core/rawdb"

"github.com/PlatONnetwork/PlatON-Go/x/xcom"

cvm "github.com/PlatONnetwork/PlatON-Go/common/vm"

"github.com/PlatONnetwork/PlatON-Go/consensus/cbft/network"
Expand Down Expand Up @@ -154,8 +152,8 @@ func CreateGenesis(db ethdb.Database) (core.Genesis, *types.Block) {
Alloc: core.GenesisAlloc{},
}
)
gspec.Alloc[xcom.PlatONFundAccount()] = core.GenesisAccount{
Balance: xcom.PlatONFundBalance(),
gspec.Alloc[params.PlatONFundAccount()] = core.GenesisAccount{
Balance: params.PlatONFundBalance(),
}
gspec.Alloc[cvm.RewardManagerPoolAddr] = core.GenesisAccount{
Balance: twoBillion,
Expand Down
2 changes: 1 addition & 1 deletion core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func CalcGasCeil(parent *types.Block, db snapshotdb.DB) uint64 {
if db == nil {
gasCeil = params.DefaultMinerGasCeil
} else {
govGasCeil, err := gov.GovernMaxBlockGasLimit(parent.Number().Uint64()+1, common.ZeroHash, db)
govGasCeil, err := gov.NewGov(db).GovernMaxBlockGasLimit(parent.Number().Uint64()+1, common.ZeroHash, db)
if nil != err {
log.Error("cannot find GasLimit from govern", "err", err)
gasCeil = params.DefaultMinerGasCeil
Expand Down
3 changes: 2 additions & 1 deletion core/blockchain_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/PlatONnetwork/PlatON-Go/common"
"github.com/PlatONnetwork/PlatON-Go/consensus"
"github.com/PlatONnetwork/PlatON-Go/core/snapshotdb"
"github.com/PlatONnetwork/PlatON-Go/core/state"
"github.com/PlatONnetwork/PlatON-Go/core/types"
"github.com/PlatONnetwork/PlatON-Go/log"
Expand Down Expand Up @@ -317,7 +318,7 @@ func (bcc *BlockChainCache) executeBlock(block *types.Block, parent *types.Block
log.Error("BlockChainCache MakeStateDB failed", "err", err)
return err
}
SenderCacher.RecoverFromBlock(types.MakeSigner(bcc.chainConfig, block.Number(), gov.Gte150VersionState(state)), block)
SenderCacher.RecoverFromBlock(types.MakeSigner(bcc.chainConfig, block.Number(), gov.NewGov(snapshotdb.Instance()).Gte150VersionState(state)), block)
if err != nil {
return errors.New("execute block error")
}
Expand Down
4 changes: 2 additions & 2 deletions core/blockchain_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (bcr *BlockChainReactor) commit(block *types.Block) error {
/**
notify P2P module the nodeId of the next round validator
*/
if plugin, ok := bcr.basePluginMap[xcom.StakingRule]; ok {
if plugin, ok := bcr.basePluginMap[params.StakingRule]; ok {
if err := plugin.Confirmed(bcr.NodeId, block); nil != err {
log.Error("Failed to call Staking Confirmed", "blockNumber", block.Number(), "blockHash", block.Hash().Hex(), "err", err.Error())
}
Expand Down Expand Up @@ -206,7 +206,7 @@ func (bcr *BlockChainReactor) SetWorkerCoinBase(header *types.Header, nodeId eno
panic(fmt.Sprintf("parse current nodeId is failed: %s", err.Error()))
}

if plu, ok := bcr.basePluginMap[xcom.StakingRule]; ok {
if plu, ok := bcr.basePluginMap[params.StakingRule]; ok {
stake := plu.(*plugin.StakingPlugin)
can, err := stake.GetCandidateInfo(common.ZeroHash, nodeIdAddr)
if nil != err {
Expand Down
6 changes: 3 additions & 3 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type BlockGen struct {
}

func (b *BlockGen) SetActiveVersion(version uint32) {
gov.AddActiveVersion(version, 0, b.statedb)
gov.NewGovDB(snapshotdb.Instance()).AddActiveVersion(version, 0, b.statedb)
}

// SetCoinbase sets the coinbase of the generated block.
Expand Down Expand Up @@ -261,7 +261,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
}
for i := 0; i < n; i++ {
statedb, err := state.New(parent.Root(), state.NewDatabase(db), nil)
gov.AddActiveVersion(params.FORKVERSION_1_6_0, 1, statedb)
gov.NewGovDB(snapshotdb.Instance()).AddActiveVersion(params.FORKVERSION_1_6_0, 1, statedb)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -319,7 +319,7 @@ func GenerateBlockChain2(gspec *Genesis, parent *types.Block, engine consensus.E
if err != nil {
panic(err)
}
gov.AddActiveVersion(params.FORKVERSION_1_6_0, 1, statedb)
gov.NewGovDB(snapshotdb.Instance()).AddActiveVersion(params.FORKVERSION_1_6_0, 1, statedb)
block, receipt := genblock(i, parent, statedb)
errCh := make(chan error, 1)
errCh <- engine.InsertChain(block)
Expand Down
5 changes: 2 additions & 3 deletions core/gen_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/PlatONnetwork/PlatON-Go/common/hexutil"
"github.com/PlatONnetwork/PlatON-Go/common/math"
"github.com/PlatONnetwork/PlatON-Go/params"
"github.com/PlatONnetwork/PlatON-Go/x/xcom"
)

var _ = (*genesisSpecMarshaling)(nil)
Expand All @@ -18,7 +17,7 @@ var _ = (*genesisSpecMarshaling)(nil)
func (g Genesis) MarshalJSON() ([]byte, error) {
type Genesis struct {
Config *params.ChainConfig `json:"config"`
EconomicModel *xcom.EconomicModel `json:"economicModel"`
EconomicModel *params.EconomicModel `json:"economicModel"`
Nonce hexutil.Bytes `json:"nonce"`
Timestamp math.HexOrDecimal64 `json:"timestamp"`
ExtraData hexutil.Bytes `json:"extraData"`
Expand Down Expand Up @@ -50,7 +49,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
func (g *Genesis) UnmarshalJSON(input []byte) error {
type Genesis struct {
Config *params.ChainConfig `json:"config"`
EconomicModel *xcom.EconomicModel `json:"economicModel"`
EconomicModel *params.EconomicModel `json:"economicModel"`
Nonce *hexutil.Bytes `json:"nonce"`
Timestamp *math.HexOrDecimal64 `json:"timestamp"`
ExtraData *hexutil.Bytes `json:"extraData"`
Expand Down
Loading
Loading