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: Partial implementation of FIP-0048 (f4/delegated addresses) #1118

Merged
merged 2 commits into from
Jan 30, 2023

Conversation

arajasek
Copy link
Contributor

Extracted from next.

This is a partial implementation of FIP-0048. This PR:

  • updates to the new Actor object, that includes an Optional field for Predictable addresses
  • introduces the new Placeholder actor that has no state and accepts all calls
  • updates the init actor to store f4 addresses in its map
  • adds a new lookup_delegated_address syscall to retrieve an actor's f4 address

It does NOT introduce the new Exec4 method specified in FIP-0048, as that method requires implementation of the Ethereum Address Manager actor. That will be included in a future PR.

actors/init/src/state.rs Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2023

Codecov Report

Merging #1118 (7feeb4b) into master (ea76792) will decrease coverage by 0.22%.
The diff coverage is 66.34%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1118      +/-   ##
==========================================
- Coverage   89.28%   89.07%   -0.22%     
==========================================
  Files          93       94       +1     
  Lines       19611    19718     +107     
==========================================
+ Hits        17510    17564      +54     
- Misses       2101     2154      +53     
Impacted Files Coverage Δ
runtime/src/actor_error.rs 77.41% <ø> (ø)
state/src/check.rs 86.73% <ø> (ø)
actors/init/src/lib.rs 89.28% <54.54%> (-8.59%) ⬇️
actors/init/src/state.rs 82.75% <54.54%> (-17.25%) ⬇️
runtime/src/test_utils.rs 81.83% <54.76%> (-1.46%) ⬇️
test_vm/src/lib.rs 87.07% <64.38%> (-1.84%) ⬇️
actors/datacap/src/lib.rs 79.29% <80.95%> (+1.73%) ⬆️
actors/market/src/lib.rs 90.91% <85.71%> (-0.11%) ⬇️
actors/market/src/ext.rs 100.00% <100.00%> (ø)
actors/miner/src/state.rs 80.88% <100.00%> (ø)
... and 10 more

if existing {
// NOTE: this case should be impossible, but we check it anyways just in case something
// changes.
return Err(ActorError::forbidden("cannot exec over an existing actor".into()));
Copy link
Member

Choose a reason for hiding this comment

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

Include the colliding ID for debugging.

actors/init/src/state.rs Outdated Show resolved Hide resolved
@@ -74,6 +74,10 @@ pub trait Runtime: Primitives + Verifier + RuntimePolicy {
/// If the argument is an ID address it is returned directly.
fn resolve_address(&self, address: &Address) -> Option<ActorID>;

/// Looks-up the "delegated" address of an actor by ID, if any. Returns None if either the
/// target actor doesn't exist, or if the target actor doesn't have either an f4 address.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// target actor doesn't exist, or if the target actor doesn't have either an f4 address.
/// target actor doesn't exist, or doesn't have an f4 address.

@@ -458,6 +464,17 @@ impl<BS: Blockstore> MockRuntime<BS> {
self.id_addresses.insert(source, target);
}

pub fn add_delegated_address(&mut self, source: Address, target: Address) {
Copy link
Member

Choose a reason for hiding this comment

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

Just take an ActorID as the source parameter. Change the maps to also use ActorID type in the appropriate parameter so it's obvious which way round they go.

Consider calling this set_delegated_address().

@@ -111,6 +112,8 @@ pub struct MockRuntime<BS = MemoryBlockstore> {
pub miner: Address,
pub base_fee: TokenAmount,
pub id_addresses: HashMap<Address, Address>,
pub delegated_addresses: HashMap<Address, Address>,
pub delegated_addresses_source: HashMap<Address, Address>,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this second map is needed - these mappings should just go in the id_addresses map instead. These mappings should just replicate what's in the Init actor. I can understand that we need the ID -> delegated address map explicitly because we don't have the actor state tree, which would otherwise encapsulate it.

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 you're right, will make this change -- thank you!

.delegated_addresses_source
.get(address)
.and_then(|a| self.resolve_address(a));
}
Copy link
Member

Choose a reason for hiding this comment

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

This change will disappear of the delegated addresses are mapped in the existing mapping.

@anorth anorth changed the title feat: Partial implementation of FIP-0048 feat: Partial implementation of FIP-0048 (f4/delegated addresses) Jan 29, 2023
@arajasek arajasek merged commit 46945f8 into master Jan 30, 2023
@arajasek arajasek deleted the asr/delegated-addresses branch January 30, 2023 02:01
shamb0 pushed a commit to shamb0/builtin-actors that referenced this pull request Jan 31, 2023
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.

3 participants