Skip to content

WIP: feat(x/auth): add support for foreign address spaces #24507

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

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

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Apr 14, 2025

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Copy link

ironbird-prod bot commented Apr 14, 2025

Ironbird - launch a network To use Ironbird, you can use the following commands:
  • /ironbird start OR /ironbird start --load-test-config= - Launch a testnet with the specified chain and load test configuration.
  • /ironbird chains - List of chain images that ironbird can use to spin-up testnet
  • /ironbird loadtests - List of load test modes that ironbird can run against testnet
Custom Load Test Configuration You can provide a custom load test configuration using the `--load-test-config=` flag:
/ironbird start cosmos --load-test-config={
  "block_gas_limit_target": 0.75,
  "num_of_blocks": 50,
  "msgs": [
    {"weight": 0.3, "type": "MsgSend"},
    {"weight": 0.3, "type": "MsgMultiSend"},
	{"weight": 0.4, "type": "MsgArr", "ContainedType": "MsgSend", "NumMsgs": 3300}
  ]
}

Use /ironbird loadtests to see more examples.

Comment on lines +151 to +152
addressSpaceManagers: map[AddressSpacePrefix]AddressSpaceManager{},
addressPrefixByName: map[string]AddressSpacePrefix{},
Copy link
Contributor

@aljo242 aljo242 Apr 14, 2025

Choose a reason for hiding this comment

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

how will these maps be populated given that they are in memory?

Copy link
Member Author

@aaronc aaronc Apr 14, 2025

Choose a reason for hiding this comment

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

With AccountKeeper.DefineAddressSpace from app.go

Comment on lines +13 to +27
// AddressSpaceManager is an interface for managing foreign address spaces.
type AddressSpaceManager interface {
// Name is the name of the address space.
Name() string

// DeriveAddress derives an address from the given account ID and public key.
// Implementations should attempt to follow the rules for their address space
// when the public key is of a known type (ex. secp256k1) and should perform
// a suitable derivation for other key types when the public key is unknown or nil.
// The account ID passed to this method will always be non-nil, but the
// public key may be nil.
// Implementations should not panic if the public key is nil and should instead
// perform derivation simply based on the account ID.
DeriveAddress(id AccountID, pubKey cryptotypes.PubKey) Address
}
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be possible to get a simple example impl of this that works for the basic cosmos address stuff we have now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably what makes sense is to do a simple example for EVM. Because for cosmos, we would just use PubKey.Address() for the initial derivation

Copy link
Member Author

Choose a reason for hiding this comment

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

mgr := ak.addressSpaceManagers[prefix]
addr := mgr.DeriveAddress(id, pk)
if addr == nil {
panic("failed to derive address for account")

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
err = ak.AddressByAccountID.Set(ctx, collections.Join(id, prefix), addr)
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
}
err = ak.AccountIDByAddress.Set(ctx, collections.Join(prefix, addr), id)
if err != nil {
panic(err)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods Warning

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants