Skip to content
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

Update osmosis tests(with modified wasm) #518

Closed
wants to merge 17 commits into from

Conversation

Buckram123
Copy link
Collaborator

@Buckram123 Buckram123 commented Oct 30, 2024

Alternative to #512

Here we use build script to change creator, instead of adding a new feature.

From the user perspective.
This approach:

  • have to set ABSTRACT_CREATOR environment to seed or public key bytes before compiling the contract
  • all of the contract dependencies(for example dex adapter) should be compiled with same ABSTRACT_CREATOR
  • No indication if the wasm was built with or without custom ABSTRACT_CREATOR

#512 :

  • Have to set feature on abstract-MODULE and all of the abstract module dependencies (for example dex adapter)
  • Have to have same feature name as enabled in abstract-MODULE (right now feature named mock-deployment)
  • Have to add mock build inside [package.metadata.optimizer] section
  • Two sets of the wasm, mock deployment is clearly visible

It's not a final, before I finish would be nice to have final approve on one of the methods
TODO, if this method gets approved:

  • Figure out where we want to set the ENV. Currently I like setting it in .cargo/config.toml#env section, because this file usually public and also will be moved inside docker(so no need to set it separately for the docker), but it's easy to deploy the wrong version this way
  • If we rely on custom ABSTRACT_CREATOR in tests, tests that use wasms, will fail in release version, are we fine with that, anything we can do with it?

let public_key = bip32::Mnemonic::new(&creator, Default::default())
.map(|phrase| {
let seed = phrase.to_seed("");
let derive_path: bip32::DerivationPath = "m/44'/118'/0'/0/0".parse().unwrap();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we have to add coin_type or derive_path as another env? IMO it's an overkill until someone needs it

Comment on lines 74 to +77
native_addrs::creator_address(hrp)?,
"Only predetermined abstract admin can deploy abstract contracts, see `native_addrs.rs`"
);

let admin = sender_addr.to_string();
// upload
let mut deployment = Self::store_on(chain.clone())?;
let blob_code_id = deployment.blob.code_id()?;

let creator_account_id: cosmrs::AccountId = admin.as_str().parse().unwrap();
let canon_creator = CanonicalAddr::from(creator_account_id.to_bytes());

let expected_addr = |salt: &[u8]| -> Result<CanonicalAddr, Instantiate2AddressError> {
instantiate2_address(&cw_blob::CHECKSUM, &canon_creator, salt)
};

deployment.ans_host.deterministic_instantiate(
&abstract_std::ans_host::MigrateMsg::Instantiate(
abstract_std::ans_host::InstantiateMsg {
admin: admin.to_string(),
},
),
blob_code_id,
expected_addr(native_addrs::ANS_HOST_SALT)?,
Binary::from(native_addrs::ANS_HOST_SALT),
)?;

deployment.registry.deterministic_instantiate(
&abstract_std::registry::MigrateMsg::Instantiate(
abstract_std::registry::InstantiateMsg {
admin: admin.to_string(),
#[cfg(feature = "integration")]
security_disabled: Some(true),
#[cfg(not(feature = "integration"))]
security_disabled: Some(false),
namespace_registration_fee: None,
},
),
blob_code_id,
expected_addr(native_addrs::REGISTRY_SALT)?,
Binary::from(native_addrs::REGISTRY_SALT),
)?;
deployment.module_factory.deterministic_instantiate(
&abstract_std::module_factory::MigrateMsg::Instantiate(
abstract_std::module_factory::InstantiateMsg {
admin: admin.to_string(),
},
),
blob_code_id,
expected_addr(native_addrs::MODULE_FACTORY_SALT)?,
Binary::from(native_addrs::MODULE_FACTORY_SALT),
)?;

// We also instantiate ibc contracts
deployment.ibc.client.deterministic_instantiate(
&abstract_std::ibc_client::MigrateMsg::Instantiate(
abstract_std::ibc_client::InstantiateMsg {},
),
blob_code_id,
expected_addr(native_addrs::IBC_CLIENT_SALT)?,
Binary::from(native_addrs::IBC_CLIENT_SALT),
)?;
deployment.ibc.host.deterministic_instantiate(
&abstract_std::ibc_host::MigrateMsg::Instantiate(
abstract_std::ibc_host::InstantiateMsg {},
),
blob_code_id,
expected_addr(native_addrs::IBC_HOST_SALT)?,
Binary::from(native_addrs::IBC_HOST_SALT),
)?;
deployment.ibc.register(&deployment.registry)?;

deployment.registry.register_base(&deployment.account)?;
deployment
.registry
.register_natives(deployment.contracts())?;
deployment.registry.approve_any_abstract_modules()?;

// Create the first abstract account in integration environments
#[cfg(feature = "integration")]
use abstract_std::objects::gov_type::GovernanceDetails;
#[cfg(feature = "integration")]
AccountI::create_default_account(
&deployment,
GovernanceDetails::Monarchy {
monarch: chain.sender_addr().to_string(),
},
)?;
let mut deployment = Self::_deploy(&chain)?;
Copy link
Collaborator Author

@Buckram123 Buckram123 Oct 30, 2024

Choose a reason for hiding this comment

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

Was thinking about having second deploy function, like mock_deploy, where we allow changing creator, and in default we check if creator matches to the original

Comment on lines +79 to +80
const MOCK_MNEMONIC: &str = "clip hire initial neck maid actor venue client foam budget lock catalog sweet steak waste crater broccoli pipe steak sister coyote moment obvious choose";

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we can get it from env, but what do we do if it's not set?

Copy link

cloudflare-workers-and-pages bot commented Oct 30, 2024

Deploying abstract-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3d06f9b
Status: ✅  Deploy successful!
Preview URL: https://ac36e985.abstract-docs.pages.dev
Branch Preview URL: https://buckram-update-osmosis-test.abstract-docs.pages.dev

View logs

@Buckram123
Copy link
Collaborator Author

Closed in favor #528

@Buckram123 Buckram123 closed this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant