Skip to content

Conversation

@udogri
Copy link

@udogri udogri commented Sep 5, 2025

This commit introduces a new option, , to the ChainDB configuration. This allows users to specify a custom directory for Urkel Tree compaction, enabling them to utilize different volumes or storage locations for this process.

Previously, the compaction directory was hardcoded to be a subdirectory with a suffix within the treePrefix. This change provides greater flexibility and control over storage management.

The following changes were made:

  • Modified the ChainDB constructor to check for the option.
  • If provided, the option is set to the value of .
  • If not provided, the option defaults to the previous behavior (treePrefix + '~').

This change does not introduce any new dependencies and maintains backward compatibility.

Testing:

Due to limitations in the testing environment, full integration tests could not be performed. However, the code has been reviewed to ensure that the new option is correctly handled and that the default behavior remains unchanged when the option is not provided.

This commit introduces a new option, , to the ChainDB configuration. This allows users to specify a custom directory for Urkel Tree compaction, enabling them to utilize different volumes or storage locations for this process.

Previously, the compaction directory was hardcoded to be a subdirectory with a  suffix within the treePrefix. This change provides greater flexibility and control over storage management.

The following changes were made:

- Modified the ChainDB constructor to check for the  option.
- If provided, the  option is set to the value of .
- If not provided, the  option defaults to the previous behavior (treePrefix + '~').

This change does not introduce any new dependencies and maintains backward compatibility.

Testing:

Due to limitations in the testing environment, full integration tests could not be performed. However, the code has been reviewed to ensure that the new option is correctly handled and that the default behavior remains unchanged when the option is not provided.
Comment on lines +66 to +73
if (this.options.compactionDirectory == null) {
this.options.compactionDirectory = this.options.treePrefix + '~';
}

// Allow users to specify a custom compaction directory
if (options.customCompactionDirectory != null) {
this.options.compactionDirectory = options.customCompactionDirectory;
}
Copy link
Member

Choose a reason for hiding this comment

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

What's the difference between compactionDirectory and customCompactionDirectory?

Copy link
Author

Choose a reason for hiding this comment

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

customCompactionDirectory is the user-provided option, while compactionDirectory is what the system actually uses. If the user provides a custom directory, we use that; otherwise, it defaults to treePrefix + '~'.

Copy link
Contributor

@nodech nodech left a comment

Choose a reason for hiding this comment

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

this.options in the chaindb is passed from the chain.js. The type of it is ChainOptions. That's the one responsible for normalizing and parsing all the configurations. chaindb does not check options, it should get finalized in chain.js ChainOptions.

Chain also needs to somehow accept this options, that happens in fullnode.js and spvnode.js. Given spvnode does not have a tree, it only needs to be applied to fullnode.

You can check compactTreeOnInit option for example. (relevant to the tree compaction as well)

@coveralls
Copy link

Coverage Status

coverage: 71.652% (+0.01%) from 71.638%
when pulling acb1a04 on udogri:add-chaindb-compaction-dir
into 698e252 on handshake-org:master.

@udogri
Copy link
Author

udogri commented Sep 8, 2025

Okay so compactTreeOnInit option will give me an idea of the changes that I need to make

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.

4 participants