-
Notifications
You must be signed in to change notification settings - Fork 956
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
Modularization: core refactors #2312
Conversation
f4b077d
to
f7f1d86
Compare
06955dc
to
c4f79a6
Compare
use thiserror::Error; | ||
|
||
use super::address::Address; | ||
use super::key::common; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might make sense to pub use
here. If I were a new dev and saw this file, I would assume I could find keys and signature types in here.
@@ -1,6 +1,7 @@ | |||
//! A basic fungible token | |||
|
|||
use std::cmp::Ordering; | |||
use std::collections::BTreeMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we decide what gets its own module and what stays under core? For example, why isn't this its own module or account not under core?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably move this into the new trans_token crate - there are still few files left in core that depend on it, but they can also be moved out
3a17751
to
d0bd9b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I've looked at:
- The
pos_queries
andeth_bridge_queries
changes, and I like them. - The general layout of the repository. The root of the project looks too cluttered now, so I suggest we move non-wasm crates to a separate directory. (
native
??ledger
?? idk) - (Follow-up of point 2). This is a somewhat counterintuitive point of criticism to the objective at hand, but perhaps we have too many crates now with very little benefit (other than smaller wasm sizes, potentially). Our main goal should be unifying the APIs into an abstraction that will prevent code changes from bubbling up the dependency graph, wrecking havoc during merges, refactors, etc. As a first step to realize that goal, this is still an excellent effort!
- The dependency graph. I noticed
storage
depended ontx
, which I found odd, so I looked through the code to see where it got used, and left some suggestions to clean up that dependency from the graph.
I might revisit this PR later today.
/// A wrapper for `crate::types::transaction::WrapperTx` to conditionally | ||
/// add `has_valid_pow` flag for only used in testnets. | ||
#[derive(Debug, Clone, BorshDeserialize, BorshSerialize)] | ||
pub struct TxInQueue { | ||
/// Wrapper tx | ||
pub tx: Tx, | ||
/// The available gas remaining for the inner tx (for gas accounting). | ||
/// This allows for a more detailed logging about the gas used by the | ||
/// wrapper and that used by the inner | ||
pub gas: Gas, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the only reason storage
depends on tx
currently is because it requires Tx
in the tx_queue
module; maybe the same could be said for namada_gas::Gas
. Since tx_queue
is re-exported to state
, and only gets used in apps
, and logically it is considered stateful data, why not move the tx_queue
module to the state
crate? This way we potentially remove two dependencies from storage
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I actually had some issue with having these dependencies elsewhere. Moving it to state
sounds like a good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, unfortunately it's not so straight-forward as the BlockStateRead
in storage/src/db.rs
depends on it :(
c1fb3d4
to
d6bc44b
Compare
* origin/tomas+tiago/modularization: (118 commits) changelog: add #2312 add impl for VP get_pred_epochs pos_queries: remove unused methods fix masp storage key regression undo reintroduced typos fix `get_current_decision_height` by moving it to WlStorage vm_env: add `tx_get_pred_epoch` impl fix rustdocs macros: fix tests fix the shell test_queries fix TxGasMeter construction from GasLimit wasm: fix tests fix shared/sdk build without rand ethereum_bridge: fix build with "testing" feature various fixes tests: fix build benches: fix build apps: fix tests make -C wasm_for_tests rm ethereum_bridge dep from tx_prelude tidy up feature flags to avoid wasm-bindgen in wasm crates shared: fix tests sdk: fix tests ibc: fix tests ethereum_bridge: fix tests proof_of_stake: fix tests shielded_token: fix tests state: fix tests parameters: fix warning account: fix tests vote_ext: fix tests tx: fix tests gas: fix tests merkle_tree: fix tests rename struct Storage to State storage: fix tests move types, trait DB and MockDB impl from state to storage core: fix tests wasm: update lock file wasm_for_tests: fix build light_sdk: fix build encoding_spec: fix build apps: fix build shared: fix build wasm: fix build sdk: fix build token: add common `write_params` fn 0.29 rebase fixes add namada_token crate vp_prelude: fix build tx_prelude: fix build shielded_token: fix build tx_env: fix build ibc: fix build ethereum_bridge: fix build ethereum_bridge: use the original name for wrapped erc20s state: fix build merkle_tree: fix build vote_ext: fix build storage: refactor new fns in StorageRead using pred `Epochs` proof_of_stake: fix build rebase fixes merkle_tree: wip fix build proof_of_stake: wip fix build move ics23_specs from state into merkle_tree governance: fix build account: fix build macros: use full paths types used in `derive(StorageKeys)` trans_token: fix build tx: wip fix build move vote_ext tx data types from tx to vote_ext crate gas: fix build parameters: fix build move collection validation helpers into vp_env crate mv proto symlink to namada_tx move collection validation helpers from storage to vp_env storage: fix build core: re-export borsh move account related code from namada_storage to namada_account trans_token: fix build move ERC20 address constructors back to core core/types/internal: remove unsued import move core::types::vote_extensions into namada_vote_ext crate move core MembershipProof into merkle_tree crate move EvalVp from core into tx::data::eval_vp core/types/key: remove unused error case move state::traits hasher into core::types::hash namada_account: take account keys storage from namada_core::types::key namada_account: fix imports, update docstring add namada_account crate from namada_core::types::account move core::types::internal::tx into namada_state::tx_queue tx_env: update imports add namada_tx_env out of core::ledger::tx_env mod add namada_storage crate out of core::ledger::storage_api core: make vp_env crate out of ledger::vp_env mod core: move types::transaction mods into namada_tx::data update lock core: move proto and into namada_tx crate gas: fix imports core: move ledger::gas into new namada_gas crate ...
Describe your changes
We're dividing namada_core crate into more granular low-level crates. The updated dependency graph looks like this:
with dev-deps (blue):
This entails:
cargo check --tests
on each crate until passingProgress for "Make each new crate compile"
Low-level
account
gas
macros
parameters
storage
vp_env
merkle_tree
state
tx_env
tx_prelude
tx
vm_env
vote_ext
vp_prelude
Sub-systems
governance
trans_token
ethereum_bridge
ibc
proof_of_stake
shielded_token
token
Other
apps
encoding_spec
examples
light_sdk
sdk
shared
test_utils
tests
wasm
Indicate on which release or other PRs this topic is based on
v0.29.0 - Diff range for review: https://github.com/anoma/namada/pull/2312/files
Checklist before merging to
draft