Skip to content

Commit

Permalink
feat: rename Actor.Address to Actor.DelegatedAddress (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored Jun 27, 2024
1 parent dfbb813 commit 4537f6b
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 59 deletions.
10 changes: 5 additions & 5 deletions builtin/actor_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ type ActorV4 struct {

// As above, but this is the actor state for state tree version 5 and above.
type ActorV5 struct {
Code cid.Cid // CID representing the code associated with the actor
Head cid.Cid // CID of the head state object for the actor
CallSeqNum uint64 // CallSeqNum for the next message to be received by the actor (non-zero for accounts only)
Balance big.Int // Token balance of the actor
Address *address.Address // Delegated (f4) actor address
Code cid.Cid // CID representing the code associated with the actor
Head cid.Cid // CID of the head state object for the actor
CallSeqNum uint64 // CallSeqNum for the next message to be received by the actor (non-zero for accounts only)
Balance big.Int // Token balance of the actor
DelegatedAddress *address.Address // Delegated (f4) actor address
}

// A specialization of a map of ID-addresses to actor heads.
Expand Down
12 changes: 6 additions & 6 deletions builtin/cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions builtin/v10/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func CheckStateInvariants(tree *builtin.ActorTree, priorEpoch abi.ChainEpoch, ac
}
totalFIl = big.Add(totalFIl, actor.Balance)

if actor.Address != nil {
acc.Require(actor.Address.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.Address)
if actor.Address.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.Address)
if actor.DelegatedAddress != nil {
acc.Require(actor.DelegatedAddress.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.DelegatedAddress)
if actor.DelegatedAddress.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.DelegatedAddress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/v10/init/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func CheckStateInvariants(st *State, tree *builtin.ActorTree, actorCodes map[str
actor.Code == actorCodes[manifest.EvmKey] ||
actor.Code == actorCodes[manifest.PlaceholderKey]) &&
keyAddr.Protocol() != addr.Actor {
acc.Require(keyAddr == *actor.Address, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.Address, keyAddr)
acc.Require(keyAddr == *actor.DelegatedAddress, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.DelegatedAddress, keyAddr)
}

return nil
Expand Down
10 changes: 5 additions & 5 deletions builtin/v10/migration/eam.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ func CreateEAMActor(m *manifest.Manifest, head cid.Cid) (*builtin.ActorV5, error
}

return &builtin.ActorV5{
Code: eamCode,
Head: head,
CallSeqNum: 0,
Balance: abi.NewTokenAmount(0),
Address: nil,
Code: eamCode,
Head: head,
CallSeqNum: 0,
Balance: abi.NewTokenAmount(0),
DelegatedAddress: nil,
}, nil
}
20 changes: 10 additions & 10 deletions builtin/v10/migration/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
}

if err := actorsOut.SetActorV5(ethZeroAddrId, &builtin.ActorV5{
Code: ethAccountCID,
Head: emptyObj,
CallSeqNum: 0,
Balance: abi.NewTokenAmount(0),
Address: &ethZeroAddr,
Code: ethAccountCID,
Head: emptyObj,
CallSeqNum: 0,
Balance: abi.NewTokenAmount(0),
DelegatedAddress: &ethZeroAddr,
}); err != nil {
return cid.Undef, xerrors.Errorf("failed to set ethZeroActor: %w", err)
}
Expand Down Expand Up @@ -337,11 +337,11 @@ func (job *migrationJob) run(ctx context.Context, store cbor.IpldStore, priorEpo
return &migrationJobResult{
job.Address, // Unchanged
builtin.ActorV5{
Code: result.NewCodeCID,
Head: result.NewHead,
CallSeqNum: job.ActorV4.CallSeqNum, // Unchanged
Balance: job.ActorV4.Balance, // Unchanged
Address: nil, // Not assigned to existing actors.
Code: result.NewCodeCID,
Head: result.NewHead,
CallSeqNum: job.ActorV4.CallSeqNum, // Unchanged
Balance: job.ActorV4.Balance, // Unchanged
DelegatedAddress: nil, // Not assigned to existing actors.
},
}, nil
}
Expand Down
8 changes: 4 additions & 4 deletions builtin/v11/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func CheckStateInvariants(tree *builtin.ActorTree, priorEpoch abi.ChainEpoch, ac
}
totalFIl = big.Add(totalFIl, actor.Balance)

if actor.Address != nil {
acc.Require(actor.Address.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.Address)
if actor.Address.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.Address)
if actor.DelegatedAddress != nil {
acc.Require(actor.DelegatedAddress.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.DelegatedAddress)
if actor.DelegatedAddress.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.DelegatedAddress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/v11/init/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func CheckStateInvariants(st *State, tree *builtin.ActorTree, actorCodes map[str
actor.Code == actorCodes[manifest.EvmKey] ||
actor.Code == actorCodes[manifest.PlaceholderKey]) &&
keyAddr.Protocol() != addr.Actor {
acc.Require(keyAddr == *actor.Address, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.Address, keyAddr)
acc.Require(keyAddr == *actor.DelegatedAddress, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.DelegatedAddress, keyAddr)
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions builtin/v12/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func CheckStateInvariants(tree *builtin.ActorTree, priorEpoch abi.ChainEpoch, ac
}
totalFIl = big.Add(totalFIl, actor.Balance)

if actor.Address != nil {
acc.Require(actor.Address.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.Address)
if actor.Address.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.Address)
if actor.DelegatedAddress != nil {
acc.Require(actor.DelegatedAddress.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.DelegatedAddress)
if actor.DelegatedAddress.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.DelegatedAddress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/v12/init/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func CheckStateInvariants(st *State, tree *builtin.ActorTree, actorCodes map[str
actor.Code == actorCodes[manifest.EvmKey] ||
actor.Code == actorCodes[manifest.PlaceholderKey]) &&
keyAddr.Protocol() != addr.Actor {
acc.Require(keyAddr == *actor.Address, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.Address, keyAddr)
acc.Require(keyAddr == *actor.DelegatedAddress, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.DelegatedAddress, keyAddr)
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions builtin/v13/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func CheckStateInvariants(tree *builtin.ActorTree, priorEpoch abi.ChainEpoch, ac
}
totalFIl = big.Add(totalFIl, actor.Balance)

if actor.Address != nil {
acc.Require(actor.Address.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.Address)
if actor.Address.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.Address)
if actor.DelegatedAddress != nil {
acc.Require(actor.DelegatedAddress.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.DelegatedAddress)
if actor.DelegatedAddress.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.DelegatedAddress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/v13/init/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func CheckStateInvariants(st *State, tree *builtin.ActorTree, actorCodes map[str
actor.Code == actorCodes[manifest.EvmKey] ||
actor.Code == actorCodes[manifest.PlaceholderKey]) &&
keyAddr.Protocol() != addr.Actor {
acc.Require(keyAddr == *actor.Address, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.Address, keyAddr)
acc.Require(keyAddr == *actor.DelegatedAddress, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.DelegatedAddress, keyAddr)
}

return nil
Expand Down
8 changes: 4 additions & 4 deletions builtin/v14/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func CheckStateInvariants(tree *builtin.ActorTree, priorEpoch abi.ChainEpoch, ac
}
totalFIl = big.Add(totalFIl, actor.Balance)

if actor.Address != nil {
acc.Require(actor.Address.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.Address)
if actor.Address.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.Address)
if actor.DelegatedAddress != nil {
acc.Require(actor.DelegatedAddress.Protocol() == address.Delegated, "actor.Address %v is not a delegated address", *actor.DelegatedAddress)
if actor.DelegatedAddress.Protocol() == address.Delegated {
delegatedAddrs = append(delegatedAddrs, *actor.DelegatedAddress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion builtin/v14/init/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func CheckStateInvariants(st *State, tree *builtin.ActorTree, actorCodes map[str
actor.Code == actorCodes[manifest.EvmKey] ||
actor.Code == actorCodes[manifest.PlaceholderKey]) &&
keyAddr.Protocol() != addr.Actor {
acc.Require(keyAddr == *actor.Address, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.Address, keyAddr)
acc.Require(keyAddr == *actor.DelegatedAddress, "address field in actor state differs from addr available in init actor map: actor=%v, init=%v", *actor.DelegatedAddress, keyAddr)
}

return nil
Expand Down
6 changes: 3 additions & 3 deletions builtin/v14/migration/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
Balance: f090OldAct.Balance,

// changed
Code: newAccountCodeCID,
Head: h,
Address: &f090ID,
Code: newAccountCodeCID,
Head: h,
DelegatedAddress: &f090ID,
})
}
if err := f090Migration(actorsOut); err != nil {
Expand Down
10 changes: 5 additions & 5 deletions migration/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func (job *migrationJob) run(ctx context.Context, store cbor.IpldStore) (*migrat
return &migrationJobResult{
job.Address, // Unchanged
builtin.ActorV5{
Code: result.NewCodeCID,
Head: result.NewHead,
CallSeqNum: job.ActorV5.CallSeqNum, // Unchanged
Balance: job.ActorV5.Balance, // Unchanged
Address: job.ActorV5.Address, // Unchanged
Code: result.NewCodeCID,
Head: result.NewHead,
CallSeqNum: job.ActorV5.CallSeqNum, // Unchanged
Balance: job.ActorV5.Balance, // Unchanged
DelegatedAddress: job.ActorV5.DelegatedAddress, // Unchanged
},
}, nil
}

0 comments on commit 4537f6b

Please sign in to comment.