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: api: add StateGetNetworkParmas #4875

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
38 changes: 38 additions & 0 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,41 @@ func (cia *chainInfoAPI) ChainGetPath(ctx context.Context, from types.TipSetKey,
}
return path, nil
}

simlecode marked this conversation as resolved.
Show resolved Hide resolved
func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.NetworkParams, error) {
networkName, err := cia.getNetworkName(ctx)
if err != nil {
return nil, err
}
cfg := cia.chain.config.Repo().Config()
params := &types.NetworkParams{
NetworkName: types.NetworkName(networkName),
BlockDelaySecs: cfg.NetworkParams.BlockDelay,
ConsensusMinerMinPower: abi.NewStoragePower(int64(cfg.NetworkParams.ConsensusMinerMinPower)),
SupportedProofTypes: cfg.NetworkParams.ReplaceProofTypes,
PreCommitChallengeDelay: cfg.NetworkParams.PreCommitChallengeDelay,
ForkUpgradeParams: types.ForkUpgradeParams{
UpgradeSmokeHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeSmokeHeight,
UpgradeBreezeHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeBreezeHeight,
UpgradeIgnitionHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeIgnitionHeight,
UpgradeLiftoffHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeLiftoffHeight,
UpgradeAssemblyHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeAssemblyHeight,
UpgradeRefuelHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeRefuelHeight,
UpgradeTapeHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTapeHeight,
UpgradeKumquatHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeKumquatHeight,
BreezeGasTampingDuration: cfg.NetworkParams.ForkUpgradeParam.BreezeGasTampingDuration,
UpgradeCalicoHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeCalicoHeight,
UpgradePersianHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradePersianHeight,
UpgradeOrangeHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeOrangeHeight,
UpgradeClausHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeClausHeight,
UpgradeTrustHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTrustHeight,
UpgradeNorwegianHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeNorwegianHeight,
UpgradeTurboHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTurboHeight,
UpgradeHyperdriveHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeHyperdriveHeight,
UpgradeChocolateHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeChocolateHeight,
UpgradeOhSnapHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeOhSnapHeight,
},
}

return params, nil
}
1 change: 1 addition & 0 deletions venus-shared/api/chain/v0/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type IChainInfo interface {
VerifyEntry(parent, child *types.BeaconEntry, height abi.ChainEpoch) bool //perm:read
ChainExport(context.Context, abi.ChainEpoch, bool, types.TipSetKey) (<-chan []byte, error) //perm:read
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*types.HeadChange, error) //perm:read
StateGetNetworkParams(ctx context.Context) (*types.NetworkParams, error) //perm:read
}

