Skip to content

Commit

Permalink
chore: make gen & fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Dec 13, 2022
1 parent de5c465 commit bdf4419
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 46 deletions.
6 changes: 3 additions & 3 deletions venus-devtool/state-type-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ var pendingPkgs = func() map[string]*pendingPkg {
for _, pkgName := range list {
pkgs[pkgName] = &pendingPkg{
name: pkgName,
ver: actors.Version(actors.LatestVersion),
path: fmt.Sprintf("%s/v%v/%s", prePath, actors.LatestVersion, pkgName),
ver: actors.Version(actors.Version9),
path: fmt.Sprintf("%s/v%v/%s", prePath, actors.Version9, pkgName),
}
}

Expand Down Expand Up @@ -203,7 +203,7 @@ func writeFile(dst string, metas []*metaVisitor) error {
fmt.Fprintln(&fileBuffer, ")\n")

for _, meta := range metas {
fmt.Fprintf(&fileBuffer, "////////// %s //////////\n", meta.pkgName)
fmt.Fprintf(&fileBuffer, "////////// %s //////////\n\n", meta.pkgName)
genDetail(&fileBuffer, meta.con, "const", meta.pkgName)
genDetail(&fileBuffer, meta.t, "type", meta.pkgName)
genDetail(&fileBuffer, meta.f, "var", meta.pkgName)
Expand Down
15 changes: 9 additions & 6 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
```

Expand Down Expand Up @@ -995,7 +996,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
```

Expand Down Expand Up @@ -1159,7 +1161,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
```

Expand Down Expand Up @@ -1308,7 +1311,7 @@ Perms: read
Inputs:
```json
[
17
18
]
```

Expand All @@ -1323,7 +1326,7 @@ Perms: read
Inputs:
```json
[
17
18
]
```

Expand Down Expand Up @@ -1605,7 +1608,7 @@ Inputs:
]
```

Response: `17`
Response: `18`

### StateSearchMsg

Expand Down
16 changes: 8 additions & 8 deletions venus-shared/api/chain/v0/mock/mock_fullnode.go

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

18 changes: 11 additions & 7 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
```

Expand Down Expand Up @@ -965,7 +966,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
```

Expand Down Expand Up @@ -1129,7 +1131,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
```

Expand Down Expand Up @@ -1278,7 +1281,7 @@ Perms: read
Inputs:
```json
[
17
18
]
```

Expand All @@ -1293,7 +1296,7 @@ Perms: read
Inputs:
```json
[
17
18
]
```

Expand Down Expand Up @@ -1615,7 +1618,7 @@ Inputs:
]
```

Response: `17`
Response: `18`

### StateSearchMsg
StateSearchMsg looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed
Expand Down Expand Up @@ -2936,7 +2939,8 @@ Response:
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"Nonce": 42,
"Balance": "0"
"Balance": "0",
"Address": "\u003cempty\u003e"
}
}
```
Expand Down
20 changes: 10 additions & 10 deletions venus-shared/api/chain/v1/mock/mock_fullnode.go

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

2 changes: 1 addition & 1 deletion venus-shared/api/gateway/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Inputs:
],
"Bw==",
10101,
17
18
]
```

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/gateway/v2/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Inputs:
],
"Bw==",
10101,
17
18
]
```

Expand Down
3 changes: 0 additions & 3 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c
- StateChangedActors
- StateCompute
- StateDecodeParams
> StateGetActor {[func(context.Context, address.Address, types.TipSetKey) (*internal.Actor, error) <> func(context.Context, address.Address, types.TipSetKey) (*types.ActorV5, error)] base=func out type: #0 input; nested={[*internal.Actor <> *types.ActorV5] base=pointed type; nested={[internal.Actor <> types.ActorV5] base=struct field; nested={[internal.Actor <> types.ActorV5] base=exported fields count: 4 != 5; nested=nil}}}}
> StateGetNetworkParams {[func(context.Context) (*types.NetworkParams, error) <> func(context.Context) (*api.NetworkParams, error)] base=func out type: #0 input; nested={[*types.NetworkParams <> *api.NetworkParams] base=pointed type; nested={[types.NetworkParams <> api.NetworkParams] base=struct field; nested={[types.NetworkParams <> api.NetworkParams] base=exported field type: #5 field named ForkUpgradeParams; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=struct field; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=exported fields count: 21 != 22; nested=nil}}}}}}
- StateGetRandomnessFromBeacon
- StateGetRandomnessFromTickets
Expand Down Expand Up @@ -200,9 +199,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
+ SetConcurrent
+ SetPassword
- Shutdown
> StateChangedActors {[func(context.Context, cid.Cid, cid.Cid) (map[string]internal.Actor, error) <> func(context.Context, cid.Cid, cid.Cid) (map[string]types.ActorV5, error)] base=func out type: #0 input; nested={[map[string]internal.Actor <> map[string]types.ActorV5] base=map value; nested={[internal.Actor <> types.ActorV5] base=struct field; nested={[internal.Actor <> types.ActorV5] base=exported fields count: 4 != 5; nested=nil}}}}
- StateCompute
> StateGetActor {[func(context.Context, address.Address, types.TipSetKey) (*internal.Actor, error) <> func(context.Context, address.Address, types.TipSetKey) (*types.ActorV5, error)] base=func out type: #0 input; nested={[*internal.Actor <> *types.ActorV5] base=pointed type; nested={[internal.Actor <> types.ActorV5] base=struct field; nested={[internal.Actor <> types.ActorV5] base=exported fields count: 4 != 5; nested=nil}}}}
> StateGetNetworkParams {[func(context.Context) (*types.NetworkParams, error) <> func(context.Context) (*api.NetworkParams, error)] base=func out type: #0 input; nested={[*types.NetworkParams <> *api.NetworkParams] base=pointed type; nested={[types.NetworkParams <> api.NetworkParams] base=struct field; nested={[types.NetworkParams <> api.NetworkParams] base=exported field type: #5 field named ForkUpgradeParams; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=struct field; nested={[types.ForkUpgradeParams <> api.ForkUpgradeParams] base=exported fields count: 21 != 22; nested=nil}}}}}}
+ StateMinerSectorSize
+ StateMinerWorkerAddress
Expand Down
4 changes: 4 additions & 0 deletions venus-shared/types/state_types_gen.go

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

28 changes: 22 additions & 6 deletions venus-shared/utils/method_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ import (
func TestMethodMap(t *testing.T) {
tf.UnitTest(t)

t.Run("Default to load mainnet v8 actors", func(t *testing.T) {
t.Run("Default to load mainnet actors", func(t *testing.T) {
for _, actorsMetadata := range actors.EmbeddedBuiltinActorsMetadata {
if actorsMetadata.Network == string(types.NetworkNameMain) {
for _, actor := range actorsMetadata.Actors {
for name, actor := range actorsMetadata.Actors {
_, ok := MethodsMap[actor]
assert.True(t, ok)
if skipEvmActor(name) {
assert.False(t, ok)
} else {
assert.True(t, ok)
}
}
}
}
})

t.Run("ReLoad butterflynet v8 actors", func(t *testing.T) {
t.Run("ReLoad butterflynet actors", func(t *testing.T) {
for _, actorsMetadata := range actors.EmbeddedBuiltinActorsMetadata {
if actorsMetadata.Network == string(types.NetworkNameButterfly) {
for _, actor := range actorsMetadata.Actors {
Expand All @@ -37,11 +41,23 @@ func TestMethodMap(t *testing.T) {
ReloadMethodsMap()
for _, actorsMetadata := range actors.EmbeddedBuiltinActorsMetadata {
if actorsMetadata.Network == string(types.NetworkNameButterfly) {
for _, actor := range actorsMetadata.Actors {
for name, actor := range actorsMetadata.Actors {
_, ok := MethodsMap[actor]
assert.True(t, ok)
if skipEvmActor(name) {
assert.False(t, ok)
} else {
assert.True(t, ok)
}
}
}
}
})
}

// 没有把 v10 actor注入,等注入后移除
func skipEvmActor(name string) bool {
if name == actors.EamKey || name == actors.EvmKey || name == actors.EmbryoKey {
return true
}
return false
}
6 changes: 5 additions & 1 deletion venus-shared/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ func TestLoadBuiltinActors(t *testing.T) {
assert.Equal(t, actor, res)

_, ok2 := MethodsMap[actor]
assert.True(t, ok2)
if skipEvmActor(name) {
assert.False(t, ok2)
} else {
assert.True(t, ok2)
}
}
}
}
Expand Down

0 comments on commit bdf4419

Please sign in to comment.