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

Feat/support method type fee cfg / 支持消息类型级别的费用配置 #5632

Merged
merged 4 commits into from
Jan 6, 2023
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
3 changes: 2 additions & 1 deletion fixtures/networks/network_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package networks

import (
"fmt"
"strings"

"github.com/filecoin-project/venus/pkg/config"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/utils"
)

func GetNetworkFromName(name string) (types.NetworkType, error) {
if name == "2k" {
if name == "2k" || strings.HasPrefix(name, "localnet-") {
return types.Network2k, nil
}
if name == "force" {
Expand Down
19 changes: 10 additions & 9 deletions venus-devtool/api-gen/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"time"

"github.com/filecoin-project/go-state-types/actors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
datatransfer "github.com/filecoin-project/go-data-transfer"
Expand Down Expand Up @@ -89,6 +91,7 @@ func init() {
panic(err)
}
addExample(constants.TestNetworkVersion)
addExample(actors.Version6)
allocationID := verifreg.AllocationId(0)
addExample(allocationID)
addExample(&allocationID)
Expand Down Expand Up @@ -283,7 +286,7 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
return ExampleValue(method, t.Elem(), nil)
case reflect.Struct:
es := exampleStruct(method, t, parent)
v := reflect.ValueOf(es).Elem().Interface()
v := reflect.ValueOf(es).Interface()
ExampleValues[t] = v
return v
case reflect.Array:
Expand All @@ -297,12 +300,9 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
out.SetMapIndex(reflect.ValueOf(ExampleValue(method, t.Key(), parent)), reflect.ValueOf(ExampleValue(method, t.Elem(), parent)))
return out.Interface()
case reflect.Ptr:
if t.Elem().Kind() == reflect.Struct {
es := exampleStruct(method, t.Elem(), t)
// ExampleValues[t] = es
return es
}

out := reflect.New(t.Elem())
out.Elem().Set(reflect.ValueOf(ExampleValue(method, t.Elem(), t)))
return out.Interface()
case reflect.Interface:
if t.Implements(reflect.TypeOf((*error)(nil)).Elem()) {
return fmt.Errorf("empty error")
Expand All @@ -315,15 +315,16 @@ func ExampleValue(method string, t, parent reflect.Type) interface{} {
}

func exampleStruct(method string, t, parent reflect.Type) interface{} {
ns := reflect.New(t)
ns := reflect.New(t).Elem()
for i := 0; i < t.NumField(); i++ {
f := t.Field(i)
if shouldIgnoreField(f, parent) {
continue
}

if strings.Title(f.Name) == f.Name {
ns.Elem().Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
fmt.Println(f.Name)
ns.Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
}
}

Expand Down
43 changes: 31 additions & 12 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -3186,7 +3186,9 @@ Response:
"ExpectedStoragePledge": "0",
"ReplacedSectorAge": 10101,
"ReplacedDayReward": "0",
"SectorKeyCID": null,
"SectorKeyCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SimpleQAPower": true
}
]
Expand Down Expand Up @@ -3349,7 +3351,9 @@ Inputs:
5432
],
"Expiration": 10101,
"UnsealedCid": null
"UnsealedCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
},
[
{
Expand Down Expand Up @@ -3468,7 +3472,9 @@ Inputs:
5432
],
"Expiration": 10101,
"UnsealedCid": null
"UnsealedCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
},
[
{
Expand Down Expand Up @@ -3633,7 +3639,8 @@ Inputs:
[
"f01234",
[
0
5,
1
],
[
{
Expand Down Expand Up @@ -3667,7 +3674,9 @@ Response:
"ExpectedStoragePledge": "0",
"ReplacedSectorAge": 10101,
"ReplacedDayReward": "0",
"SectorKeyCID": null,
"SectorKeyCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SimpleQAPower": true
}
]
Expand Down Expand Up @@ -3765,7 +3774,9 @@ Response:
"ExpectedStoragePledge": "0",
"ReplacedSectorAge": 10101,
"ReplacedDayReward": "0",
"SectorKeyCID": null,
"SectorKeyCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SimpleQAPower": true
}
```
Expand Down Expand Up @@ -3834,7 +3845,9 @@ Response:
5432
],
"Expiration": 10101,
"UnsealedCid": null
"UnsealedCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
},
"PreCommitDeposit": "0",
"PreCommitEpoch": 10101
Expand Down Expand Up @@ -4060,7 +4073,9 @@ Response:
{
"SealProof": 8,
"SectorNumber": 9,
"SectorKey": null,
"SectorKey": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SealedCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
Expand Down Expand Up @@ -4834,14 +4849,16 @@ Inputs:
Response:
```json
{
"Channel": "\u003cempty\u003e",
"Channel": "f01234",
"From": "f01234",
"To": "f01234",
"ConfirmedAmt": "0",
"PendingAmt": "0",
"NonReservedAmt": "0",
"PendingAvailableAmt": "0",
"PendingWaitSentinel": null,
"PendingWaitSentinel": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"QueuedAmt": "0",
"VoucherReedeemedAmt": "0"
}
Expand All @@ -4866,14 +4883,16 @@ Inputs:
Response:
```json
{
"Channel": "\u003cempty\u003e",
"Channel": "f01234",
"From": "f01234",
"To": "f01234",
"ConfirmedAmt": "0",
"PendingAmt": "0",
"NonReservedAmt": "0",
"PendingAvailableAmt": "0",
"PendingWaitSentinel": null,
"PendingWaitSentinel": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"QueuedAmt": "0",
"VoucherReedeemedAmt": "0"
}
Expand Down
46 changes: 33 additions & 13 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -3517,7 +3517,9 @@ Response:
"ExpectedStoragePledge": "0",
"ReplacedSectorAge": 10101,
"ReplacedDayReward": "0",
"SectorKeyCID": null,
"SectorKeyCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SimpleQAPower": true
}
]
Expand Down Expand Up @@ -3547,7 +3549,8 @@ Inputs:
Response:
```json
[
0
5,
1
]
```

Expand Down Expand Up @@ -3708,7 +3711,9 @@ Inputs:
5432
],
"Expiration": 10101,
"UnsealedCid": null
"UnsealedCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
},
[
{
Expand Down Expand Up @@ -3827,7 +3832,9 @@ Inputs:
5432
],
"Expiration": 10101,
"UnsealedCid": null
"UnsealedCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
},
[
{
Expand Down Expand Up @@ -3992,7 +3999,8 @@ Inputs:
[
"f01234",
[
0
5,
1
],
[
{
Expand Down Expand Up @@ -4026,7 +4034,9 @@ Response:
"ExpectedStoragePledge": "0",
"ReplacedSectorAge": 10101,
"ReplacedDayReward": "0",
"SectorKeyCID": null,
"SectorKeyCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SimpleQAPower": true
}
]
Expand Down Expand Up @@ -4155,7 +4165,9 @@ Response:
"ExpectedStoragePledge": "0",
"ReplacedSectorAge": 10101,
"ReplacedDayReward": "0",
"SectorKeyCID": null,
"SectorKeyCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SimpleQAPower": true
}
```
Expand Down Expand Up @@ -4230,7 +4242,9 @@ Response:
5432
],
"Expiration": 10101,
"UnsealedCid": null
"UnsealedCid": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
},
"PreCommitDeposit": "0",
"PreCommitEpoch": 10101
Expand Down Expand Up @@ -4456,7 +4470,9 @@ Response:
{
"SealProof": 8,
"SectorNumber": 9,
"SectorKey": null,
"SectorKey": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SealedCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
Expand Down Expand Up @@ -5422,14 +5438,16 @@ Inputs:
Response:
```json
{
"Channel": "\u003cempty\u003e",
"Channel": "f01234",
"From": "f01234",
"To": "f01234",
"ConfirmedAmt": "0",
"PendingAmt": "0",
"NonReservedAmt": "0",
"PendingAvailableAmt": "0",
"PendingWaitSentinel": null,
"PendingWaitSentinel": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"QueuedAmt": "0",
"VoucherReedeemedAmt": "0"
}
Expand All @@ -5454,14 +5472,16 @@ Inputs:
Response:
```json
{
"Channel": "\u003cempty\u003e",
"Channel": "f01234",
"From": "f01234",
"To": "f01234",
"ConfirmedAmt": "0",
"PendingAmt": "0",
"NonReservedAmt": "0",
"PendingAvailableAmt": "0",
"PendingWaitSentinel": null,
"PendingWaitSentinel": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"QueuedAmt": "0",
"VoucherReedeemedAmt": "0"
}
Expand Down
4 changes: 3 additions & 1 deletion venus-shared/api/gateway/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ Inputs:
{
"SealProof": 8,
"SectorNumber": 9,
"SectorKey": null,
"SectorKey": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SealedCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
Expand Down
4 changes: 3 additions & 1 deletion venus-shared/api/gateway/v2/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ Inputs:
{
"SealProof": 8,
"SectorNumber": 9,
"SectorKey": null,
"SectorKey": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
},
"SealedCID": {
"/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
}
Expand Down
Loading