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

fix: state: rename Actor.Address and only use it for f4 addresses #12155

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions build/openrpc/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -15501,7 +15501,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -15541,7 +15541,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -15611,10 +15611,6 @@
"State": {
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -15623,6 +15619,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down Expand Up @@ -15892,18 +15892,14 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
}
],
"patternProperties": {
".*": {
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -15912,6 +15908,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down Expand Up @@ -16196,7 +16196,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -16236,7 +16236,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -16316,10 +16316,6 @@
"State": {
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -16328,6 +16324,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down Expand Up @@ -17001,15 +17001,11 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
],
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -17018,6 +17014,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down Expand Up @@ -21372,7 +21372,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -21412,7 +21412,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -21482,10 +21482,6 @@
"State": {
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -21494,6 +21490,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down
34 changes: 17 additions & 17 deletions build/openrpc/gateway.json
Original file line number Diff line number Diff line change
Expand Up @@ -6830,7 +6830,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -6870,7 +6870,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -6940,10 +6940,6 @@
"State": {
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -6952,6 +6948,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down Expand Up @@ -7418,15 +7418,11 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
],
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -7435,6 +7431,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down Expand Up @@ -9316,7 +9316,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -9356,7 +9356,7 @@
},
"Nonce": 42,
"Balance": "0",
"Address": "f01234"
"DelegatedAddress": "f01234"
}
},
"GasCharges": [
Expand Down Expand Up @@ -9426,10 +9426,6 @@
"State": {
"additionalProperties": false,
"properties": {
"Address": {
"additionalProperties": false,
"type": "object"
},
"Balance": {
"additionalProperties": false,
"type": "object"
Expand All @@ -9438,6 +9434,10 @@
"title": "Content Identifier",
"type": "string"
},
"DelegatedAddress": {
"additionalProperties": false,
"type": "object"
},
"Head": {
"title": "Content Identifier",
"type": "string"
Expand Down
4 changes: 2 additions & 2 deletions chain/consensus/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ func IsValidForSending(nv network.Version, act *types.Actor) bool {

// Allow placeholder actors with a delegated address and nonce 0 to send a message.
// These will be converted to an EthAccount actor on first send.
if !builtin.IsPlaceholderActor(act.Code) || act.Nonce != 0 || act.Address == nil || act.Address.Protocol() != address.Delegated {
if !builtin.IsPlaceholderActor(act.Code) || act.Nonce != 0 || act.DelegatedAddress == nil || act.DelegatedAddress.Protocol() != address.Delegated {
return false
}

// Only allow such actors to send if their delegated address is in the EAM's namespace.
id, _, err := varint.FromUvarint(act.Address.Payload())
id, _, err := varint.FromUvarint(act.DelegatedAddress.Payload())
return err == nil && id == builtintypes.EthereumAddressManagerActorID
}

Expand Down
28 changes: 14 additions & 14 deletions chain/consensus/filcns/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2115,11 +2115,11 @@ func buildUpgradeActorsV12MinerFix(oldBuggyMinerCID, newManifestCID cid.Cid) fun
}

return actorsOut.SetActor(a, &types.ActorV5{
Code: newCid,
Head: actor.Head,
Nonce: actor.Nonce,
Balance: actor.Balance,
Address: actor.Address,
Code: newCid,
Head: actor.Head,
Nonce: actor.Nonce,
Balance: actor.Balance,
DelegatedAddress: actor.DelegatedAddress,
})
})
if err != nil {
Expand Down Expand Up @@ -2153,8 +2153,8 @@ func buildUpgradeActorsV12MinerFix(oldBuggyMinerCID, newManifestCID cid.Cid) fun
return xerrors.Errorf("mismatched balance for actor %s: %d != %d", a, inActor.Balance, outActor.Balance)
}

if inActor.Address != outActor.Address && inActor.Address.String() != outActor.Address.String() {
return xerrors.Errorf("mismatched address for actor %s: %s != %s", a, inActor.Address, outActor.Address)
if inActor.DelegatedAddress != outActor.DelegatedAddress && inActor.DelegatedAddress.String() != outActor.DelegatedAddress.String() {
return xerrors.Errorf("mismatched address for actor %s: %s != %s", a, inActor.DelegatedAddress, outActor.DelegatedAddress)
}

if inActor.Head != outActor.Head && a != builtin.SystemActorAddr {
Expand Down Expand Up @@ -2413,11 +2413,11 @@ func upgradeActorsV13VerifregFix(oldBuggyVerifregCID, newManifestCID cid.Cid) fu
}

return actorsOut.SetActor(a, &types.ActorV5{
Code: newCid,
Head: actor.Head,
Nonce: actor.Nonce,
Balance: actor.Balance,
Address: actor.Address,
Code: newCid,
Head: actor.Head,
Nonce: actor.Nonce,
Balance: actor.Balance,
DelegatedAddress: actor.DelegatedAddress,
})
})
if err != nil {
Expand Down Expand Up @@ -2451,8 +2451,8 @@ func upgradeActorsV13VerifregFix(oldBuggyVerifregCID, newManifestCID cid.Cid) fu
return xerrors.Errorf("mismatched balance for actor %s: %d != %d", a, inActor.Balance, outActor.Balance)
}

if inActor.Address != outActor.Address && inActor.Address.String() != outActor.Address.String() {
return xerrors.Errorf("mismatched address for actor %s: %s != %s", a, inActor.Address, outActor.Address)
if inActor.DelegatedAddress != outActor.DelegatedAddress && inActor.DelegatedAddress.String() != outActor.DelegatedAddress.String() {
return xerrors.Errorf("mismatched address for actor %s: %s != %s", a, inActor.DelegatedAddress, outActor.DelegatedAddress)
}

if inActor.Head != outActor.Head && a != builtin.SystemActorAddr {
Expand Down
13 changes: 9 additions & 4 deletions chain/gen/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,16 @@ func MakeAccountActor(ctx context.Context, cst cbor.IpldStore, av actorstypes.Ve
return nil, xerrors.Errorf("failed to get account actor code ID for actors version %d", av)
}

var delegatedAddr *address.Address
if addr.Protocol() == address.Delegated {
delegatedAddr = &addr
}

act := &types.Actor{
Code: actcid,
Head: statecid,
Balance: bal,
Address: &addr,
Code: actcid,
Head: statecid,
Balance: bal,
DelegatedAddress: delegatedAddr,
}

return act, nil
Expand Down
Loading
Loading