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

feat: EthAPI: Add EthAddressToFilecoinAddress #10286

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

arajasek
Copy link
Contributor

Related Issues

Fixes #10279

Proposed Changes

Simple API that users can call to go from EthAddresses to Filecoin Addresses

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@@ -0,0 +1,35 @@
package itests

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't have a strong opinion on this but maybe move this to fevm_address_test.go and rename that file to eth_address_test.go since that name does cover this domain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need to have a dedicated test suite for the EthAPI, my hope is that this will be the start of that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point but the Eth API seems very large to stick in a single file?

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

secpKey, err := key.GenerateKey(types.KTDelegated)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still a secpKey since the type here is delegated?

Copy link
Contributor Author

@arajasek arajasek Feb 16, 2023

Choose a reason for hiding this comment

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

Yes, "Delegated" signature keys are solely secp.

Copy link
Contributor

Choose a reason for hiding this comment

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

For my own knowledge,
We also have a secp address type which I presume have secp keys
What is the mapping of address types to key types? Are those orthogonal concepts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this is a little gnarly. Secp addresses correspond to secp keys. Delegated addresses today solely correspond to secp keys. They will eventually support other kinds of signatures, such as "account abstraction".

So why do we have the KTDelegated sigtype today? It's because the Lotus keystore couples the stored key with its address representation. So when working with keys, we need to treat delegated sigtypes differently from secp sigtypes (eg. here).

apiFilAddr, err := client.EthAddressToFilecoinAddress(ctx, ethAddr)
require.NoError(t, err)

require.Equal(t, filecoinAddr, apiFilAddr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you enhance this test or add another test, to test the conversion for non delegated addresses?

@arajasek arajasek merged commit a2b996e into release/v1.20.0 Feb 16, 2023
@arajasek arajasek deleted the asr/eth-address-api branch February 16, 2023 18:04
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