-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(monitor): add xcall loadgen to the monitor app #2723
Conversation
- implement GetPortal func on xconnector - add xcaller and config - add xcall forever
- enable xcaller in devnet1 manifest
lib/netconf/static.go
Outdated
@@ -131,7 +131,7 @@ func (s Static) ConsensusRPC() string { | |||
if s.Network == Devnet { | |||
// First halo in devnet docker-compose. | |||
// Note that it might not be running. | |||
return "http://localhost:5701" | |||
return "http://validator01:26657" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/netconf/static.go
should remain external RPCs. which for devnet, are local host
with have internalEndpoints()
in e2e to get endpoints from within a network (docker or gcp)
[loadgen] | ||
# Validator keys glob defines the validator keys to use for self-delegation. | ||
validator-keys-glob = "path/*/1" | ||
|
||
[xcaller] | ||
enabled = "false" | ||
|
||
# Chain ID pairs, where each pair specifies a 'from' and 'to' chain for sending xCalls. | ||
[xcaller.chainid-pairs] | ||
# arbitrum_one = "optimism" | ||
# base = "arbitrum_one" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xcaller
is part of loadgen, so let's make it part of loadgen config
xCallerAddr := eoa.MustAddress(network.ID, eoa.RoleXCaller) | ||
go xCallForever(ctx, xCallerAddr, period, xCallerCfg.ChainIDs, backends, connector) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Start
function has a lot of stuff in it now. First half about loadgening validator updates. Second part about loadgening xcalls. Maybe put both in their own function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e2e/manifests/devnet1.toml
Outdated
xcaller_enabled = true | ||
|
||
[node.validator01] | ||
[node.validator02] | ||
|
||
[node.fullnode01] | ||
mode="archive" | ||
|
||
[xcaller_chainid_pairs] | ||
mock_l1 = "mock_l2" | ||
mock_l2 = "mock_l1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some thoughts on config.
- let's make it clear these are part of loadgen config
- we use chain names, not chain ids.
- do we have a reason for specifying which xcalls to to make xcalls from / to? if not, let's just do all of them. until we have a reason for more granular control
[loadgen.xcalls]
enabled = true
if we do have a need to specify, I think pairs are limitting. for ex, we could not loadtest xcalls on all streams by configuring pairs (at least, not as written). What about just specifying source and destination chains with a regex
[loadgen.xcall]
from = "mock_l1|mock_l2"
to = "*"
e2e/types/manifest.go
Outdated
@@ -132,6 +132,12 @@ type Manifest struct { | |||
|
|||
// FeatureFlags defines the feature flags to enable. | |||
FeatureFlags feature.Flags `toml:"feature_flags"` | |||
|
|||
// XCallerEnabled defines whether to enable the xcaller load generator for the monitor app. | |||
XCallerEnabled bool `toml:"xcaller_enabled"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets follow the existing loadgen pattern, "Validator self-delegation" is simply enabled by presence of the key. Also, avoid complex configuration options in v1, simply hardcode the chain pairs in monitor
. lessismore.
lib/xchain/connect/connect.go
Outdated
@@ -51,6 +53,21 @@ func (c Connector) Backend(chainID uint64) (*ethbackend.Backend, error) { | |||
return ethbackend.NewBackend(chain.Name, chainID, chain.BlockPeriod, cl) | |||
} | |||
|
|||
// GetPortal returns an OmniPortal binding for the portal at the provided address. | |||
func (c Connector) GetPortal(chainID uint64, backend bind.ContractBackend) (*bindings.OmniPortal, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xconnector isn't used in monitor, it is only used in scripts, lets keep it that way. please remove this.
- send single xMsgs each configured period
e2e/app/definition.go
Outdated
@@ -435,7 +435,7 @@ func internalEndpoints(def Definition, nodePrefix string) xchain.RPCEndpoints { | |||
endpoints[omniEVM.Chain.Name] = omniEVM.InternalRPC | |||
|
|||
node := nodeByPrefix(def.Testnet, nodePrefix) | |||
endpoints[def.Testnet.Network.Static().OmniConsensusChain().Name] = node.AddressRPC() | |||
endpoints[def.Testnet.Network.Static().OmniConsensusChain().Name] = fmt.Sprintf("http://%s", node.AddressRPC()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this required, things work without this, lets remove is not abs required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/loadgen.go
Outdated
func Start(ctx context.Context, network netconf.Network, ethClients map[uint64]ethclient.Client, cfg Config) error { | ||
// - Makes XCalls from -> to random EVM portals on periodic basis. | ||
func Start(ctx context.Context, network netconf.Network, ethClients map[uint64]ethclient.Client, cfg Config, rpcEndpoints xchain.RPCEndpoints) error { | ||
err := startSelfDelegationLoadgen(ctx, network, ethClients, cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove loadgen suffix since this is loadgen package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/loadgen.go
Outdated
@@ -81,3 +98,32 @@ func Start(ctx context.Context, network netconf.Network, ethClients map[uint64]e | |||
|
|||
return nil | |||
} | |||
|
|||
func startXCallLoadgen(ctx context.Context, network netconf.Network, rpcEndpoints xchain.RPCEndpoints) error { | |||
xCallerPK, err := eoa.PrivateKey(ctx, network.ID, eoa.RoleXCaller) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets stick to existing pattern, see cfg.ValidatorKeysGlob
. At this point, app don't need GPC perms and don't download keys, lets stick to that pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove xcaller prefix, since we are in xcaller function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/loadgen.go
Outdated
func startXCallLoadgen(ctx context.Context, network netconf.Network, rpcEndpoints xchain.RPCEndpoints) error { | ||
xCallerPK, err := eoa.PrivateKey(ctx, network.ID, eoa.RoleXCaller) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to get RoleXCaller priv key exiting xcall loadgen") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify wrapped msgs, also, no need to add "failed" when wrapping, see Golang style guide in notion. e.g. errors.Wrap(err, "get xcaller priv key")
is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/loadgen.go
Outdated
var xCallPeriod = time.Hour * 2 | ||
if network.ID == netconf.Devnet { | ||
xCallPeriod = time.Second * 30 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make these package level globals, e.g. xcallPerid
and xcallPeriodDevnet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/xcall.go
Outdated
) | ||
|
||
const ( | ||
dead = "0x000000000000000000000000000000000000dead" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: deadAddr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/xcall.go
Outdated
return err | ||
} | ||
|
||
var data []byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nil: nilData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/xcall.go
Outdated
} | ||
|
||
func xCall(ctx context.Context, cfg *XCallConfig, getChainPair func() (from netconf.Chain, to netconf.Chain)) error { | ||
fromChain, dstChain := getChainPair() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we commonly use srcChain
, not fromChain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/xcall.go
Outdated
"dst_chain_id", dstChain.ID, | ||
) | ||
} | ||
log.Debug(ctx, fmt.Sprintf("xcall made %s -> %s %s", fromChain.Name, dstChain.Name, tx.Hash())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid %s or %v in logging, use structured log attributes rather
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
monitor/loadgen/xcall.go
Outdated
} | ||
|
||
txOpts.Value = fee | ||
tx, err := fromPortal.Xcall(txOpts, dstChain.ID, uint8(xchain.ConfLatest), to, data, gasLimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have to waitmined the tx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
monitor/loadgen/xcall.go
Outdated
return err | ||
} | ||
|
||
fromPortal, err := getPortal(ctx, cfg.NetworkID, srcChain.ID, cfg.Backends) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename srcPortal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds xcall load generation to the monitor app.
issue: #2275