From 4537f6b52218da30f055eb61ed264d9be6ccb4e0 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 27 Jun 2024 01:43:02 +0000 Subject: [PATCH] feat: rename Actor.Address to Actor.DelegatedAddress (#279) See https://github.com/filecoin-project/lotus/pull/12155 --- builtin/actor_tree.go | 10 +++++----- builtin/cbor_gen.go | 12 ++++++------ builtin/v10/check.go | 8 ++++---- builtin/v10/init/invariants.go | 2 +- builtin/v10/migration/eam.go | 10 +++++----- builtin/v10/migration/top.go | 20 ++++++++++---------- builtin/v11/check.go | 8 ++++---- builtin/v11/init/invariants.go | 2 +- builtin/v12/check.go | 8 ++++---- builtin/v12/init/invariants.go | 2 +- builtin/v13/check.go | 8 ++++---- builtin/v13/init/invariants.go | 2 +- builtin/v14/check.go | 8 ++++---- builtin/v14/init/invariants.go | 2 +- builtin/v14/migration/top.go | 6 +++--- migration/job.go | 10 +++++----- 16 files changed, 59 insertions(+), 59 deletions(-) diff --git a/builtin/actor_tree.go b/builtin/actor_tree.go index 496b5d5f..0e0b48b3 100644 --- a/builtin/actor_tree.go +++ b/builtin/actor_tree.go @@ -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. diff --git a/builtin/cbor_gen.go b/builtin/cbor_gen.go index a1fb59ab..b7264631 100644 --- a/builtin/cbor_gen.go +++ b/builtin/cbor_gen.go @@ -168,8 +168,8 @@ func (t *ActorV5) MarshalCBOR(w io.Writer) error { return err } - // t.Address (address.Address) (struct) - if err := t.Address.MarshalCBOR(cw); err != nil { + // t.DelegatedAddress (address.Address) (struct) + if err := t.DelegatedAddress.MarshalCBOR(cw); err != nil { return err } return nil @@ -245,7 +245,7 @@ func (t *ActorV5) UnmarshalCBOR(r io.Reader) (err error) { } } - // t.Address (address.Address) (struct) + // t.DelegatedAddress (address.Address) (struct) { @@ -257,9 +257,9 @@ func (t *ActorV5) UnmarshalCBOR(r io.Reader) (err error) { if err := cr.UnreadByte(); err != nil { return err } - t.Address = new(address.Address) - if err := t.Address.UnmarshalCBOR(cr); err != nil { - return xerrors.Errorf("unmarshaling t.Address pointer: %w", err) + t.DelegatedAddress = new(address.Address) + if err := t.DelegatedAddress.UnmarshalCBOR(cr); err != nil { + return xerrors.Errorf("unmarshaling t.DelegatedAddress pointer: %w", err) } } diff --git a/builtin/v10/check.go b/builtin/v10/check.go index c05e27d3..b20e40d0 100644 --- a/builtin/v10/check.go +++ b/builtin/v10/check.go @@ -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) } } diff --git a/builtin/v10/init/invariants.go b/builtin/v10/init/invariants.go index e47d0e08..193fb210 100644 --- a/builtin/v10/init/invariants.go +++ b/builtin/v10/init/invariants.go @@ -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 diff --git a/builtin/v10/migration/eam.go b/builtin/v10/migration/eam.go index b2c9f11e..18b7e5d8 100644 --- a/builtin/v10/migration/eam.go +++ b/builtin/v10/migration/eam.go @@ -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 } diff --git a/builtin/v10/migration/top.go b/builtin/v10/migration/top.go index a66a9bb6..7713ca93 100644 --- a/builtin/v10/migration/top.go +++ b/builtin/v10/migration/top.go @@ -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: ðZeroAddr, + Code: ethAccountCID, + Head: emptyObj, + CallSeqNum: 0, + Balance: abi.NewTokenAmount(0), + DelegatedAddress: ðZeroAddr, }); err != nil { return cid.Undef, xerrors.Errorf("failed to set ethZeroActor: %w", err) } @@ -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 } diff --git a/builtin/v11/check.go b/builtin/v11/check.go index b3d1c769..6519f229 100644 --- a/builtin/v11/check.go +++ b/builtin/v11/check.go @@ -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) } } diff --git a/builtin/v11/init/invariants.go b/builtin/v11/init/invariants.go index ef199fdc..67472a12 100644 --- a/builtin/v11/init/invariants.go +++ b/builtin/v11/init/invariants.go @@ -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 diff --git a/builtin/v12/check.go b/builtin/v12/check.go index f1e24c52..d67b76e4 100644 --- a/builtin/v12/check.go +++ b/builtin/v12/check.go @@ -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) } } diff --git a/builtin/v12/init/invariants.go b/builtin/v12/init/invariants.go index c13c9868..220f6f30 100644 --- a/builtin/v12/init/invariants.go +++ b/builtin/v12/init/invariants.go @@ -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 diff --git a/builtin/v13/check.go b/builtin/v13/check.go index ed0a3085..ee20b0e0 100644 --- a/builtin/v13/check.go +++ b/builtin/v13/check.go @@ -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) } } diff --git a/builtin/v13/init/invariants.go b/builtin/v13/init/invariants.go index e67d65ea..c949c43d 100644 --- a/builtin/v13/init/invariants.go +++ b/builtin/v13/init/invariants.go @@ -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 diff --git a/builtin/v14/check.go b/builtin/v14/check.go index c86e9226..1522f977 100644 --- a/builtin/v14/check.go +++ b/builtin/v14/check.go @@ -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) } } diff --git a/builtin/v14/init/invariants.go b/builtin/v14/init/invariants.go index fecb0519..00c62d53 100644 --- a/builtin/v14/init/invariants.go +++ b/builtin/v14/init/invariants.go @@ -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 diff --git a/builtin/v14/migration/top.go b/builtin/v14/migration/top.go index c4c8d9e4..21556bf1 100644 --- a/builtin/v14/migration/top.go +++ b/builtin/v14/migration/top.go @@ -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 { diff --git a/migration/job.go b/migration/job.go index 7a17194e..ef8b824e 100644 --- a/migration/job.go +++ b/migration/job.go @@ -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 }