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 / change contracts intantiation logic #45

Open
maurolacy opened this issue Sep 26, 2024 · 0 comments
Open

Refactor / change contracts intantiation logic #45

maurolacy opened this issue Sep 26, 2024 · 0 comments
Assignees

Comments

@maurolacy
Copy link
Contributor

maurolacy commented Sep 26, 2024

The contracts instantiation logic is somewhat convoluted right now, in that the babylon-contract instantiates both the staking and finality contracts. This requires some back and forth messages between contracts, so that they know their addresses and can communicate.

Contracts dependencies / references details:

  • babylon-contract has to know both, staking and finality address, to properly route IBC messages to them.
  • btc-staking has to know the babylon-contract address, to validate that some privileged messages come from it. It also needs it to (in the future) query / mirror the BTC headers / tip information.
  • btc-finality needs to know both, the babylon address, to forward the slashing message, and to validate that privileged messages come from it. And the staking address, for membership / voting power queries.

Refactor this into a SDK instantiation, in which the SDK instantiates each of the contracts independently. The address of the other contracts can then be passed as instantiation params.

Proposed instantiation sequence:

  1. Instantiate the babylon contract.
  2. Instantiate the staking contract, passing the address of the babylon contract.
  3. Instantiate the finality contract, passing the address of both the babylon and staking contracts.

Needless to say, this has to be done in conjunction with contract modifications.
Also, this will impact not only the SDK, but e2e tests in which the current instantiation logic is being used / relied upon.

Also, as part of this, or in a follow-up, the SDK can provide a convenience query endpoint that reports the addresses of the different contracts.
tgrade reference / example for the poe-contracts query:

https://github.com/confio/tgrade/blob/1bc8463f3760bf9549389a02a9e48eda482a59fe/x/poe/client/cli/query.go#L42

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

No branches or pull requests

2 participants