Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

feat(abci): add a custom process proposal #1286

Merged
merged 7 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions cosmos/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ func readConfigFromAppOptsParser(parser AppOptionsParser) (*Config, error) {
conf := &Config{}

// Polar settings
if conf.Polar.IsMainnet, err =
parser.GetBool(flags.IsMainnet); err != nil {
return nil, err
}

if conf.Polar.RPCGasCap, err =
parser.GetUint64(flags.RPCGasCap); err != nil {
return nil, err
Expand Down
1 change: 1 addition & 0 deletions cosmos/config/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package flags

const (
// Polar Root.
IsMainnet = "polaris.polar.is-mainnet"
RPCEvmTimeout = "polaris.polar.rpc-evm-timeout"
RPCTxFeeCap = "polaris.polar.rpc-tx-fee-cap"
RPCGasCap = "polaris.polar.rpc-gas-cap"
Expand Down
2 changes: 2 additions & 0 deletions cosmos/config/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const (
# General Polaris settings
[polaris]

is-mainnet = "{{Polaris.Polar.IsMainnet}}

[polaris.polar]
# Gas cap for RPC requests
rpc-gas-cap = "{{ .Polaris.Polar.RPCGasCap }}"
Expand Down
2 changes: 1 addition & 1 deletion cosmos/x/evm/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ var _ = Describe("Genesis", func() {
cfg,
)
err = k.Setup(
core.NewChain(k.Host, params.DefaultChainConfig, beacon.NewFaker()),
core.NewChain(k.Host, params.DefaultChainConfig, beacon.NewFaker(), true),
)
Expect(err).ToNot(HaveOccurred())

Expand Down
4 changes: 3 additions & 1 deletion eth/core/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type blockchain struct {
rmLogsFeed event.Feed // currently never used
chainSideFeed event.Feed // currently never used
logger log.Logger
isMainnet bool
}

// =========================================================================
Expand All @@ -110,7 +111,7 @@ type blockchain struct {

// NewChain creates and returns a `api.Chain` with the given EVM chain configuration and host.
func NewChain(
host PolarisHostChain, config *params.ChainConfig, engine consensus.Engine,
host PolarisHostChain, config *params.ChainConfig, engine consensus.Engine, isMainnet bool,
) *blockchain { //nolint:revive // only used as `api.Chain`.
bc := &blockchain{
bp: host.GetBlockPlugin(),
Expand All @@ -127,6 +128,7 @@ func NewChain(
scope: event.SubscriptionScope{},
logger: log.Root(),
engine: engine,
isMainnet: isMainnet,
}
bc.statedb = state.NewStateDB(bc.sp, bc.pp)
bc.processor = core.NewStateProcessor(bc.config, bc, bc.engine)
Expand Down
8 changes: 6 additions & 2 deletions eth/core/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func (bc *blockchain) InsertBlockAndSetHead(block *types.Block) error {
if block.NumberU64() > 1 { // TODO DIAGNOSE
itsdevbear marked this conversation as resolved.
Show resolved Hide resolved
if err := bc.validator.ValidateBody(block); err != nil {
log.Error("invalid block body", "err", err)
return err
if bc.isMainnet {
return err
}
}
}

itsdevbear marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -70,7 +72,9 @@ func (bc *blockchain) InsertBlockAndSetHead(block *types.Block) error {
// ValidateState validates the statedb post block processing.
if err = bc.validator.ValidateState(block, bc.statedb, receipts, usedGas); err != nil {
log.Error("invalid state after processing block", "num", block.NumberU64(), "err", err)
return err
if bc.isMainnet {
return err
}
}

itsdevbear marked this conversation as resolved.
Show resolved Hide resolved
// We can just immediately finalize the block. It's okay in this context.
Expand Down
2 changes: 1 addition & 1 deletion eth/polar/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func New(
config: config,
host: host,
engine: engine,
blockchain: core.NewChain(host, &config.Chain, engine),
blockchain: core.NewChain(host, &config.Chain, engine, config.IsMainnet),
}

// Build the backend api object.
Expand Down
3 changes: 3 additions & 0 deletions eth/polar/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ type Config struct {
// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
// send-transaction variants. The unit is ether.
RPCTxFeeCap float64

// IsMainnet is used to enable extra safety checks for a live mainnet.
IsMainnet bool
}
Loading