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

Split node task in subtasks #874

Merged
merged 27 commits into from
Oct 15, 2020
Merged

Split node task in subtasks #874

merged 27 commits into from
Oct 15, 2020

Conversation

fvictorio
Copy link
Member

No description provided.

@alcuadrado
Copy link
Member

I think the only missing thing is creating a new provider if the network is not hardhat.

Can you take a look at this @wighawag? Thanks!

Also, it would be great to give the users a way to stop the node, but I'm not sure how we can do it. Any ideas?

@fvictorio
Copy link
Member Author

Also, it would be great to give the users a way to stop the node, but I'm not sure how we can do it. Any ideas?

I thought the same thing. One (not very elegant) solution is for the server to check all requests before delegating them to the handler and, if the request is hardhat_close, the server calls this.close.

@alcuadrado
Copy link
Member

I thought the same thing. One (not very elegant) solution is for the server to check all requests before delegating them to the handler and, if the request is hardhat_close, the server calls this.close.

Yes, that's the best I can come up with TBH. Maybe just make it super explicit, like hardhat_closeJsonRpcServer? And I think I wouldn't forward it to the provider.

@fvictorio
Copy link
Member Author

@alcuadrado this should be ready for review

@@ -118,7 +257,7 @@ task(TASK_NODE, "Starts a JSON-RPC server on top of Hardhat Network")
console.log();
Copy link
Member

Choose a reason for hiding this comment

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

I think these console.log calls should be placed in TASK_NODE_SERVER_READY

@@ -137,6 +276,8 @@ task(TASK_NODE, "Starts a JSON-RPC server on top of Hardhat Network")
const networkConfig = config.networks[HARDHAT_NETWORK_NAME];
logHardhatNetworkAccounts(networkConfig);
Copy link
Member

Choose a reason for hiding this comment

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

Also, this should be in TASK_NODE_SERVER_READY

import { EIP1193Provider } from "../provider";

export interface JsonRpcServer {
getProvider(name: string): EIP1193Provider;
Copy link
Member

Choose a reason for hiding this comment

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

This is only for testing purposes, so I don't think it should be placed here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed 👍 close isn't used in the task either, but I guess it makes sense to have it in the interface anyway, wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think that can be really useful for people overriding the tasks.

@@ -137,6 +276,8 @@ task(TASK_NODE, "Starts a JSON-RPC server on top of Hardhat Network")
const networkConfig = config.networks[HARDHAT_NETWORK_NAME];
logHardhatNetworkAccounts(networkConfig);

await run(TASK_NODE_SERVER_READY, { provider, server });
Copy link
Member

Choose a reason for hiding this comment

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

This task should receive the hostname and actual port.


const server = new JsonRpcServer(serverConfig);
await run(TASK_NODE_SERVER_CREATED, { provider, server });
Copy link
Member

Choose a reason for hiding this comment

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

This plugin should receive the hostname and port

@wighawag
Copy link
Contributor

I had a quick look, but this looks great!
this would be all I need to implement my node override.

is the log enabled when the server start or on when the provider is created ?
I am asking because if it is only when the server start, I might never need to disable it as I could execute the deployment in TASK_NODE_GET_PROVIDER and then the server can start like usual.

@alcuadrado
Copy link
Member

Thanks for your comments, @wighawag.

Right now, you should override the get provider task, disable logging, do your things, and re enable logging.

BTW, i think we should add the new method to this array, @fvictorio https://github.com/nomiclabs/buidler/blob/2.0/packages/hardhat-core/src/internal/hardhat-network/provider/provider.ts#L45 -- Otherwise the hardhat_setLoggingEnabled call will be logged.

const { verbose = false, configPath } = event.extra ?? {};
const extra: { verbose?: boolean; configPath?: string } =
event.extra ?? {};
const { verbose = false, configPath } = extra;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why this stopped compiling, maybe the sentry dependency was updated for some reason?

Anyway, it seems like event.extra values are unknown now, so this is necessary.

Copy link
Member

Choose a reason for hiding this comment

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

I've seen this before. I think sentry is a bit sloppy with semver

@alcuadrado alcuadrado merged commit 29b1c5e into 2.0 Oct 15, 2020
@alcuadrado alcuadrado deleted the split-node-task branch October 15, 2020 20:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants