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

(local) better cleanup during start and shutdown #130

Merged
merged 3 commits into from
Feb 28, 2024
Merged

Conversation

joewagner
Copy link
Contributor

Overview

As seen here, https://gist.github.com/dtbuchholz/ff5a8c261ff282bb72476bc1ad02f328#file-e2e-test-ts, the hardhat snapshotting was not working because the database backup was not being reset when the Validator was reset.

Details

This PR fixes the reset procedure to allow chain snapshotting, and also include better cleanup logic for database backup files.

throw new Error(
`unexpected error during shutdown: ${err.message as string}`
);
} finally {
this.#_cleanup();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the potentially confusing finally block.

// we allow passing an optional directory to clean in case the user wants
// to cleanup before starting
if (typeof validatorDir !== "string") {
validatorDir = this.validatorDir;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had been cleaning up before starting the Validator, and the directory where the validator backups are stored can't be determined by the instance until after starting.
To enable pre-start cleanup, we now allow a directory value to be optionally passed in.

shell.rm("-rf", resolve(this.validatorDir, "backups"));

const dbFiles = [
resolve(this.validatorDir, "database.db"),
resolve(this.validatorDir, "database.db-shm"),
resolve(this.validatorDir, "database.db-wal"),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These -shm and -wal endings were not getting removed.

@@ -394,6 +395,7 @@ class LocalTableland {

this.validator.process.on("close", () => resolve());
this.validator.shutdown();
this.validator.cleanup();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the actual fix for the issue @dtbuchholz outlines here: https://gist.github.com/dtbuchholz/ff5a8c261ff282bb72476bc1ad02f328

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, nice! and thanks for the details on the gist...I can use that as a reference for new docs on this feature

@joewagner joewagner marked this pull request as ready for review February 28, 2024 15:12
@joewagner joewagner merged commit 9245c0d into main Feb 28, 2024
5 checks passed
@joewagner joewagner deleted the joe/local-cleanup branch February 28, 2024 17:39
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