-
Notifications
You must be signed in to change notification settings - Fork 960
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
refactor out namada crate #3402
Conversation
c6ffa27
to
8dd4a05
Compare
8dd4a05
to
8e91b53
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3402 +/- ##
==========================================
+ Coverage 53.66% 54.51% +0.85%
==========================================
Files 322 323 +1
Lines 111871 113288 +1417
==========================================
+ Hits 60035 61762 +1727
+ Misses 51836 51526 -310 ☔ View full report in Codecov by Sentry. |
635d40b
to
949f6b1
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.
nice changes! I have a couple of suggestions
crates/benches/native_vps.rs
Outdated
// Use an empty verifiers set placeholder for validation, this is only | ||
// needed in actual txs to addresses whose VPs should be triggered | ||
let verifiers = Rc::new(RefCell::new(BTreeSet::<Address>::new())); | ||
|
||
let exec_ctx = PseudoExecutionContext::new(ibc.ctx.pre()); | ||
let exec_ctx = | ||
PseudoExecutionContext::<'_, '_, _, _, _, token::Store<_>>::new( |
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.
:o big turbo fish
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.
I've added type aliases for this to improve this 5513de2
crates/core/src/ledger/mod.rs
Outdated
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.
this file is empty but not deleted. we should git rm
it
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.
never trust what github says lol: fatal: pathspec 'crates/core/src/ledger/mod.rs' did not match any files
. There were however some leftover regression files that are no longer being used, cleared in c0d04cb
|
||
/// Abstract parameters storage read interface | ||
pub trait Read<S> { | ||
/// Storage error | ||
type Err; |
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.
nice approach. I think we should eventually still try to hide these details from core
, if possible, but it's a big improvement over the previous iteration of namada
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 was thinking the same - maybe we could put these into a new crate namada_systems
or something - It would actually help to have a concrete type for the error too to avoid having to type Err = namada_state::StorageError
in some places
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.
I've done this in a follow-up PR #3472
where | ||
S: StateRead, | ||
CA: 'static + WasmCacheAccess, | ||
S: 'static + StateRead, | ||
EVAL: 'static + VpEvaluator<'ctx, S, CA, EVAL>, | ||
{ |
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.
not a fan of adding trait bounds to struct definitions. if possible, we should arrange to get rid of them everywhere in the codebase. they place unnecessary restrictions on these types, that could be made stricter at the method definition level using where
clauses.
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.
agree - we need to remove the bounds on the inner fields (in here it's the native_vp::Ctx
) - I'll open a separate issue for this
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.
crates/ibc/src/vp/mod.rs
Outdated
/// Parameters type | ||
pub params: PhantomData<Params>, | ||
/// Governance type | ||
pub gov: PhantomData<Gov>, | ||
/// Token type | ||
pub token: PhantomData<Token>, | ||
/// PoS type | ||
pub pos: PhantomData<PoS>, |
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.
personal preference, I prefer creating a single type with all the generics using a tuple, eg
/// Parameters type | |
pub params: PhantomData<Params>, | |
/// Governance type | |
pub gov: PhantomData<Gov>, | |
/// Token type | |
pub token: PhantomData<Token>, | |
/// PoS type | |
pub pos: PhantomData<PoS>, | |
_marker: PhantomData<(Params, Gov, Token, PoS)>, |
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.
good call - done in 9695d7b
// Invoke the root RPC handler - returns borsh-encoded data on success | ||
let result = if query.path == RPC.shell().dry_run_tx_path() { | ||
dry_run_tx(ctx, &query) | ||
dry_run_tx( | ||
unsafe { self.state.read_only().with_static_temp_write_log() }, |
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.
unsafe { self.state.read_only().with_static_temp_write_log() }, | |
// SAFETY: blah blah | |
unsafe { self.state.read_only().with_static_temp_write_log() }, |
consider adding a small explanation on why this is fine
unsafe { | ||
borrowed.state.read_only().with_static_temp_write_log() | ||
}, |
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.
same thing here
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.
@@ -564,7 +544,6 @@ impl TypeHash | |||
typehash!(SerializeWrapper<BTreeMap<String, Address>>); | |||
} | |||
|
|||
#[cfg(feature = "migrations")] |
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.
the sdk always has migrations enabled by default?
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's still guarded but I just moved it onto the mod migrations
instead
crates/state/src/wl_state.rs
Outdated
/// The lifetime of borrows is unsafely extended to `'static` to allow usage | ||
/// in node's `dry_run_tx`, which needs a static lifetime to be able to call | ||
/// protocol's API that is generic over the state with a bound `S: 'static + | ||
/// State` with a mutable reference to this struct. | ||
/// Because the lifetime of `S` is invariant w.r.t. `&mut S` | ||
/// (<https://doc.rust-lang.org/nomicon/subtyping.html>) we are faking a | ||
/// static lifetime of `S` for `TempWlState`. This should be safe as neither | ||
/// `db` nor `in_mem` are actually mutable, only the `write_log` which is | ||
/// owned by this struct. |
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.
I think this is the explanation that should go under those unsafe
blocks. here we should only write something like "the caller must guarantee that ..."
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.
improved this in a04ad35
crates/vm/src/wasm/run.rs
Outdated
tracing::warn!( | ||
"VP eval from a native VP failed with: | ||
{err}", | ||
); |
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.
nit: fix this weird formatting
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.
59918ef
to
81e16b5
Compare
81e16b5
to
1104095
Compare
1104095
to
d222183
Compare
d222183
to
c602ac1
Compare
d08a0ea
to
1154023
Compare
Hey @tzemanovic, your pull request has been dequeued due to the following reason: PR_DEQUEUED. |
@Mergifyio requeue |
✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically |
Hey @tzemanovic, your pull request has been dequeued due to the following reason: PR_DEQUEUED. |
@Mergifyio refresh |
✅ Pull request refreshed |
Hey @tzemanovic, your pull request has been dequeued due to the following reason: PR_DEQUEUED. |
@Mergifyio refresh |
✅ Pull request refreshed |
@Mergifyio refresh |
✅ Pull request refreshed |
Describe your changes
Related to #2111 this PR refactors out the
namada
crate that will be removed. Two new crates are added:namada_vp
with native VP interfaces and VP host fns implementationsnamada_vm
with the VM and its wasm implementationThe native VPs from
namada
crate are moved to their respective crates using the approach outlined in https://hackmd.io/@heliax/r131cSMSR (note that existing cross system deps are not yet removed, only the ones in the moved native VPs):proof_of_stake::Read
storage andtoken::Keys
)token::Keys
)governance::Read
,parameters::Keys + Read
,token::Keys + Write
andproof_of_stake::Read
)governance::Read
,parameters::Read
) - moved intoshielded_token
governance::Read
,parameters::Read
) - moved intotrans_token
governance::Read
)governance::Read
)Additionally:
namada_parameters
crate innamada_state
was removed with the same DI approach as above to allow thenamada_parameters
to depend onnamada_vp
to implement its native VPmod namada::ledger::protocol
is moved intonamada_node::protocol
mod namada::vm::prefix_iter
moved tonamada_state::prefix_iter
fn dry_run_tx
is moved into thenode
cratemod control_flow
has been moved fromnamada_sdk
tonamada_core
(feature-guarded by non-default "control_flow" as it needs tokio)Deps graph
The two highlighted crates are newly added:
Indicate on which release or other PRs this topic is based on
v0.41.0
namada
crate into relevant system's cratecrates/sdk/src/validation.rs
that injects the dependencies for native VPsChecklist before merging to
draft