-
Notifications
You must be signed in to change notification settings - Fork 11
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
Optimize validators storage #61
Conversation
let admin_res = ADMIN.get(deps.as_ref()); | ||
if let Err(err) = admin_res { | ||
let not_found = matches!(err, StdError::NotFound { .. }); | ||
if !not_found { | ||
return Err(ContractError::AdminError(AdminError::NotAdmin {})); | ||
} | ||
} else { | ||
return Err(ContractError::AdminError(AdminError::NotAdmin {})); | ||
} |
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.
There's probably a simpler / nicer way to do 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.
we should add such method to admin.
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.
wait... if this is only for tests, we do not want this in production build at all.
how about feature-gating it with #[cfg(features = "integration")]
and you make such a build for the wasm used in integration test? Then no worries about it as this code path isn't in production at all
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 idea. Will do this tomorrow.
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.
Forgot to remove this in the first iteration.
Then, tried to do it in a follow-up, but hit dependency / feature problems with compiling the wasm using the integration feature.
I'll post my working copy and we can see if there's a way around those problems (other than keeping / removing the entry point entirely).
Update: See #77.
Requires "tgrade" cosmwasm-vm feature
48f42d5
to
de18d26
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.
Looks good.
Please make all this integration test code feature gated.
Also ensure we have longer addresses, maybe 1 with 20 byte as bech32, other as 32 byte
let admin_res = ADMIN.get(deps.as_ref()); | ||
if let Err(err) = admin_res { | ||
let not_found = matches!(err, StdError::NotFound { .. }); | ||
if !not_found { | ||
return Err(ContractError::AdminError(AdminError::NotAdmin {})); | ||
} | ||
} else { | ||
return Err(ContractError::AdminError(AdminError::NotAdmin {})); | ||
} |
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 add such method to admin.
let admin_res = ADMIN.get(deps.as_ref()); | ||
if let Err(err) = admin_res { | ||
let not_found = matches!(err, StdError::NotFound { .. }); | ||
if !not_found { | ||
return Err(ContractError::AdminError(AdminError::NotAdmin {})); | ||
} | ||
} else { | ||
return Err(ContractError::AdminError(AdminError::NotAdmin {})); | ||
} |
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.
wait... if this is only for tests, we do not want this in production build at all.
how about feature-gating it with #[cfg(features = "integration")]
and you make such a build for the wasm used in integration test? Then no worries about it as this code path isn't in production at all
189a67b
to
db375ac
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.
One last change requested, so we get proper test numbers
use tgrade_valset::msg::ExecuteMsg; | ||
use tgrade_valset::state::ValidatorInfo; | ||
|
||
// Copied from test_helpers | ||
// returns a list of addresses that are set in the tg4-stake contract | ||
fn addrs(count: u32) -> Vec<String> { | ||
(1..=count).map(|x| format!("operator-{:03}", x)).collect() | ||
(1..=count) | ||
.map(|x| bech32::encode("tgrade", format!("operator-{:03}", x).to_base32(), Variant::Bech32).unwrap()) |
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 is getting closer, but not realistic.
The two cases I refer to are
(1) 20 unencoded bytes before the bech32
(2) 32 unencoded bytes before the bech32
I would replace format!("operator-{:03}", x).to_base32()
with
format!("20-byte-operator-{:03}", x)
which is 20 bytes
I guess we can skip the 32 byte variant for now as it is unlikely anyone uses contracts, but it would be interesting to test as a true upper limit
Closes #42.
After a lot of wrestling, added a couple integration tests to see
Item
fail.I was determined to do this as part of
tgrade-valset
integration tests, as I think this might be useful in the future. That required adding the "tgrade" feature to cosmwasm-vm. Will publish that in a cosmwasm PR (CosmWasm/cosmwasm#1208) and we decide what to do with it there.Creating as Draft, as this is just the failure case at the moment. Will work in the proposed fix next.Of course, tests will not pass until a new cosmwasm-vm supporting the "tgrade" feature is released.