type IMinerState interface {
Expand Down
42 changes: 42 additions & 0 deletions venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
* [MessageWait](#MessageWait)
* [ProtocolParameters](#ProtocolParameters)
* [ResolveToKeyAddr](#ResolveToKeyAddr)
* [StateGetNetworkParams](#StateGetNetworkParams)
* [StateGetReceipt](#StateGetReceipt)
* [StateNetworkName](#StateNetworkName)
* [StateNetworkVersion](#StateNetworkVersion)
Expand Down Expand Up @@ -1243,6 +1244,47 @@ Inputs:

Response: `"f01234"`

### StateGetNetworkParams


Perms: read

Inputs: `[]`

Response:
```json
{
"NetworkName": "mainnet",
"BlockDelaySecs": 42,
"ConsensusMinerMinPower": "0",
"SupportedProofTypes": [
8
],
"PreCommitChallengeDelay": 10101,
"ForkUpgradeParams": {
"UpgradeSmokeHeight": 10101,
"UpgradeBreezeHeight": 10101,
"UpgradeIgnitionHeight": 10101,
"UpgradeLiftoffHeight": 10101,
"UpgradeAssemblyHeight": 10101,
"UpgradeRefuelHeight": 10101,
"UpgradeTapeHeight": 10101,
"UpgradeKumquatHeight": 10101,
"BreezeGasTampingDuration": 10101,
"UpgradeCalicoHeight": 10101,
"UpgradePersianHeight": 10101,
"UpgradeOrangeHeight": 10101,
"UpgradeClausHeight": 10101,
"UpgradeTrustHeight": 10101,
"UpgradeNorwegianHeight": 10101,
"UpgradeTurboHeight": 10101,
"UpgradeHyperdriveHeight": 10101,
"UpgradeChocolateHeight": 10101,
"UpgradeOhSnapHeight": 10101
}
}
```

### StateGetReceipt


Expand Down
15 changes: 15 additions & 0 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.

4 changes: 4 additions & 0 deletions venus-shared/api/chain/v0/proxy_gen.go

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

1 change: 1 addition & 0 deletions venus-shared/api/chain/v1/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type IChainInfo interface {
VerifyEntry(parent, child *types.BeaconEntry, height abi.ChainEpoch) bool //perm:read
ChainExport(context.Context, abi.ChainEpoch, bool, types.TipSetKey) (<-chan []byte, error) //perm:read
ChainGetPath(ctx context.Context, from types.TipSetKey, to types.TipSetKey) ([]*types.HeadChange, error) //perm:read
StateGetNetworkParams(ctx context.Context) (*types.NetworkParams, error) //perm:read
}

type IMinerState interface {
Expand Down
42 changes: 42 additions & 0 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* [MessageWait](#MessageWait)
* [ProtocolParameters](#ProtocolParameters)
* [ResolveToKeyAddr](#ResolveToKeyAddr)
* [StateGetNetworkParams](#StateGetNetworkParams)
* [StateGetRandomnessFromBeacon](#StateGetRandomnessFromBeacon)
* [StateGetRandomnessFromTickets](#StateGetRandomnessFromTickets)
* [StateNetworkName](#StateNetworkName)
Expand Down Expand Up @@ -1275,6 +1276,47 @@ Inputs:

Response: `"f01234"`

### StateGetNetworkParams


Perms: read

Inputs: `[]`

Response:
```json
{
"NetworkName": "mainnet",
"BlockDelaySecs": 42,
"ConsensusMinerMinPower": "0",
"SupportedProofTypes": [
8
],
"PreCommitChallengeDelay": 10101,
"ForkUpgradeParams": {
"UpgradeSmokeHeight": 10101,
"UpgradeBreezeHeight": 10101,
"UpgradeIgnitionHeight": 10101,
"UpgradeLiftoffHeight": 10101,
"UpgradeAssemblyHeight": 10101,
"UpgradeRefuelHeight": 10101,
"UpgradeTapeHeight": 10101,
"UpgradeKumquatHeight": 10101,
"BreezeGasTampingDuration": 10101,
"UpgradeCalicoHeight": 10101,
"UpgradePersianHeight": 10101,
"UpgradeOrangeHeight": 10101,
"UpgradeClausHeight": 10101,
"UpgradeTrustHeight": 10101,
"UpgradeNorwegianHeight": 10101,
"UpgradeTurboHeight": 10101,
"UpgradeHyperdriveHeight": 10101,
"UpgradeChocolateHeight": 10101,
"UpgradeOhSnapHeight": 10101
}
}
```

### StateGetRandomnessFromBeacon


Expand Down
15 changes: 15 additions & 0 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.

4 changes: 4 additions & 0 deletions venus-shared/api/chain/v1/proxy_gen.go

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

2 changes: 2 additions & 0 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c
> StateDealProviderCollateralBounds {[func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (types.DealCollateralBounds, error) <> func(context.Context, abi.PaddedPieceSize, bool, types.TipSetKey) (api.DealCollateralBounds, error)] base=func in type: #3 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
- StateDecodeParams
> StateGetActor {[func(context.Context, address.Address, types.TipSetKey) (*internal.Actor, error) <> func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error)] base=func in type: #2 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
+ StateGetNetworkParams
- StateGetRandomnessFromBeacon
- StateGetRandomnessFromTickets
> StateGetReceipt {[func(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error) <> func(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)] base=func in type: #2 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
Expand Down Expand Up @@ -322,6 +323,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.c
- StateDecodeParams
- StateEncodeParams
> StateGetActor {[func(context.Context, address.Address, types.TipSetKey) (*internal.Actor, error) <> func(context.Context, address.Address, types.TipSetKey) (*types.Actor, error)] base=func in type: #2 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
+ StateGetNetworkParams
> StateGetRandomnessFromBeacon {[func(context.Context, crypto.DomainSeparationTag, abi.ChainEpoch, []uint8, types.TipSetKey) (abi.Randomness, error) <> func(context.Context, crypto.DomainSeparationTag, abi.ChainEpoch, []uint8, types.TipSetKey) (abi.Randomness, error)] base=func in type: #4 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
> StateGetRandomnessFromTickets {[func(context.Context, crypto.DomainSeparationTag, abi.ChainEpoch, []uint8, types.TipSetKey) (abi.Randomness, error) <> func(context.Context, crypto.DomainSeparationTag, abi.ChainEpoch, []uint8, types.TipSetKey) (abi.Randomness, error)] base=func in type: #4 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
> StateListActors {[func(context.Context, types.TipSetKey) ([]address.Address, error) <> func(context.Context, types.TipSetKey) ([]address.Address, error)] base=func in type: #1 input; nested={[types.TipSetKey <> types.TipSetKey] base=codec marshaler implementations for codec Cbor: true != false; nested=nil}}
Expand Down
2 changes: 2 additions & 0 deletions venus-shared/compatible-checks/api-perm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ v0: github.com/filecoin-project/venus/venus-shared/api/chain/v0 <> github.com/fi
- IChainInfo.MessageWait
- IChainInfo.ProtocolParameters
- IChainInfo.ResolveToKeyAddr
- IChainInfo.StateGetNetworkParams
- IChainInfo.VerifyEntry
- IMinerState.StateMinerSectorSize
- IMinerState.StateMinerWorkerAddress
Expand Down Expand Up @@ -55,6 +56,7 @@ v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/fi
- IChainInfo.MessageWait
- IChainInfo.ProtocolParameters
- IChainInfo.ResolveToKeyAddr
- IChainInfo.StateGetNetworkParams
- IChainInfo.VerifyEntry
- IMinerState.StateMinerSectorSize
- IMinerState.StateMinerWorkerAddress
Expand Down
31 changes: 31 additions & 0 deletions venus-shared/types/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,34 @@ type InvocResult struct {
Error string
Duration time.Duration
}

type NetworkParams struct {
NetworkName NetworkName
BlockDelaySecs uint64
ConsensusMinerMinPower abi.StoragePower
SupportedProofTypes []abi.RegisteredSealProof
PreCommitChallengeDelay abi.ChainEpoch
ForkUpgradeParams ForkUpgradeParams
}

type ForkUpgradeParams struct {
UpgradeSmokeHeight abi.ChainEpoch
UpgradeBreezeHeight abi.ChainEpoch
UpgradeIgnitionHeight abi.ChainEpoch
UpgradeLiftoffHeight abi.ChainEpoch
UpgradeAssemblyHeight abi.ChainEpoch
UpgradeRefuelHeight abi.ChainEpoch
UpgradeTapeHeight abi.ChainEpoch
UpgradeKumquatHeight abi.ChainEpoch
BreezeGasTampingDuration abi.ChainEpoch
UpgradeCalicoHeight abi.ChainEpoch
UpgradePersianHeight abi.ChainEpoch
UpgradeOrangeHeight abi.ChainEpoch
UpgradeClausHeight abi.ChainEpoch
UpgradeTrustHeight abi.ChainEpoch
UpgradeNorwegianHeight abi.ChainEpoch
UpgradeTurboHeight abi.ChainEpoch
UpgradeHyperdriveHeight abi.ChainEpoch
UpgradeChocolateHeight abi.ChainEpoch
UpgradeOhSnapHeight abi.ChainEpoch
}