Skip to content

Commit

Permalink
chore: add evm-bridges list to evtforward config
Browse files Browse the repository at this point in the history
  • Loading branch information
wwestgarth committed Apr 18, 2024
1 parent 21fd81b commit 1dd665b
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 101 deletions.
3 changes: 0 additions & 3 deletions cmd/vega/commands/faucet/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func (opts *faucetInit) Execute(_ []string) error {
nodeCfg.EvtForward.BlockchainQueueAllowlist = append(
nodeCfg.EvtForward.BlockchainQueueAllowlist, initResult.Wallet.PublicKey)

nodeCfg.SecondaryEvtForward.BlockchainQueueAllowlist = append(
nodeCfg.SecondaryEvtForward.BlockchainQueueAllowlist, initResult.Wallet.PublicKey)

if err := nodeCfgLoader.Save(nodeCfg); err != nil {
return fmt.Errorf("couldn't update node configuration: %w", err)
}
Expand Down
148 changes: 73 additions & 75 deletions core/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,44 +66,43 @@ import (

// Config ties together all other application configuration types.
type Config struct {
Admin admin.Config `group:"Admin" namespace:"admin"`
API api.Config `group:"API" namespace:"api"`
Blockchain blockchain.Config `group:"Blockchain" namespace:"blockchain"`
Collateral collateral.Config `group:"Collateral" namespace:"collateral"`
CoreAPI coreapi.Config `group:"CoreAPI" namespace:"coreapi"`
Execution execution.Config `group:"Execution" namespace:"execution"`
Ethereum eth.Config `group:"Ethereum" namespace:"ethereum"`
Processor processor.Config `group:"Processor" namespace:"processor"`
Logging logging.Config `group:"Logging" namespace:"logging"`
Oracles spec.Config `group:"Oracles" namespace:"oracles"`
Time vegatime.Config `group:"Time" namespace:"time"`
Epoch epochtime.Config `group:"Epoch" namespace:"epochtime"`
Metrics metrics.Config `group:"Metrics" namespace:"metrics"`
Governance governance.Config `group:"Governance" namespace:"governance"`
NodeWallet nodewallets.Config `group:"NodeWallet" namespace:"nodewallet"`
Assets assets.Config `group:"Assets" namespace:"assets"`
Notary notary.Config `group:"Notary" namespace:"notary"`
EvtForward evtforward.Config `group:"EvtForward" namespace:"evtForward"`
SecondaryEvtForward evtforward.Config `group:"SecondaryEvtForward" namespace:"secondaryEvtForward"`
Genesis genesis.Config `group:"Genesis" namespace:"genesis"`
Validators validators.Config `group:"Validators" namespace:"validators"`
Banking banking.Config `group:"Banking" namespace:"banking"`
Stats stats.Config `group:"Stats" namespace:"stats"`
NetworkParameters netparams.Config `group:"NetworkParameters" namespace:"netparams"`
Limits limits.Config `group:"Limits" namespace:"limits"`
Checkpoint checkpoint.Config `group:"Checkpoint" namespace:"checkpoint"`
Staking staking.Config `group:"Staking" namespace:"staking"`
Broker broker.Config `group:"Broker" namespace:"broker"`
Rewards rewards.Config `group:"Rewards" namespace:"rewards"`
Delegation delegation.Config `group:"Delegation" namespace:"delegation"`
Spam spam.Config `group:"Spam" namespace:"spam"`
PoW pow.Config `group:"ProofOfWork" namespace:"pow"`
Snapshot snapshot.Config `group:"Snapshot" namespace:"snapshot"`
StateVar statevar.Config `group:"StateVar" namespace:"statevar"`
ERC20MultiSig erc20multisig.Config `group:"ERC20MultiSig" namespace:"erc20multisig"`
ProtocolUpgrade protocolupgrade.Config `group:"ProtocolUpgrade" namespace:"protocolupgrade"`
Pprof pprof.Config `group:"Pprof" namespace:"pprof"`
Vesting vesting.Config `group:"Vesting" namespace:"vesting"`
Admin admin.Config `group:"Admin" namespace:"admin"`

Check failure on line 69 in core/config/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"Admin" namespace:"admin" (tagalign)
API api.Config `group:"API" namespace:"api"`

Check failure on line 70 in core/config/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"API" namespace:"api" (tagalign)
Blockchain blockchain.Config `group:"Blockchain" namespace:"blockchain"`

Check failure on line 71 in core/config/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"Blockchain" namespace:"blockchain" (tagalign)
Collateral collateral.Config `group:"Collateral" namespace:"collateral"`

Check failure on line 72 in core/config/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"Collateral" namespace:"collateral" (tagalign)
CoreAPI coreapi.Config `group:"CoreAPI" namespace:"coreapi"`

Check failure on line 73 in core/config/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"CoreAPI" namespace:"coreapi" (tagalign)
Execution execution.Config `group:"Execution" namespace:"execution"`
Ethereum eth.Config `group:"Ethereum" namespace:"ethereum"`
Processor processor.Config `group:"Processor" namespace:"processor"`
Logging logging.Config `group:"Logging" namespace:"logging"`
Oracles spec.Config `group:"Oracles" namespace:"oracles"`
Time vegatime.Config `group:"Time" namespace:"time"`
Epoch epochtime.Config `group:"Epoch" namespace:"epochtime"`
Metrics metrics.Config `group:"Metrics" namespace:"metrics"`
Governance governance.Config `group:"Governance" namespace:"governance"`
NodeWallet nodewallets.Config `group:"NodeWallet" namespace:"nodewallet"`
Assets assets.Config `group:"Assets" namespace:"assets"`
Notary notary.Config `group:"Notary" namespace:"notary"`
EvtForward evtforward.Config `group:"EvtForward" namespace:"evtForward"`
Genesis genesis.Config `group:"Genesis" namespace:"genesis"`
Validators validators.Config `group:"Validators" namespace:"validators"`
Banking banking.Config `group:"Banking" namespace:"banking"`
Stats stats.Config `group:"Stats" namespace:"stats"`
NetworkParameters netparams.Config `group:"NetworkParameters" namespace:"netparams"`
Limits limits.Config `group:"Limits" namespace:"limits"`
Checkpoint checkpoint.Config `group:"Checkpoint" namespace:"checkpoint"`
Staking staking.Config `group:"Staking" namespace:"staking"`
Broker broker.Config `group:"Broker" namespace:"broker"`
Rewards rewards.Config `group:"Rewards" namespace:"rewards"`
Delegation delegation.Config `group:"Delegation" namespace:"delegation"`
Spam spam.Config `group:"Spam" namespace:"spam"`
PoW pow.Config `group:"ProofOfWork" namespace:"pow"`
Snapshot snapshot.Config `group:"Snapshot" namespace:"snapshot"`
StateVar statevar.Config `group:"StateVar" namespace:"statevar"`
ERC20MultiSig erc20multisig.Config `group:"ERC20MultiSig" namespace:"erc20multisig"`
ProtocolUpgrade protocolupgrade.Config `group:"ProtocolUpgrade" namespace:"protocolupgrade"`
Pprof pprof.Config `group:"Pprof" namespace:"pprof"`
Vesting vesting.Config `group:"Vesting" namespace:"vesting"`

NodeMode cfgencoding.NodeMode `description:"The mode of the vega node [validator, full]" long:"mode"`
MaxMemoryPercent uint8 `description:"The maximum amount of memory reserved for the vega node (default: 33%)" long:"max-memory-percent"`
Expand All @@ -113,43 +112,42 @@ type Config struct {
// config level, if there is an error initialising any of the configs then this is returned.
func NewDefaultConfig() Config {
return Config{
NodeMode: cfgencoding.NodeModeValidator,
MaxMemoryPercent: 33,
Admin: admin.NewDefaultConfig(),
API: api.NewDefaultConfig(),
CoreAPI: coreapi.NewDefaultConfig(),
Blockchain: blockchain.NewDefaultConfig(),
Execution: execution.NewDefaultConfig(),
Ethereum: eth.NewDefaultConfig(),
Processor: processor.NewDefaultConfig(),
Oracles: spec.NewDefaultConfig(),
Time: vegatime.NewDefaultConfig(),
Epoch: epochtime.NewDefaultConfig(),
Pprof: pprof.NewDefaultConfig(),
Logging: logging.NewDefaultConfig(),
Collateral: collateral.NewDefaultConfig(),
Metrics: metrics.NewDefaultConfig(),
Governance: governance.NewDefaultConfig(),
NodeWallet: nodewallets.NewDefaultConfig(),
Assets: assets.NewDefaultConfig(),
Notary: notary.NewDefaultConfig(),
EvtForward: evtforward.NewDefaultConfig(),
SecondaryEvtForward: evtforward.NewDefaultConfig(),
Genesis: genesis.NewDefaultConfig(),
Validators: validators.NewDefaultConfig(),
Banking: banking.NewDefaultConfig(),
Stats: stats.NewDefaultConfig(),
NetworkParameters: netparams.NewDefaultConfig(),
Limits: limits.NewDefaultConfig(),
Checkpoint: checkpoint.NewDefaultConfig(),
Staking: staking.NewDefaultConfig(),
Broker: broker.NewDefaultConfig(),
Snapshot: snapshot.DefaultConfig(),
StateVar: statevar.NewDefaultConfig(),
ERC20MultiSig: erc20multisig.NewDefaultConfig(),
PoW: pow.NewDefaultConfig(),
ProtocolUpgrade: protocolupgrade.NewDefaultConfig(),
Vesting: vesting.NewDefaultConfig(),
NodeMode: cfgencoding.NodeModeValidator,
MaxMemoryPercent: 33,
Admin: admin.NewDefaultConfig(),
API: api.NewDefaultConfig(),
CoreAPI: coreapi.NewDefaultConfig(),
Blockchain: blockchain.NewDefaultConfig(),
Execution: execution.NewDefaultConfig(),
Ethereum: eth.NewDefaultConfig(),
Processor: processor.NewDefaultConfig(),
Oracles: spec.NewDefaultConfig(),
Time: vegatime.NewDefaultConfig(),
Epoch: epochtime.NewDefaultConfig(),
Pprof: pprof.NewDefaultConfig(),
Logging: logging.NewDefaultConfig(),
Collateral: collateral.NewDefaultConfig(),
Metrics: metrics.NewDefaultConfig(),
Governance: governance.NewDefaultConfig(),
NodeWallet: nodewallets.NewDefaultConfig(),
Assets: assets.NewDefaultConfig(),
Notary: notary.NewDefaultConfig(),
EvtForward: evtforward.NewDefaultConfig(),
Genesis: genesis.NewDefaultConfig(),
Validators: validators.NewDefaultConfig(),
Banking: banking.NewDefaultConfig(),
Stats: stats.NewDefaultConfig(),
NetworkParameters: netparams.NewDefaultConfig(),
Limits: limits.NewDefaultConfig(),
Checkpoint: checkpoint.NewDefaultConfig(),
Staking: staking.NewDefaultConfig(),
Broker: broker.NewDefaultConfig(),
Snapshot: snapshot.DefaultConfig(),
StateVar: statevar.NewDefaultConfig(),
ERC20MultiSig: erc20multisig.NewDefaultConfig(),
PoW: pow.NewDefaultConfig(),
ProtocolUpgrade: protocolupgrade.NewDefaultConfig(),
Vesting: vesting.NewDefaultConfig(),
}
}

Expand Down
5 changes: 3 additions & 2 deletions core/evtforward/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ type Config struct {
BlockchainQueueAllowlist []string `description:" " long:"blockchain-queue-allowlist"`
// Ethereum groups the configuration related to Ethereum implementation of
// the Event Forwarder.
Ethereum ethereum.Config `group:"Ethereum" namespace:"ethereum"`
EthCall ethcall.Config `group:"EthCall" namespace:"ethcall"`
Ethereum ethereum.Config `group:"Ethereum" namespace:"ethereum"`

Check failure on line 46 in core/evtforward/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"Ethereum" namespace:"ethereum" (tagalign)
EVMBridges []ethereum.Config `group:"EVMBridges" namespace:"evmbridges"`
EthCall ethcall.Config `group:"EthCall" namespace:"ethcall"`

Check failure on line 48 in core/evtforward/config.go

View workflow job for this annotation

GitHub Actions / lint

tag is not aligned, should be: group:"EthCall" namespace:"ethcall" (tagalign)
}

// NewDefaultConfig creates an instance of the package specific configuration.
Expand Down
20 changes: 10 additions & 10 deletions core/evtforward/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
)

type Engine struct {
cfg Config
cfg ethereum.Config
log *logging.Logger

ethEngine *ethereum.Engine
Expand All @@ -39,7 +39,7 @@ type Engine struct {
multisigControlStartingBlock uint64
}

func NewEngine(log *logging.Logger, config Config) *Engine {
func NewEngine(log *logging.Logger, config ethereum.Config) *Engine {
topEngineLogger := log.Named(topEngineLogger)
topEngineLogger.SetLevel(config.Level.Get())

Expand All @@ -50,7 +50,7 @@ func NewEngine(log *logging.Logger, config Config) *Engine {
}

// ReloadConf updates the internal configuration of the Event Forwarder engine.
func (e *Engine) ReloadConf(config Config) {
func (e *Engine) ReloadConf(config ethereum.Config) {
e.log.Info("Reloading configuration")

if e.log.GetLevel() != config.Level.Get() {
Expand All @@ -61,7 +61,7 @@ func (e *Engine) ReloadConf(config Config) {
e.log.SetLevel(config.Level.Get())
}
if e.ethEngine != nil {
e.ethEngine.ReloadConf(config.Ethereum)
e.ethEngine.ReloadConf(config)
}
}

Expand Down Expand Up @@ -105,7 +105,7 @@ func (e *Engine) SetupEthereumEngine(
ethLogger.SetLevel(config.Level.Get())

filterer, err := ethereum.NewLogFilterer(
e.cfg.Ethereum,
e.cfg,
ethLogger,
client,
ethCfg.CollateralBridge(),
Expand All @@ -120,7 +120,7 @@ func (e *Engine) SetupEthereumEngine(
}

e.ethEngine = ethereum.NewEngine(
e.cfg.Ethereum,
e.cfg,
ethLogger,
filterer,
forwarder,
Expand Down Expand Up @@ -170,7 +170,7 @@ func (e *Engine) SetupSecondaryEthereumEngine(
ethLogger.SetLevel(config.Level.Get())

filterer, err := ethereum.NewLogFilterer(
e.cfg.Ethereum,
e.cfg,
ethLogger,
client,
ethCfg.CollateralBridge(),
Expand All @@ -185,7 +185,7 @@ func (e *Engine) SetupSecondaryEthereumEngine(
}

e.ethEngine = ethereum.NewEngine(
e.cfg.Ethereum,
e.cfg,
ethLogger,
filterer,
forwarder,
Expand Down Expand Up @@ -231,7 +231,7 @@ type NoopEngine struct {
log *logging.Logger
}

func NewNoopEngine(log *logging.Logger, config Config) *NoopEngine {
func NewNoopEngine(log *logging.Logger, config ethereum.Config) *NoopEngine {
topEngineLogger := log.Named(topEngineLogger)
topEngineLogger.SetLevel(config.Level.Get())

Expand All @@ -240,7 +240,7 @@ func NewNoopEngine(log *logging.Logger, config Config) *NoopEngine {
}
}

func (e *NoopEngine) ReloadConf(_ Config) {
func (e *NoopEngine) ReloadConf(_ ethereum.Config) {
if e.log.IsDebug() {
e.log.Debug("Reloading Ethereum configuration is a no-op")
}
Expand Down
1 change: 1 addition & 0 deletions core/evtforward/ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Config struct {
Level encoding.LogLevel `long:"log-level"`
MaxEthereumBlocks uint64 `long:"max-ethereum-blocks"`
PollEventRetryDuration encoding.Duration
ChainID string
}

func NewDefaultConfig() Config {
Expand Down
18 changes: 9 additions & 9 deletions core/protocol/all_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,16 @@ func newServices(
svcs.primaryMultisig.SetWitness(svcs.witness)
svcs.secondaryMultisig.SetWitness(svcs.witness)
svcs.primaryEventForwarder = evtforward.New(svcs.log, svcs.conf.EvtForward, svcs.commander, svcs.timeService, svcs.topology)
svcs.secondaryEventForwarder = evtforward.New(svcs.log, svcs.conf.SecondaryEvtForward, svcs.commander, svcs.timeService, svcs.topology)
svcs.secondaryEventForwarder = evtforward.New(svcs.log, svcs.conf.EvtForward, svcs.commander, svcs.timeService, svcs.topology)

if svcs.conf.HaveEthClient() {
svcs.primaryBridgeView = bridges.NewERC20LogicView(primaryEthClient, primaryEthConfirmations)
svcs.secondaryBridgeView = bridges.NewERC20LogicView(secondaryEthClient, secondaryEthConfirmations)
svcs.primaryEventForwarderEngine = evtforward.NewEngine(svcs.log, svcs.conf.EvtForward)
svcs.secondaryEventForwarderEngine = evtforward.NewEngine(svcs.log, svcs.conf.SecondaryEvtForward)
svcs.primaryEventForwarderEngine = evtforward.NewEngine(svcs.log, svcs.conf.EvtForward.Ethereum)
svcs.secondaryEventForwarderEngine = evtforward.NewEngine(svcs.log, svcs.conf.EvtForward.EVMBridges[0])
} else {
svcs.primaryEventForwarderEngine = evtforward.NewNoopEngine(svcs.log, svcs.conf.EvtForward)
svcs.secondaryEventForwarderEngine = evtforward.NewNoopEngine(svcs.log, svcs.conf.SecondaryEvtForward)
svcs.primaryEventForwarderEngine = evtforward.NewNoopEngine(svcs.log, svcs.conf.EvtForward.Ethereum)
svcs.secondaryEventForwarderEngine = evtforward.NewNoopEngine(svcs.log, svcs.conf.EvtForward.EVMBridges[0])
}

svcs.oracle = spec.NewEngine(svcs.log, svcs.conf.Oracles, svcs.timeService, svcs.broker)
Expand Down Expand Up @@ -544,10 +544,10 @@ func (svcs *allServices) registerConfigWatchers() {
svcs.confListenerIDs = svcs.confWatcher.OnConfigUpdateWithID(
func(cfg config.Config) { svcs.executionEngine.ReloadConf(cfg.Execution) },
func(cfg config.Config) { svcs.notary.ReloadConf(cfg.Notary) },
func(cfg config.Config) { svcs.primaryEventForwarderEngine.ReloadConf(cfg.EvtForward) },
func(cfg config.Config) { svcs.primaryEventForwarderEngine.ReloadConf(cfg.EvtForward.Ethereum) },
func(cfg config.Config) { svcs.primaryEventForwarder.ReloadConf(cfg.EvtForward) },
func(cfg config.Config) { svcs.secondaryEventForwarderEngine.ReloadConf(cfg.SecondaryEvtForward) },
func(cfg config.Config) { svcs.secondaryEventForwarder.ReloadConf(cfg.SecondaryEvtForward) },
func(cfg config.Config) { svcs.secondaryEventForwarderEngine.ReloadConf(cfg.EvtForward.EVMBridges[0]) },
func(cfg config.Config) { svcs.secondaryEventForwarder.ReloadConf(cfg.EvtForward) },
func(cfg config.Config) { svcs.topology.ReloadConf(cfg.Validators) },
func(cfg config.Config) { svcs.witness.ReloadConf(cfg.Validators) },
func(cfg config.Config) { svcs.assets.ReloadConf(cfg.Assets) },
Expand Down Expand Up @@ -761,7 +761,7 @@ func (svcs *allServices) setupNetParameters(powWatchers []netparams.WatchParam)
svcs.assets.SetBridgeChainID(ethCfg.ChainID(), false)
svcs.secondaryEventForwarder.SetChainID(ethCfg.ChainID())

return svcs.secondaryEventForwarderEngine.SetupSecondaryEthereumEngine(svcs.secondaryEthClient, svcs.secondaryEventForwarder, svcs.conf.SecondaryEvtForward.Ethereum, ethCfg, svcs.assets)
return svcs.secondaryEventForwarderEngine.SetupSecondaryEthereumEngine(svcs.secondaryEthClient, svcs.secondaryEventForwarder, svcs.conf.EvtForward.EVMBridges[0], ethCfg, svcs.assets)
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions core/protocol/engines.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
package protocol

import (
"code.vegaprotocol.io/vega/core/evtforward"
"code.vegaprotocol.io/vega/core/evtforward/ethereum"
evtfwdeth "code.vegaprotocol.io/vega/core/evtforward/ethereum"
"code.vegaprotocol.io/vega/core/types"
)

type EventForwarderEngine interface {
ReloadConf(evtforward.Config)
ReloadConf(ethereum.Config)
SetupEthereumEngine(evtfwdeth.Client, evtfwdeth.Forwarder, evtfwdeth.Config, *types.EthereumConfig, evtfwdeth.Assets) error
SetupSecondaryEthereumEngine(evtfwdeth.Client, evtfwdeth.Forwarder, evtfwdeth.Config, *types.EVMChainConfig, evtfwdeth.Assets) error
Start()
Expand Down

0 comments on commit 1dd665b

Please sign in to comment.