Skip to content

Commit 375bd51

Browse files
Feature/update actor v7 (#570)
* actors v7 * network heights const * add actor_version for cbor streams Signed-off-by: Alexey-N-Chernyshov <[email protected]>
1 parent 868797d commit 375bd51

File tree

137 files changed

+1209
-1127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+1209
-1127
lines changed

core/api/full_node/make.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,9 @@ namespace fc::api {
776776
OUTCOME_TRY(deadline->partitions.visit(
777777
[&](auto, const auto &part) -> outcome::result<void> {
778778
for (const auto &id : part->activeSectors()) {
779-
OUTCOME_TRYA(sectors.emplace_back(),
780-
state->sectors.sectors.get(id));
779+
OUTCOME_TRY(universal_sector_info,
780+
state->sectors.sectors.get(id));
781+
sectors.emplace_back(*universal_sector_info);
781782
}
782783
return outcome::success();
783784
}));
@@ -889,7 +890,7 @@ namespace fc::api {
889890
std::vector<SectorOnChainInfo> sectors;
890891
OUTCOME_TRY(state->sectors.sectors.visit([&](auto id, auto &info) {
891892
if (!filter || filter->count(id)) {
892-
sectors.push_back(info);
893+
sectors.push_back(*info);
893894
}
894895
return outcome::success();
895896
}));
@@ -990,7 +991,12 @@ namespace fc::api {
990991
-> outcome::result<boost::optional<SectorOnChainInfo>> {
991992
OUTCOME_TRY(context, tipsetContext(tipset_key, false));
992993
OUTCOME_TRY(state, context.minerState(address));
993-
return state->sectors.sectors.tryGet(sector_number);
994+
OUTCOME_TRY(maybe_universal_sector_info,
995+
state->sectors.sectors.tryGet(sector_number));
996+
if (maybe_universal_sector_info) {
997+
return *maybe_universal_sector_info.get();
998+
}
999+
return boost::none;
9941000
};
9951001
api->StateSectorExpiration = [=](auto &address, auto sector, auto &tsk)
9961002
-> outcome::result<SectorExpiration> {
@@ -1084,7 +1090,7 @@ namespace fc::api {
10841090
};
10851091
api->Version = []() {
10861092
return VersionResult{
1087-
kNodeVersion, makeApiVersion(2, 1, 0), kEpochDurationSeconds};
1093+
kNodeVersion, makeApiVersion(2, 2, 0), kEpochDurationSeconds};
10881094
};
10891095
return api;
10901096
}

core/api/full_node/node_api.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace fc::api {
6060
using primitives::piece::PaddedPieceSize;
6161
using primitives::sector::RegisteredPoStProof;
6262
using primitives::sector::RegisteredSealProof;
63-
using primitives::sector::SectorInfo;
63+
using primitives::sector::ExtendedSectorInfo;
6464
using primitives::tipset::HeadChange;
6565
using primitives::tipset::TipsetCPtr;
6666
using primitives::tipset::TipsetKey;
@@ -239,7 +239,7 @@ namespace fc::api {
239239
struct MiningBaseInfo {
240240
StoragePower miner_power;
241241
StoragePower network_power;
242-
std::vector<SectorInfo> sectors;
242+
std::vector<ExtendedSectorInfo> sectors;
243243
Address worker;
244244
SectorSize sector_size{};
245245
BeaconEntry prev_beacon;

core/api/full_node/node_api_v1_wrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace fc::api {
1515
auto api = std::make_shared<FullNodeApiV1Wrapper>();
1616
api->Version = []() {
1717
return VersionResult{
18-
kNodeVersion, makeApiVersion(1, 4, 0), kEpochDurationSeconds};
18+
kNodeVersion, makeApiVersion(1, 5, 0), kEpochDurationSeconds};
1919
};
2020
return api;
2121
}

core/api/rpc/json.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,16 +1082,18 @@ namespace fc::api {
10821082
decode(v.message, Get(j, "Message"));
10831083
}
10841084

1085-
ENCODE(SectorInfo) {
1085+
ENCODE(ExtendedSectorInfo) {
10861086
Value j{rapidjson::kObjectType};
10871087
Set(j, "SealProof", v.registered_proof);
1088+
Set(j, "SectorKey", v.sector_key);
10881089
Set(j, "SectorNumber", v.sector);
10891090
Set(j, "SealedCID", v.sealed_cid);
10901091
return j;
10911092
}
10921093

1093-
DECODE(SectorInfo) {
1094+
DECODE(ExtendedSectorInfo) {
10941095
Get(j, "SealProof", v.registered_proof);
1096+
Get(j, "SectorKey", v.sector_key);
10951097
Get(j, "SectorNumber", v.sector);
10961098
Get(j, "SealedCID", v.sealed_cid);
10971099
}

core/blockchain/block_validator/validator.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
namespace fc::blockchain::block_validator {
3030
using primitives::Nonce;
3131
using primitives::block::MsgMeta;
32+
using primitives::sector::SectorInfo;
33+
using primitives::sector::toSectorInfo;
3234
using vm::actor::kStoragePowerAddress;
3335
using vm::actor::builtin::states::MinerActorStatePtr;
3436
using vm::actor::builtin::states::PowerActorStatePtr;
@@ -177,11 +179,18 @@ namespace fc::blockchain::block_validator {
177179
return ERROR_TEXT("validate: wrong fake win_post_proof");
178180
}
179181
} else {
180-
OUTCOME_TRY(sectors,
182+
OUTCOME_TRY(extended_sectors,
181183
getSectorsForWinningPoSt(getNetworkVersion(parent->height()),
182184
block.miner,
183185
lookback_miner,
184186
rand.win));
187+
188+
std::vector<SectorInfo> sectors;
189+
sectors.reserve(extended_sectors.size());
190+
for (const auto &sector : extended_sectors) {
191+
sectors.emplace_back(primitives::sector::toSectorInfo(sector));
192+
}
193+
185194
static proofs::ProofEngineImpl proofs;
186195
OUTCOME_TRY(win_verified,
187196
proofs.verifyWinningPoSt({

core/blockchain/block_validator/win_sectors.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ namespace fc::blockchain::block_validator {
1212
using crypto::randomness::Randomness;
1313
using primitives::RleBitset;
1414
using primitives::address::Address;
15-
using primitives::sector::SectorInfo;
15+
using primitives::sector::ExtendedSectorInfo;
1616
using vm::actor::builtin::states::MinerActorStatePtr;
1717
using vm::version::NetworkVersion;
1818

19+
inline outcome::result<std::vector<ExtendedSectorInfo>>
1920
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
20-
inline outcome::result<std::vector<SectorInfo>> getSectorsForWinningPoSt(
21-
NetworkVersion network,
22-
const Address &miner,
23-
const MinerActorStatePtr &state,
24-
const Randomness &rand) {
25-
std::vector<SectorInfo> sectors;
21+
getSectorsForWinningPoSt(NetworkVersion network,
22+
const Address &miner,
23+
const MinerActorStatePtr &state,
24+
const Randomness &rand) {
25+
std::vector<ExtendedSectorInfo> sectors;
2626
RleBitset sectors_bitset;
2727
OUTCOME_TRY(deadlines, state->deadlines.get());
2828
for (const auto &deadline_cid : deadlines.due) {
@@ -55,9 +55,10 @@ namespace fc::blockchain::block_validator {
5555
for (const auto &i : indices) {
5656
OUTCOME_TRY(sector, state->sectors.sectors.get(sector_ids[i]));
5757
sectors.push_back({
58-
sector.seal_proof,
59-
sector.sector,
60-
sector.sealed_cid,
58+
sector->seal_proof,
59+
sector->sector,
60+
sector->sector_key_cid,
61+
sector->sealed_cid,
6162
});
6263
}
6364
}

core/codec/cbor/cbor_decode_stream.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace fc::codec::cbor {
7979
listLength();
8080
CborDecodeStream stream{readNested()};
8181
stream.readToken();
82+
stream.actor_version = actor_version;
8283
return stream;
8384
}
8485

@@ -89,7 +90,9 @@ namespace fc::codec::cbor {
8990
std::string key;
9091
for (size_t i{}; i < n; ++i) {
9192
*this >> key;
92-
map.emplace(key, CborDecodeStream{readNested()});
93+
CborDecodeStream stream{readNested()};
94+
stream.actor_version = actor_version;
95+
map.emplace(key, stream);
9396
}
9497
return map;
9598
}

core/const.cpp

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,35 @@ namespace fc {
3232
DEFINE(kUpgradeSmokeHeight){51000};
3333
DEFINE(kUpgradeIgnitionHeight){94000};
3434
DEFINE(kUpgradeRefuelHeight){130800};
35-
DEFINE(kUpgradeActorsV2Height){138720};
35+
DEFINE(kUpgradeAssemblyHeight){138720};
3636
DEFINE(kUpgradeTapeHeight){140760};
3737
DEFINE(kUpgradeLiftoffHeight){148888};
3838
DEFINE(kUpgradeKumquatHeight){170000};
3939
DEFINE(kUpgradeCalicoHeight){265200};
4040
DEFINE(kUpgradePersianHeight){272400};
4141
DEFINE(kUpgradeOrangeHeight){336458};
42+
// 2020-12-22T02:00:00Z
4243
DEFINE(kUpgradeClausHeight){343200};
43-
DEFINE(kUpgradeActorsV3Height){550321};
44+
// 2021-03-04T00:00:30Z
45+
DEFINE(kUpgradeTrustHeight){550321};
46+
// 2021-04-12T22:00:00Z
4447
DEFINE(kUpgradeNorwegianHeight){665280};
45-
DEFINE(kUpgradeActorsV4Height){712320};
48+
// 2021-04-29T06:00:00Z
49+
DEFINE(kUpgradeTurboHeight){712320};
50+
// 2021-06-30T22:00:00Z
4651
DEFINE(kUpgradeHyperdriveHeight){892800};
52+
// 2021-10-26T13:30:00Z
4753
DEFINE(kUpgradeChocolateHeight){1231620};
54+
// Not applied yet
55+
DEFINE(kUpgradeOhSnapHeight){INT64_MAX};
4856

4957
DEFINE(kBreezeGasTampingDuration){120};
5058

5159
DEFINE(kInteractivePoRepConfidence){6};
5260
} // namespace fc
5361

5462
namespace fc::vm::actor::builtin::types::market {
55-
DEFINE(kDealUpdatesInterval) = kEpochsInDay;
63+
DEFINE(kDealUpdatesInterval) = static_cast<EpochDuration>(kEpochsInDay);
5664
}
5765

5866
namespace fc::vm::actor::builtin::types::miner {
@@ -97,18 +105,20 @@ namespace fc {
97105
kUpgradeIgnitionHeight = -2;
98106
kUpgradeRefuelHeight = -3;
99107
kUpgradeTapeHeight = -4;
100-
kUpgradeActorsV2Height = -5;
108+
kUpgradeAssemblyHeight = -5;
101109
kUpgradeLiftoffHeight = -6;
102110
kUpgradeKumquatHeight = -7;
103-
kUpgradeCalicoHeight = -8;
104-
kUpgradePersianHeight = -9;
105-
kUpgradeOrangeHeight = -10;
106-
kUpgradeClausHeight = -11;
107-
kUpgradeActorsV3Height = -12;
108-
kUpgradeNorwegianHeight = -13;
109-
kUpgradeActorsV4Height = -14;
110-
kUpgradeHyperdriveHeight = -15;
111+
// order according to lotus build/params_2k.go
112+
kUpgradeCalicoHeight = -9;
113+
kUpgradePersianHeight = -10;
114+
kUpgradeOrangeHeight = -11;
115+
kUpgradeClausHeight = -12;
116+
kUpgradeTrustHeight = -13;
117+
kUpgradeNorwegianHeight = -14;
118+
kUpgradeTurboHeight = -15;
119+
kUpgradeHyperdriveHeight = -16;
111120
kUpgradeChocolateHeight = -17;
121+
kUpgradeOhSnapHeight = -18;
112122

113123
kBreezeGasTampingDuration = 0;
114124

@@ -146,22 +156,23 @@ namespace fc {
146156
kPropagationDelaySecs = 1;
147157

148158
// Network versions
149-
kUpgradeBreezeHeight = 100000000;
150-
kUpgradeSmokeHeight = 100000000;
151-
kUpgradeIgnitionHeight = 100000000;
152-
kUpgradeRefuelHeight = 100000000;
153-
kUpgradeTapeHeight = 100000000;
154-
kUpgradeActorsV2Height = 100000000;
155-
kUpgradeLiftoffHeight = 100000000;
156-
kUpgradeKumquatHeight = 100000000;
157-
kUpgradeCalicoHeight = 100000000;
158-
kUpgradePersianHeight = 100000000;
159-
kUpgradeOrangeHeight = 100000000;
160-
kUpgradeClausHeight = 100000000;
161-
kUpgradeActorsV3Height = 100000000;
162-
kUpgradeNorwegianHeight = 100000000;
163-
kUpgradeActorsV4Height = 100000000;
164-
kUpgradeChocolateHeight = 100000000;
159+
kUpgradeBreezeHeight = INT64_MAX;
160+
kUpgradeSmokeHeight = INT64_MAX;
161+
kUpgradeIgnitionHeight = INT64_MAX;
162+
kUpgradeRefuelHeight = INT64_MAX;
163+
kUpgradeTapeHeight = INT64_MAX;
164+
kUpgradeAssemblyHeight = INT64_MAX;
165+
kUpgradeLiftoffHeight = INT64_MAX;
166+
kUpgradeKumquatHeight = INT64_MAX;
167+
kUpgradeCalicoHeight = INT64_MAX;
168+
kUpgradePersianHeight = INT64_MAX;
169+
kUpgradeOrangeHeight = INT64_MAX;
170+
kUpgradeClausHeight = INT64_MAX;
171+
kUpgradeTrustHeight = INT64_MAX;
172+
kUpgradeNorwegianHeight = INT64_MAX;
173+
kUpgradeTurboHeight = INT64_MAX;
174+
kUpgradeChocolateHeight = INT64_MAX;
175+
kUpgradeOhSnapHeight = INT64_MAX;
165176

166177
kBreezeGasTampingDuration = 0;
167178

@@ -193,18 +204,20 @@ namespace fc {
193204
kUpgradeIgnitionHeight = -2;
194205
kUpgradeRefuelHeight = -3;
195206
kUpgradeTapeHeight = -4;
196-
kUpgradeActorsV2Height = -5;
207+
kUpgradeAssemblyHeight = -5;
197208
kUpgradeLiftoffHeight = -6;
198209
kUpgradeKumquatHeight = -7;
199-
kUpgradeCalicoHeight = -8;
200-
kUpgradePersianHeight = -9;
201-
kUpgradeOrangeHeight = -10;
202-
kUpgradeClausHeight = -11;
203-
kUpgradeActorsV3Height = -12;
204-
kUpgradeNorwegianHeight = -13;
205-
kUpgradeActorsV4Height = -14;
206-
kUpgradeHyperdriveHeight = -15;
207-
kUpgradeChocolateHeight = INT64_MAX;
210+
// order according to lotus build/params_interop.go
211+
kUpgradeCalicoHeight = -9;
212+
kUpgradePersianHeight = -10;
213+
kUpgradeOrangeHeight = -11;
214+
kUpgradeClausHeight = -12;
215+
kUpgradeTrustHeight = -13;
216+
kUpgradeNorwegianHeight = -14;
217+
kUpgradeTurboHeight = -15;
218+
kUpgradeHyperdriveHeight = -16;
219+
kUpgradeChocolateHeight = INT64_MAX; // -17 in lotus
220+
kUpgradeOhSnapHeight = INT64_MAX; // -18 in lotus
208221

209222
kBreezeGasTampingDuration = 0;
210223

core/const.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ namespace fc {
6262
extern ChainEpoch kUpgradeIgnitionHeight;
6363
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
6464
extern ChainEpoch kUpgradeRefuelHeight;
65+
/** Actors V2 update */
6566
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
66-
extern ChainEpoch kUpgradeActorsV2Height;
67+
extern ChainEpoch kUpgradeAssemblyHeight;
6768
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
6869
extern ChainEpoch kUpgradeTapeHeight;
6970
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
@@ -78,16 +79,21 @@ namespace fc {
7879
extern ChainEpoch kUpgradeOrangeHeight;
7980
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8081
extern ChainEpoch kUpgradeClausHeight;
82+
/** Actors V3 upgrade */
8183
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
82-
extern ChainEpoch kUpgradeActorsV3Height;
84+
extern ChainEpoch kUpgradeTrustHeight;
8385
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8486
extern ChainEpoch kUpgradeNorwegianHeight;
87+
/** Actors V4 upgrade */
8588
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
86-
extern ChainEpoch kUpgradeActorsV4Height;
89+
extern ChainEpoch kUpgradeTurboHeight;
8790
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8891
extern ChainEpoch kUpgradeHyperdriveHeight;
8992
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
9093
extern ChainEpoch kUpgradeChocolateHeight;
94+
/** Actors V7 and Snap deals */
95+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
96+
extern ChainEpoch kUpgradeOhSnapHeight;
9197

9298
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
9399
extern EpochDuration kBreezeGasTampingDuration;
@@ -109,5 +115,9 @@ namespace fc {
109115
*/
110116
void setParamsNoUpgrades();
111117

118+
/**
119+
* Sets upgrades heights and parameters for Interopnet.
120+
* Identical to Lotus `build interopnet`
121+
*/
112122
void setParamsInteropnet();
113123
} // namespace fc

core/miner/storage_fsm/impl/checks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace fc::mining::checks {
5353
return kMaxProveCommitDuration;
5454
case ActorVersion::kVersion5:
5555
case ActorVersion::kVersion6:
56+
case ActorVersion::kVersion7:
5657
return sector_info->sector_type
5758
>= api::RegisteredSealProof::kStackedDrg2KiBV1_1
5859
? 30 * kEpochsInDay + kPreCommitChallengeDelay

0 commit comments

Comments
 (0)