Skip to content
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

Change config to use RPC urls instead of host and port #1512

Merged
merged 6 commits into from
Sep 13, 2023

Conversation

BedrockSquirrel
Copy link
Collaborator

Why this change is needed

For sepolia we want to pass in URLs for API services like infura but our config all expects host+port separately and constructs the URL.

What changes were made as part of this PR

Change host, contract deployer configs and github deploy actions to use RPC addresses instead of host + port.

PR checks pre-merging

Please indicate below by ticking the checkbox that you have read and performed the required
PR checks

  • PR checks reviewed and performed

Copy link
Contributor

@otherview otherview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I would suggest a slight change to the naming though.
Namely changing all names to variations of L1 Websocket URL instead of L1 websocket RPC or Address. I believe URL is the name we're looking for as it describes protocol + address + port.

Comment on lines 41 to 42
L1_WS_RPC: ${{ steps.outputVars.outputs.L1_WS_RPC }}
L1_HTTP_RPC: ${{ steps.outputVars.outputs.L1_HTTP_RPC }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugestion:

Suggested change
L1_WS_RPC: ${{ steps.outputVars.outputs.L1_WS_RPC }}
L1_HTTP_RPC: ${{ steps.outputVars.outputs.L1_HTTP_RPC }}
L1_WS_URL: ${{ steps.outputVars.outputs.L1_WS_RPC }}
L1_HTTP_URL: ${{ steps.outputVars.outputs.L1_HTTP_RPC }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically this is called URL because it's proto + address + port formatted

@@ -107,7 +111,7 @@ jobs:
shell: bash
run: |
go run ./testnet/launcher/l1contractdeployer/cmd \
-l1_host=${{ env.L1_HOST }} \
-l1_http_rpc=${{ env.L1_HTTP_RPC }} \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-l1_http_rpc=${{ env.L1_HTTP_RPC }} \
-l1_http_url=${{ env.L1_HTTP_RPC }} \

@@ -62,8 +62,8 @@ jobs:
echo "RESOURCE_TAG_NAME=testnetlatest" >> $GITHUB_ENV
echo "RESOURCE_STARTING_NAME=T" >> $GITHUB_ENV
echo "RESOURCE_TESTNET_NAME=testnet" >> $GITHUB_ENV
echo "L1_HOST=testnet-eth2network.uksouth.cloudapp.azure.com" >> $GITHUB_ENV

echo "L1_WS_RPC=ws://testnet-eth2network.uksouth.cloudapp.azure.com:9000" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "L1_WS_RPC=ws://testnet-eth2network.uksouth.cloudapp.azure.com:9000" >> $GITHUB_ENV
echo "L1_WS_URL=ws://testnet-eth2network.uksouth.cloudapp.azure.com:9000" >> $GITHUB_ENV

Comment on lines 40 to 41
// Websocket RPC address for interactions with the L1
L1WebsocketRPCAddress string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Websocket RPC address for interactions with the L1
L1WebsocketRPCAddress string
// L1WebsocketURL is the RPC address for interactions with the L1
L1WebsocketURL string

Keeping the same name for consistency

Comment on lines 197 to 198
// The websocket RPC address for L1 requests
L1WebsocketRPCAddr string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The websocket RPC address for L1 requests
L1WebsocketRPCAddr string
// L1WebsocketURL is the RPC address for interactions with the L1
L1WebsocketURL string

@@ -27,8 +27,7 @@ type HostConfigToml struct {
EnclaveRPCAddress string
P2PBindAddress string
P2PPublicAddress string
L1NodeHost string
L1NodeWebsocketPort uint
L1WebsocketRPCAddress string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
L1WebsocketRPCAddress string
L1WebsocketURL string

@@ -12,8 +12,7 @@ const (
enclaveRPCAddressName = "enclaveRPCAddress"
p2pBindAddressName = "p2pBindAddress"
p2pPublicAddressName = "p2pPublicAddress"
l1NodeHostName = "l1NodeHost"
l1NodePortName = "l1NodePort"
l1WebsocketRPCAddrName = "l1WSRPCAddress"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1WebsocketRPCAddrName = "l1WSRPCAddress"
l1WebsocketURLName = "l1WSURL"

@@ -41,8 +40,7 @@ func getFlagUsageMap() map[string]string {
isSGXEnabledFlag: "Whether the it should run on an SGX is enabled CPU",
enclaveDockerImageFlag: "Docker image for the enclave",
hostDockerImageFlag: "Docker image for the host",
l1HostFlag: "Layer 1 network host addr",
l1WSPortFlag: "Layer 1 network WebSocket port",
l1WSRPCAddressFlag: "Layer 1 websocket RPC address",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1WSRPCAddressFlag: "Layer 1 websocket RPC address",
l1WSURLFlag: "Layer 1 WebSocket RPC URL",

@@ -114,7 +114,7 @@ func NewHostContainerFromConfig(parsedConfig *config.HostInputConfig, logger get
ethWallet := wallet.NewInMemoryWalletFromConfig(cfg.PrivateKeyString, cfg.L1ChainID, log.New("wallet", cfg.LogLevel, cfg.LogPath))

fmt.Println("Connecting to L1 network...")
l1Client, err := ethadapter.NewEthClient(cfg.L1NodeHost, cfg.L1NodeWebsocketPort, cfg.L1RPCTimeout, cfg.ID, logger)
l1Client, err := ethadapter.NewEthClientFromAddress(cfg.L1WebsocketURL, cfg.L1RPCTimeout, cfg.ID, logger)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1Client, err := ethadapter.NewEthClientFromAddress(cfg.L1WebsocketURL, cfg.L1RPCTimeout, cfg.ID, logger)
l1Client, err := ethadapter.NewEthClientFromURL(cfg.L1WebsocketURL, cfg.L1RPCTimeout, cfg.ID, logger)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have the patience it would cool if we changed NewEthClient to call NewEthClientFromAddress instead the two methods having the same duplicated code.

@@ -13,8 +12,7 @@ const (
// While we could just use constants instead of a map, this approach allows us to test that all the expected flags are defined.
func getFlagUsageMap() map[string]string {
return map[string]string{
l1HostFlag: "Layer 1 network host addr",
l1HTTPPortFlag: "Layer 1 network HTTP port",
l1HTTPRPCAddressFlag: "Layer 1 network http RPC addr",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1HTTPRPCAddressFlag: "Layer 1 network http RPC addr",
l1HTTPURLFlag: "Layer 1 network http RPC addr",

l1cd.WithL1Port(cliConfig.l1HTTPPort), // 8025
l1cd.WithPrivateKey(cliConfig.privateKey), //"f52e5418e349dccdda29b6ac8b0abe6576bb7713886aa85abea6181ba731f9bb"),
l1cd.WithDockerImage(cliConfig.dockerImage), //"testnetobscuronet.azurecr.io/obscuronet/hardhatdeployer:latest"
l1cd.WithL1HTTPRPCAddress(cliConfig.l1HTTPRPCAddr), // "http://eth2network:8025"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1cd.WithL1HTTPRPCAddress(cliConfig.l1HTTPRPCAddr), // "http://eth2network:8025"
l1cd.WithL1HTTPURL(cliConfig.l1HTTPRPCAddr), // "http://eth2network:8025"

privateKey string
l1Port int
dockerImage string
l1HTTPRPCAddress string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1HTTPRPCAddress string
l1HTTPURL string

@@ -6,8 +6,7 @@ import (

// L2ContractDeployerConfigCLI represents the configurations passed into the deployer over CLI
type L2ContractDeployerConfigCLI struct {
l1Host string
l1HTTPPort int
l1HTTPRPCAddr string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
l1HTTPRPCAddr string
l1HTTPURL string

Copy link
Contributor

@otherview otherview left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - would optionally make that NewEthClientFromAddress change (name and reusage), but it's totally fine to leave it to another pr too.

The contract deployers should probably get updated, would suggest taking those sugestion-changes, so that we call the l1 http url everywhere the same.

@BedrockSquirrel BedrockSquirrel merged commit b7b4e3e into main Sep 13, 2023
@BedrockSquirrel BedrockSquirrel deleted the matt/rpc-address-config branch September 13, 2023 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants