From f098fc2a66ab0cb95bef6d95a9ae59b63cefbab0 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 16 May 2024 12:46:24 +1000 Subject: [PATCH] feat: api: add SectorNumber to MarketDealState (nv22) --- api/api_full.go | 12 +++++++++--- build/openrpc/full.json | 10 ++++++++++ build/openrpc/gateway.json | 5 +++++ build/openrpc/miner.json | 10 ++++++++++ chain/actors/builtin/market/actor.go.template | 5 +++++ chain/actors/builtin/market/market.go | 5 +++++ chain/actors/builtin/market/state.go.template | 8 ++++++++ chain/actors/builtin/market/v0.go | 6 ++++++ chain/actors/builtin/market/v10.go | 6 ++++++ chain/actors/builtin/market/v11.go | 6 ++++++ chain/actors/builtin/market/v12.go | 6 ++++++ chain/actors/builtin/market/v13.go | 6 ++++++ chain/actors/builtin/market/v14.go | 6 ++++++ chain/actors/builtin/market/v2.go | 6 ++++++ chain/actors/builtin/market/v3.go | 6 ++++++ chain/actors/builtin/market/v4.go | 6 ++++++ chain/actors/builtin/market/v5.go | 6 ++++++ chain/actors/builtin/market/v6.go | 6 ++++++ chain/actors/builtin/market/v7.go | 6 ++++++ chain/actors/builtin/market/v8.go | 6 ++++++ chain/actors/builtin/market/v9.go | 6 ++++++ documentation/en/api-v0-methods-miner.md | 2 ++ documentation/en/api-v0-methods.md | 2 ++ documentation/en/api-v1-unstable-methods.md | 2 ++ 24 files changed, 142 insertions(+), 3 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index bbfcae0a2..5d2fdc491 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -1166,13 +1166,15 @@ type MarketBalance struct { } type MarketDealState struct { - SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector - LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated - SlashEpoch abi.ChainEpoch // -1 if deal never slashed + SectorNumber abi.SectorNumber // 0 if not yet included in proven sector (0 is also a valid sector number). + SectorStartEpoch abi.ChainEpoch // -1 if not yet included in proven sector + LastUpdatedEpoch abi.ChainEpoch // -1 if deal state never updated + SlashEpoch abi.ChainEpoch // -1 if deal never slashed } func MakeDealState(mds market.DealState) MarketDealState { return MarketDealState{ + SectorNumber: mds.SectorNumber(), SectorStartEpoch: mds.SectorStartEpoch(), LastUpdatedEpoch: mds.LastUpdatedEpoch(), SlashEpoch: mds.SlashEpoch(), @@ -1183,6 +1185,10 @@ type mstate struct { s MarketDealState } +func (m mstate) SectorNumber() abi.SectorNumber { + return m.s.SectorNumber +} + func (m mstate) SectorStartEpoch() abi.ChainEpoch { return m.s.SectorStartEpoch } diff --git a/build/openrpc/full.json b/build/openrpc/full.json index ff04e6069..8895cfa8c 100644 --- a/build/openrpc/full.json +++ b/build/openrpc/full.json @@ -21611,6 +21611,7 @@ "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -21678,6 +21679,10 @@ "title": "number", "type": "number" }, + "SectorNumber": { + "title": "number", + "type": "number" + }, "SectorStartEpoch": { "title": "number", "type": "number" @@ -21848,6 +21853,7 @@ "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -21912,6 +21918,10 @@ "title": "number", "type": "number" }, + "SectorNumber": { + "title": "number", + "type": "number" + }, "SectorStartEpoch": { "title": "number", "type": "number" diff --git a/build/openrpc/gateway.json b/build/openrpc/gateway.json index bb6abab0a..6978bb140 100644 --- a/build/openrpc/gateway.json +++ b/build/openrpc/gateway.json @@ -8179,6 +8179,7 @@ "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -8243,6 +8244,10 @@ "title": "number", "type": "number" }, + "SectorNumber": { + "title": "number", + "type": "number" + }, "SectorStartEpoch": { "title": "number", "type": "number" diff --git a/build/openrpc/miner.json b/build/openrpc/miner.json index 9bc2dcf88..5e6ac618f 100644 --- a/build/openrpc/miner.json +++ b/build/openrpc/miner.json @@ -1327,6 +1327,7 @@ "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -1394,6 +1395,10 @@ "title": "number", "type": "number" }, + "SectorNumber": { + "title": "number", + "type": "number" + }, "SectorStartEpoch": { "title": "number", "type": "number" @@ -2649,6 +2654,7 @@ "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -2716,6 +2722,10 @@ "title": "number", "type": "number" }, + "SectorNumber": { + "title": "number", + "type": "number" + }, "SectorStartEpoch": { "title": "number", "type": "number" diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index 0604737b3..f913cb0ab 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -143,6 +143,7 @@ type DealProposal = markettypes.DealProposal type DealLabel = markettypes.DealLabel type DealState interface { + SectorNumber() abi.SectorNumber // 0 if not yet included in proven sector (0 is also a valid sector number) SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated SlashEpoch() abi.ChainEpoch // -1 if deal never slashed @@ -185,6 +186,10 @@ type ProposalIDState struct { type emptyDealState struct{} +func (e *emptyDealState) SectorNumber() abi.SectorNumber { + return 0 +} + func (e *emptyDealState) SectorStartEpoch() abi.ChainEpoch { return -1 } diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 5d760dca2..c32bf3667 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -252,6 +252,7 @@ type DealProposal = markettypes.DealProposal type DealLabel = markettypes.DealLabel type DealState interface { + SectorNumber() abi.SectorNumber // 0 if not yet included in proven sector (0 is also a valid sector number) SectorStartEpoch() abi.ChainEpoch // -1 if not yet included in proven sector LastUpdatedEpoch() abi.ChainEpoch // -1 if deal state never updated SlashEpoch() abi.ChainEpoch // -1 if deal never slashed @@ -293,6 +294,10 @@ type ProposalIDState struct { type emptyDealState struct{} +func (e *emptyDealState) SectorNumber() abi.SectorNumber { + return 0 +} + func (e *emptyDealState) SectorStartEpoch() abi.ChainEpoch { return -1 } diff --git a/chain/actors/builtin/market/state.go.template b/chain/actors/builtin/market/state.go.template index 467057660..19f2c17ab 100644 --- a/chain/actors/builtin/market/state.go.template +++ b/chain/actors/builtin/market/state.go.template @@ -212,6 +212,14 @@ type dealStateV{{.v}} struct { ds{{.v}} market{{.v}}.DealState } +func (d dealStateV{{.v}}) SectorNumber() abi.SectorNumber { +{{if (le .v 12)}} + return 0 +{{else}} + return d.ds{{.v}}.SectorNumber +{{end}} +} + func (d dealStateV{{.v}}) SectorStartEpoch() abi.ChainEpoch { return d.ds{{.v}}.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v0.go b/chain/actors/builtin/market/v0.go index d797d53f8..cd207ac2c 100644 --- a/chain/actors/builtin/market/v0.go +++ b/chain/actors/builtin/market/v0.go @@ -191,6 +191,12 @@ type dealStateV0 struct { ds0 market0.DealState } +func (d dealStateV0) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV0) SectorStartEpoch() abi.ChainEpoch { return d.ds0.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v10.go b/chain/actors/builtin/market/v10.go index 290c17d09..9d6e97989 100644 --- a/chain/actors/builtin/market/v10.go +++ b/chain/actors/builtin/market/v10.go @@ -190,6 +190,12 @@ type dealStateV10 struct { ds10 market10.DealState } +func (d dealStateV10) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV10) SectorStartEpoch() abi.ChainEpoch { return d.ds10.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v11.go b/chain/actors/builtin/market/v11.go index 56a4c6038..69620f558 100644 --- a/chain/actors/builtin/market/v11.go +++ b/chain/actors/builtin/market/v11.go @@ -190,6 +190,12 @@ type dealStateV11 struct { ds11 market11.DealState } +func (d dealStateV11) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV11) SectorStartEpoch() abi.ChainEpoch { return d.ds11.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v12.go b/chain/actors/builtin/market/v12.go index cf7687203..7ae777605 100644 --- a/chain/actors/builtin/market/v12.go +++ b/chain/actors/builtin/market/v12.go @@ -190,6 +190,12 @@ type dealStateV12 struct { ds12 market12.DealState } +func (d dealStateV12) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV12) SectorStartEpoch() abi.ChainEpoch { return d.ds12.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v13.go b/chain/actors/builtin/market/v13.go index d270319ce..6a5f58778 100644 --- a/chain/actors/builtin/market/v13.go +++ b/chain/actors/builtin/market/v13.go @@ -190,6 +190,12 @@ type dealStateV13 struct { ds13 market13.DealState } +func (d dealStateV13) SectorNumber() abi.SectorNumber { + + return d.ds13.SectorNumber + +} + func (d dealStateV13) SectorStartEpoch() abi.ChainEpoch { return d.ds13.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v14.go b/chain/actors/builtin/market/v14.go index b6bc570b7..0eea2375f 100644 --- a/chain/actors/builtin/market/v14.go +++ b/chain/actors/builtin/market/v14.go @@ -190,6 +190,12 @@ type dealStateV14 struct { ds14 market14.DealState } +func (d dealStateV14) SectorNumber() abi.SectorNumber { + + return d.ds14.SectorNumber + +} + func (d dealStateV14) SectorStartEpoch() abi.ChainEpoch { return d.ds14.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v2.go b/chain/actors/builtin/market/v2.go index 5ced3c8a3..3c1f376ec 100644 --- a/chain/actors/builtin/market/v2.go +++ b/chain/actors/builtin/market/v2.go @@ -191,6 +191,12 @@ type dealStateV2 struct { ds2 market2.DealState } +func (d dealStateV2) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV2) SectorStartEpoch() abi.ChainEpoch { return d.ds2.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v3.go b/chain/actors/builtin/market/v3.go index 35dd9c29a..7e8d60fea 100644 --- a/chain/actors/builtin/market/v3.go +++ b/chain/actors/builtin/market/v3.go @@ -186,6 +186,12 @@ type dealStateV3 struct { ds3 market3.DealState } +func (d dealStateV3) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV3) SectorStartEpoch() abi.ChainEpoch { return d.ds3.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v4.go b/chain/actors/builtin/market/v4.go index bc9e61c88..08beaf515 100644 --- a/chain/actors/builtin/market/v4.go +++ b/chain/actors/builtin/market/v4.go @@ -186,6 +186,12 @@ type dealStateV4 struct { ds4 market4.DealState } +func (d dealStateV4) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV4) SectorStartEpoch() abi.ChainEpoch { return d.ds4.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v5.go b/chain/actors/builtin/market/v5.go index 63743ba8d..93a05355d 100644 --- a/chain/actors/builtin/market/v5.go +++ b/chain/actors/builtin/market/v5.go @@ -186,6 +186,12 @@ type dealStateV5 struct { ds5 market5.DealState } +func (d dealStateV5) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV5) SectorStartEpoch() abi.ChainEpoch { return d.ds5.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v6.go b/chain/actors/builtin/market/v6.go index 5900eace9..ec9157318 100644 --- a/chain/actors/builtin/market/v6.go +++ b/chain/actors/builtin/market/v6.go @@ -188,6 +188,12 @@ type dealStateV6 struct { ds6 market6.DealState } +func (d dealStateV6) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV6) SectorStartEpoch() abi.ChainEpoch { return d.ds6.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v7.go b/chain/actors/builtin/market/v7.go index f51f070c7..5e49fb5da 100644 --- a/chain/actors/builtin/market/v7.go +++ b/chain/actors/builtin/market/v7.go @@ -188,6 +188,12 @@ type dealStateV7 struct { ds7 market7.DealState } +func (d dealStateV7) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV7) SectorStartEpoch() abi.ChainEpoch { return d.ds7.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v8.go b/chain/actors/builtin/market/v8.go index f9bf25f9c..0ea4bf84b 100644 --- a/chain/actors/builtin/market/v8.go +++ b/chain/actors/builtin/market/v8.go @@ -189,6 +189,12 @@ type dealStateV8 struct { ds8 market8.DealState } +func (d dealStateV8) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV8) SectorStartEpoch() abi.ChainEpoch { return d.ds8.SectorStartEpoch } diff --git a/chain/actors/builtin/market/v9.go b/chain/actors/builtin/market/v9.go index 3b5be4dfa..7805efca2 100644 --- a/chain/actors/builtin/market/v9.go +++ b/chain/actors/builtin/market/v9.go @@ -190,6 +190,12 @@ type dealStateV9 struct { ds9 market9.DealState } +func (d dealStateV9) SectorNumber() abi.SectorNumber { + + return 0 + +} + func (d dealStateV9) SectorStartEpoch() abi.ChainEpoch { return d.ds9.SectorStartEpoch } diff --git a/documentation/en/api-v0-methods-miner.md b/documentation/en/api-v0-methods-miner.md index 65cf301d4..263585b71 100644 --- a/documentation/en/api-v0-methods-miner.md +++ b/documentation/en/api-v0-methods-miner.md @@ -824,6 +824,7 @@ Response: "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -1423,6 +1424,7 @@ Response: "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 diff --git a/documentation/en/api-v0-methods.md b/documentation/en/api-v0-methods.md index 097722d3f..a3fe23f30 100644 --- a/documentation/en/api-v0-methods.md +++ b/documentation/en/api-v0-methods.md @@ -5841,6 +5841,7 @@ Response: "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -5919,6 +5920,7 @@ Response: "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 diff --git a/documentation/en/api-v1-unstable-methods.md b/documentation/en/api-v1-unstable-methods.md index 244b29953..8048bb2cb 100644 --- a/documentation/en/api-v1-unstable-methods.md +++ b/documentation/en/api-v1-unstable-methods.md @@ -7529,6 +7529,7 @@ Response: "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101 @@ -7607,6 +7608,7 @@ Response: "ClientCollateral": "0" }, "State": { + "SectorNumber": 9, "SectorStartEpoch": 10101, "LastUpdatedEpoch": 10101, "SlashEpoch": 10101