Replies: 6 comments 5 replies
-
Following the test fix in #3425 I've been looking into code quality improvements to reduce the risk of similar concurrency issues in the future. I've looked into the following: 1. Use a macro to get the name of the current function in the tests
do
Caveat: This macro does not exist in the standard library. These two third-party implementations are interesting: 2. Remove the Drawback: We loose some interpretability in debug logs and temporary test directory names. RecommendationI recommend using the stdext macro. It's slightly simpler than the dedicated function_name and only requires replacing the hard-coded names to the macro call. We only need to add I'd love to get feedback on this. If everyone agrees that this makes sense, I'd be happy to prepare a PR implementing this change. |
Beta Was this translation helpful? Give feedback.
-
Suggestion: write pure code, without side-effects.The most problematic side-effect is IO. Avoid using IO directly, like listening ports. Avoid using functions from third-party libraries which using IO directly. Bind IO at the latest stage. This way we can test and mock IO in our unit tests and try different scenarios without complicated long running integration tests. |
Beta Was this translation helpful? Give feedback.
-
Clear Rust Repository StructureDON'T mix together project properties and a workspace. A root level Example: A repository
Other projects, outside of this repo, can depend on a specific projects of the mono-repo: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-git-repositories [dependencies]
b = { git = "https://github.com/x/x", branch = "next" } |
Beta Was this translation helpful? Give feedback.
-
Where appropriate, have the caller call |
Beta Was this translation helpful? Give feedback.
-
Make stacks_common::types::Address require FromStr. More context in this old issue #3483 |
Beta Was this translation helpful? Give feedback.
-
Refactor: Remove unneccessary generics from FromRow and FromColumn traits #3513 |
Beta Was this translation helpful? Give feedback.
-
Collecting issues and tasks to improve code quality and developer productivity.
Documentation
From Mårten:
vim-boxdraw is a nice utility to generate these types of diagrams
https://github.com/gyim/vim-boxdraw
PlantUML is also able to translate ascii art to proper figures.
It's a good compromise for documentation where you can have readable charts in the code,
and also get pretty images in web interfaces https://plantuml.com/ditaa
Matthew Little:
https://github.com/mermaid-js/mermaid
Mermaidjs is pretty popular too - works on GitHub with Markdown. For example:
Brice Dobry:
I believe there are tools to generate ascii from dot files too (Graphviz)
https://dot-to-ascii.ggerganov.com
Greg Coppola:
People like figma
Another tool to create diagrams: https://text-to-diagram.com/?example=basic
Code quality issues
Include a .editorconfig.
Turn on Clippy warnings, and get these fixed.
Address
rustc
warnings.Move Cargo package from
/testnet/stacks-node
to/stacks-node
Move Cargo workspace member "." to
blockstack-core
directoryRemove code using
unsafe
keywordInvestigate issues with libraries
reqwest
,async-h1
andtokio
Add the Cargo package
stacks-common
as a workspace memberRemove the use of
extern crate
Add support for Bitcoin v23
jude: I'm a fan of "all of the core functionality for a single distinct subsystem should be in one file" because then it's straightforward to see the big picture of how the system ought to work.
the large files come mainly from keeping the unit tests in the same file
like, src/chainstate/stacks/db/transactions.rs is mostly unit tests (like, 90% of it is just unit tests)
those could be separated out into a separate tests module
src/chainstate/stacks/db/blocks.rs without tests is about 7 KLoC; it could probably be separated into four files:
Test suite reliability
Some tests are slow (run for over one minute) or fail when run with multiple threads.
Running local tests
Running contiguous integration tests
Using the logs files produced above:
Show failing tests
Run local tests with
--test-threads=16
to check for tests failing due to concurrent runsShow slow tests
Break up large code files
Jude: These files are large because they have lots of tests in them. We could separate the tests out into their own files. This was already done in next for miner.rs, for example.
Beta Was this translation helpful? Give feedback.
All reactions