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

refactor instantiation logic #94

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

SebastianElvis
Copy link
Member

@SebastianElvis SebastianElvis commented Dec 6, 2024

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

LGTM. Just some comments about the overall design.

Will review the SDK PR next.

Comment on lines 49 to 53
pub fn get_babylon_sdk_params(querier: &QuerierWrapper) -> Result<Params, StdError> {
let params = querier.query_grpc(QUERY_PARAMS_PATH.to_owned(), Binary::new("".into()))?;
let params = QueryParamsResponse::from(params).params;
Ok(params)
}
Copy link
Contributor

@maurolacy maurolacy Dec 6, 2024

Choose a reason for hiding this comment

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

I think this approach is not without merit, but it would be much simpler IMO to just pass the needed params during instantiation. The contracts have a clear dependencies, so it's just a matter of instantiating them in the right order and pass required parameters (other contracts' addresses) between them at instantiation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Finally got back to this PR. In the ideal case, indeed it's better if we let each contract to only keep references of contracts that it interacts with. However, we have a couple of cyclic dependencies between contracts, making it difficult for instantiating them in order.

In addition, the contract might not be persistent. It's possible that the consumer's gov prop deploys another sets of contracts and specifies them as the "official version" through the governance proposal. Once this happens then there can be discrepencies between parameters of Babylon SDK and Babylon contracts.

Thus I proposed we make contract addresses in Babylon SDK module parameters as single source of truth, and let contract find each other through Babylon SDK. What do you think?

Comment on lines -20 to -21
pub babylon: Addr,
pub staking: Addr,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just keep these, and pass / set them during instantiation.

Comment on lines 263 to 264
pub fn get_activated_height(querier: &QuerierWrapper) -> StdResult<u64> {
let params = get_babylon_sdk_params(querier)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This is good for encapsulation, but bad for performance. In any case, since you already have it why not pass the entire Config by reference instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants