Skip to content

Commit 3dbe0c3

Browse files
authored
Mainnet Edge Case Fixes (#413)
* fix: multisig constructor fallback * feat: zero address actor * fix: add zero address translation * fix: rm invalid check * fix: leftover debugging code
1 parent 740449a commit 3dbe0c3

2 files changed

Lines changed: 53 additions & 5 deletions

File tree

actors/v2/multisig/multisig.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,21 @@ func (*Msig) MsigConstructor(network string, height int64, raw []byte) (map[stri
2424
return nil, fmt.Errorf("constructorParams: %s not found", version.String())
2525
}
2626

27-
return parseCBOR(raw, nil, params(), nil)
27+
metadata, err := parseCBOR(raw, nil, params(), nil)
28+
if err != nil {
29+
versions := tools.GetSupportedVersions(network)
30+
for _, version := range versions {
31+
params, ok := constructorParams[version.String()]
32+
if !ok {
33+
continue
34+
}
35+
metadata, err = parseCBOR(raw, nil, params(), nil)
36+
if err == nil {
37+
break
38+
}
39+
}
40+
}
41+
return metadata, err
2842
}
2943

3044
func (*Msig) Approve(network string, msg *parser.LotusMessage, height int64, key filTypes.TipSetKey, rawParams, rawReturn []byte) (map[string]interface{}, error) {

parser/helper/helpers.go

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ const (
5454
// https://github.com/filecoin-project/lotus/releases/tag/v1.28.1
5555
// https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0085.md
5656
keylessAccountActor = "f090"
57+
// ZeroAddressAccountActorRobust f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a is a zero address actor that existed until V10.
58+
// Created: https://github.com/filecoin-project/lotus/blob/5750f49834deee9dfce752ff840630ae402a8b51/build/buildconstants/params_shared_vals.go#L56
59+
// Terminated: https://github.com/filecoin-project/lotus/blob/5750f49834deee9dfce752ff840630ae402a8b51/chain/consensus/filcns/upgrades.go#L1054
60+
ZeroAddressAccountActorRobust = "f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a"
61+
// ZeroAddressAccountActorShort f067253 is a zero address actor that existed until V10.
62+
// Created: https://github.com/filecoin-project/lotus/blob/5750f49834deee9dfce752ff840630ae402a8b51/build/buildconstants/params_shared_vals.go#L56
63+
// Terminated: https://github.com/filecoin-project/lotus/blob/5750f49834deee9dfce752ff840630ae402a8b51/chain/consensus/filcns/upgrades.go#L1054
64+
ZeroAddressAccountActorShort = "f067253"
5765
// multisig actorcode for nv22
5866
msigCidStr = "bafk2bzacedef4sqdsfebspu7dqnk7naj27ac4lyho4zmvjrei5qnf2wn6v64u"
5967
// account actorcode for nv23
@@ -182,11 +190,17 @@ func (h *Helper) GetActorAddressInfo(add address.Address, key filTypes.TipSetKey
182190

183191
addInfo.Short, err = h.actorCache.GetShortAddress(add)
184192
if err != nil {
193+
if ok, _, _ := h.isZeroAddressAccountActor(add); ok {
194+
addInfo.Short = ZeroAddressAccountActorShort
195+
}
185196
h.logger.Errorf("could not get short address for %s. Err: %v", add.String(), err)
186197
}
187198

188199
addInfo.Robust, err = h.actorCache.GetRobustAddress(add)
189200
if err != nil {
201+
if ok, _, _ := h.isZeroAddressAccountActor(add); ok {
202+
addInfo.Robust = ZeroAddressAccountActorRobust
203+
}
190204
h.logger.Errorf("could not get robust address for %s. Err: %v", add.String(), err)
191205
}
192206

@@ -199,10 +213,8 @@ func (h *Helper) GetActorNameFromAddress(add address.Address, height int64, key
199213
if add == address.Undef {
200214
return cid.Undef, "", errors.New("address is undefined")
201215
}
202-
// The f090 address was a multisig actor until V23 where it was converted to an account actor
203-
// https://github.com/filecoin-project/lotus/releases/tag/v1.28.1
204-
// https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0085.md
205-
if ok, cid, actorName := h.isKeylessAccountActor(add, height); ok {
216+
217+
if ok, cid, actorName := h.isSpecialAccountActor(add, height); ok {
206218
return cid, actorName, nil
207219
}
208220

@@ -233,6 +245,28 @@ func (h *Helper) GetActorNameFromAddress(add address.Address, height int64, key
233245
}
234246
}
235247

248+
// isSpecialAccountActor handles actor addresses that will fail to resolve from the node for reasons documented in each case.
249+
func (h *Helper) isSpecialAccountActor(add address.Address, height int64) (bool, cid.Cid, string) {
250+
if ok, cid, actorName := h.isZeroAddressAccountActor(add); ok {
251+
return true, cid, actorName
252+
}
253+
if ok, cid, actorName := h.isKeylessAccountActor(add, height); ok {
254+
return true, cid, actorName
255+
}
256+
return false, cid.Undef, ""
257+
}
258+
259+
// The f3yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaby2smx7a(f067253) is a zero address actor that existed until V10.
260+
// Created: https://github.com/filecoin-project/lotus/blob/5750f49834deee9dfce752ff840630ae402a8b51/build/buildconstants/params_shared_vals.go#L56
261+
// Terminated: https://github.com/filecoin-project/lotus/blob/5750f49834deee9dfce752ff840630ae402a8b51/chain/consensus/filcns/upgrades.go#L1054
262+
func (h *Helper) isZeroAddressAccountActor(add address.Address) (bool, cid.Cid, string) {
263+
if h.network != tools.MainnetNetwork || (add.String() != ZeroAddressAccountActorRobust && add.String() != ZeroAddressAccountActorShort) {
264+
return false, cid.Undef, ""
265+
}
266+
267+
return true, accountCid, manifest.AccountKey
268+
}
269+
236270
// The f090 address was a multisig actor until V23 where it was converted to an account actor
237271
// https://github.com/filecoin-project/lotus/releases/tag/v1.28.1
238272
// https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0085.md

0 commit comments

Comments
 (0)