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

Use address in the wallet config for module initialization during genesis #879

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

666lcz
Copy link
Contributor

@666lcz 666lcz commented Mar 16, 2022

Problem

The oracle object for SuiEcho needs to be transferred to some trusted address during module initialization in genesis

fun init(ctx: &mut TxContext) {
let oracle = oracle_address();
Transfer::transfer(
CrossChainAirdropOracle {
id: TxContext::new_id(ctx),
managed_contracts: Vector::empty(),
},
oracle
)
}

Right now we are using a hardcoded address, and this presents a few problems:

  1. To be able to test the flow in Rust, we need to expose the private key of this address
  2. At the moment, the REST server owns the wallet(subject to change), and it's unsafe to transmit the private key of this oracle address from the oracle server to the REST server over the network.

Solution

We will transfer the oracle object to the address that initializes the modules during genesis. The question is what should this genesis address be?

Right now this address is default to be "0x00...000". This PR replaces it with the last address in the wallet config so that the oracle object can be transferred to an address controlled by the wallet. This is a simple but temporary solution that unblocks GDC.

After we are done with the migration to manage keys on client(as opposed to the REST server), the client should specify the address they want to use for initializing modules when calling /genesis

Copy link
Contributor

@patrickkuo patrickkuo left a comment

Choose a reason for hiding this comment

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

It's a bit hacky here, will need to revisit this after GDC.

Code LGTM, agree to unblock.

@666lcz 666lcz merged commit f668016 into main Mar 17, 2022
@666lcz 666lcz deleted the chris/default-address branch March 17, 2022 19:44
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