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

Move EVM init till after chainstate init #2125

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all 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
98 changes: 48 additions & 50 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,56 +1559,6 @@ bool AppInitMain(InitInterfaces& interfaces)
return InitError(_("Unable to start HTTP server. See debug log for details.").translated);
}

// ********************************************************* Step 4b: application initialization

/* Start the ETH RPC and gRPC servers. Current API only allows for one ETH
* RPC/gRPC server to bind to one address. By default, we will only take
* the first address, if multiple addresses are specified.
*/
int eth_rpc_port = gArgs.GetArg("-ethrpcport", BaseParams().ETHRPCPort());
int grpc_port = gArgs.GetArg("-grpcport", BaseParams().GRPCPort());
std::vector<std::pair<std::string, uint16_t> > eth_endpoints;
std::vector<std::pair<std::string, uint16_t> > g_endpoints;

// Determine which addresses to bind to ETH RPC server
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-ethrpcbind"))) { // Default to loopback if not allowing external IPs
eth_endpoints.push_back(std::make_pair("127.0.0.1", eth_rpc_port));
if (gArgs.IsArgSet("-rpcallowip")) {
LogPrintf("WARNING: option -rpcallowip was specified without -ethrpcbind; this doesn't usually make sense\n");
}
if (gArgs.IsArgSet("-ethrpcbind")) {
LogPrintf("WARNING: option -ethrpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
}
} else if (gArgs.IsArgSet("-ethrpcbind")) { // Specific bind address
for (const std::string& strETHRPCBind : gArgs.GetArgs("-ethrpcbind")) {
int port = eth_rpc_port;
std::string host;
SplitHostPort(strETHRPCBind, port, host);
eth_endpoints.push_back(std::make_pair(host, port));
}
}

// Determine which addresses to bind to gRPC server
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-grpcbind"))) { // Default to loopback if not allowing external IPs
g_endpoints.push_back(std::make_pair("127.0.0.1", grpc_port));
if (gArgs.IsArgSet("-rpcallowip")) {
LogPrintf("WARNING: option -rpcallowip was specified without -grpcbind; this doesn't usually make sense\n");
}
if (gArgs.IsArgSet("-grpcbind")) {
LogPrintf("WARNING: option -grpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
}
} else if (gArgs.IsArgSet("-grpcbind")) { // Specific bind address
for (const std::string& strGRPCBind : gArgs.GetArgs("-grpcbind")) {
int port = grpc_port;
std::string host;
SplitHostPort(strGRPCBind, port, host);
g_endpoints.push_back(std::make_pair(host, port));
}
}

// Default to using the first address passed to bind to ETH RPC server and gRPC server
start_servers(eth_endpoints[0].first + ":" + std::to_string(eth_endpoints[0].second), g_endpoints[0].first + "." + std::to_string(g_endpoints[0].second));

// ********************************************************* Step 5: verify wallet database integrity
for (const auto& client : interfaces.chain_clients) {
if (!client->verify()) {
Expand Down Expand Up @@ -1950,6 +1900,54 @@ bool AppInitMain(InitInterfaces& interfaces)
}
}

/* Start the ETH RPC and gRPC servers. Current API only allows for one ETH
* RPC/gRPC server to bind to one address. By default, we will only take
* the first address, if multiple addresses are specified.
*/
int eth_rpc_port = gArgs.GetArg("-ethrpcport", BaseParams().ETHRPCPort());
int grpc_port = gArgs.GetArg("-grpcport", BaseParams().GRPCPort());
std::vector<std::pair<std::string, uint16_t> > eth_endpoints;
std::vector<std::pair<std::string, uint16_t> > g_endpoints;

// Determine which addresses to bind to ETH RPC server
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-ethrpcbind"))) { // Default to loopback if not allowing external IPs
eth_endpoints.emplace_back("127.0.0.1", eth_rpc_port);
if (gArgs.IsArgSet("-rpcallowip")) {
LogPrintf("WARNING: option -rpcallowip was specified without -ethrpcbind; this doesn't usually make sense\n");
}
if (gArgs.IsArgSet("-ethrpcbind")) {
LogPrintf("WARNING: option -ethrpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
}
} else if (gArgs.IsArgSet("-ethrpcbind")) { // Specific bind address
for (const std::string& strETHRPCBind : gArgs.GetArgs("-ethrpcbind")) {
int port = eth_rpc_port;
std::string host;
SplitHostPort(strETHRPCBind, port, host);
eth_endpoints.emplace_back(host, port);
}
}

// Determine which addresses to bind to gRPC server
if (!(gArgs.IsArgSet("-rpcallowip") && gArgs.IsArgSet("-grpcbind"))) { // Default to loopback if not allowing external IPs
g_endpoints.emplace_back("127.0.0.1", grpc_port);
if (gArgs.IsArgSet("-rpcallowip")) {
LogPrintf("WARNING: option -rpcallowip was specified without -grpcbind; this doesn't usually make sense\n");
}
if (gArgs.IsArgSet("-grpcbind")) {
LogPrintf("WARNING: option -grpcbind was ignored because -rpcallowip was not specified, refusing to allow everyone to connect\n");
}
} else if (gArgs.IsArgSet("-grpcbind")) { // Specific bind address
for (const std::string& strGRPCBind : gArgs.GetArgs("-grpcbind")) {
int port = grpc_port;
std::string host;
SplitHostPort(strGRPCBind, port, host);
g_endpoints.emplace_back(host, port);
}
}

// Default to using the first address passed to bind to ETH RPC server and gRPC server
start_servers(eth_endpoints[0].first + ":" + std::to_string(eth_endpoints[0].second), g_endpoints[0].first + "." + std::to_string(g_endpoints[0].second));

try {
LOCK(cs_main);
if (!is_coinsview_empty) {
Expand Down