Skip to content

Commit

Permalink
Fix MinGasPrice override - move into flags (Fantom-foundation#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Kalina authored Oct 19, 2023
1 parent 9e3641d commit e8a1545
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
13 changes: 10 additions & 3 deletions cmd/opera/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/Fantom-foundation/Carmen/go/evmstore"
"github.com/Fantom-foundation/go-opera/opera"
"github.com/Fantom-foundation/go-opera/statedb"
"math/big"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -68,12 +69,10 @@ var (
Name: "statedb.impl",
Usage: "Implementation of StateDB to use (geth/carmen-s3/carmen-s5)",
}

archiveImplFlag = cli.StringFlag{
Name: "archive.impl",
Usage: "Implementation of Carmen Archive to use (none/ldb/s5)",
}

vmImplFlag = cli.StringFlag{
Name: "vm.impl",
Usage: "Implementation of EVM to use (geth/lfvm/lfvm-si)",
Expand All @@ -83,7 +82,6 @@ var (
Name: "noevmlogs",
Usage: "Disable recording of EVM logs",
}

disableTxHashesFlag = cli.BoolFlag{
Name: "notxhashes",
Usage: "Disable indexing of tx hashes",
Expand All @@ -94,6 +92,11 @@ var (
Usage: "Switch to using Carmen EvmStore for receipts and txs.",
}

overrideMinGasPriceFlag = cli.Uint64Flag{
Name: "overridemingasprice",
Usage: "Override the MinGasPrice with given value",
}

// DataDirFlag defines directory to store Lachesis state and user's wallets
DataDirFlag = utils.DirectoryFlag{
Name: "datadir",
Expand Down Expand Up @@ -602,6 +605,10 @@ func mayMakeAllConfigs(ctx *cli.Context) (*config, error) {
opera.DefaultVMConfig.InterpreterImpl = impl
}

if overrideMinGasPrice := ctx.GlobalUint64(overrideMinGasPriceFlag.Name); overrideMinGasPrice != 0 {
opera.OverrideMinGasPrice = big.NewInt(int64(overrideMinGasPrice))
}

if ctx.GlobalBool(disableLogsFlag.Name) {
cfg.OperaStore.EVM.DisableLogsIndexing = true
}
Expand Down
1 change: 1 addition & 0 deletions cmd/opera/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func initFlags() {
disableLogsFlag,
disableTxHashesFlag,
carmenEvmStoreFlag,
overrideMinGasPriceFlag,
}
legacyRpcFlags = []cli.Flag{
utils.NoUSBFlag,
Expand Down
3 changes: 1 addition & 2 deletions example-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"MaxEventGas": 10028000000,
"MaxEpochGas": 1500000000000,
"ShortGasAllocPerSec": 5600000000000,
"LongGasAllocPerSec": 2800000000000,
"OverrideMinGasPrice": 10
"LongGasAllocPerSec": 2800000000000
},
"accounts": [
{
Expand Down
5 changes: 0 additions & 5 deletions integration/makefakegenesis/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ type NetworkRules struct {
MaxEventGas *uint64 `json:",omitempty"`
LongGasAllocPerSec *uint64 `json:",omitempty"`
ShortGasAllocPerSec *uint64 `json:",omitempty"`
OverrideMinGasPrice *uint64 `json:",omitempty"`
}

type Account struct {
Expand Down Expand Up @@ -103,10 +102,6 @@ func ApplyGenesisJson(json *GenesisJson) (*genesisstore.Store, error) {
if json.Rules.LongGasAllocPerSec != nil {
rules.Economy.LongGasPower.AllocPerSec = *json.Rules.LongGasAllocPerSec
}
if json.Rules.OverrideMinGasPrice != nil {
opera.OverrideMinGasPrice = big.NewInt(int64(*json.Rules.OverrideMinGasPrice))
rules.Economy.MinGasPrice = opera.OverrideMinGasPrice
}

builder.SetCurrentEpoch(ier.LlrIdxFullEpochRecord{
LlrFullEpochRecord: ier.LlrFullEpochRecord{
Expand Down
7 changes: 6 additions & 1 deletion opera/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,18 @@ func FakeNetRules() Rules {

// DefaultEconomyRules returns mainnet economy
func DefaultEconomyRules() EconomyRules {
return EconomyRules{
rules := EconomyRules{
BlockMissedSlack: 50,
Gas: DefaultGasRules(),
MinGasPrice: big.NewInt(1e9),
ShortGasPower: DefaultShortGasPowerRules(),
LongGasPower: DefaulLongGasPowerRules(),
}
// hack for performance testing
if OverrideMinGasPrice != nil && OverrideMinGasPrice.Sign() > 0 {
rules.MinGasPrice = OverrideMinGasPrice
}
return rules
}

// FakeEconomyRules returns fakenet economy
Expand Down

0 comments on commit e8a1545

Please sign in to comment.