Skip to content

Commit 4887629

Browse files
authored
fix circulating (#617)
Signed-off-by: turuslan <[email protected]>
1 parent be79e14 commit 4887629

File tree

14 files changed

+44
-71
lines changed

14 files changed

+44
-71
lines changed

core/api/full_node/make.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ namespace fc::api {
588588
if (!message.gas_limit) {
589589
message.gas_limit = kBlockGasLimit;
590590
}
591-
auto env = std::make_shared<Env>(env_context, ts_branch, context.tipset);
591+
OUTCOME_TRY(env, Env::make(env_context, ts_branch, context.tipset));
592592
InvocResult result;
593593
result.message = message;
594594
OUTCOME_TRYA(result.receipt, env->applyImplicitMessage(message));

core/api/wallet/local_wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace fc::api {
7171
std::sort(addresses.begin(), addresses.end());
7272
auto last = std::unique(addresses.begin(), addresses.end());
7373
addresses.erase(last, addresses.end());
74-
return addresses;
74+
return std::move(addresses);
7575
};
7676
api->WalletSetDefault = [=](auto &address) -> outcome::result<void> {
7777
wallet_default_address->setCbor(address);

core/const.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ namespace fc {
5151
DEFINE(kUpgradeHyperdriveHeight){892800};
5252
// 2021-10-26T13:30:00Z
5353
DEFINE(kUpgradeChocolateHeight){1231620};
54-
// 2021-03-01T14:00:00Z
55-
DEFINE(kUpgradeOhSnapHeight){1594560};
54+
// 2022-03-01T15:00:00Z
55+
DEFINE(kUpgradeOhSnapHeight){1594680};
5656

5757
DEFINE(kBreezeGasTampingDuration){120};
5858

core/node/blocksync_request.cpp

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -347,33 +347,10 @@ namespace fc::sync::blocksync {
347347
done();
348348

349349
if (result_->error) {
350-
int64_t dr = 0;
351-
const auto &category =
352-
std::error_code(BlocksyncRequest::Error::kTimeout).category();
353-
if (result_->error.category() == category) {
354-
switch (result_->error.value()) {
355-
case int(BlocksyncRequest::Error::kStoreCidsMismatch):
356-
dr = -700;
357-
break;
358-
case int(BlocksyncRequest::Error::kInconsistentResponse):
359-
dr = -500;
360-
break;
361-
case int(BlocksyncRequest::Error::kTimeout):
362-
dr = -200;
363-
break;
364-
default:
365-
break;
366-
}
367-
} else {
368-
// stream and other errors
369-
dr -= 200;
370-
}
371-
log()->debug("peer {}, error {}, dr={}",
350+
log()->debug("peer {}, error {}",
372351
(result_->from.has_value() ? result_->from->toBase58()
373352
: "unknown"),
374-
result_->error.message(),
375-
dr);
376-
result_->delta_rating += dr;
353+
result_->error.message());
377354
}
378355

379356
if (call_now) {
@@ -447,15 +424,9 @@ namespace fc::sync::blocksync {
447424
statusToString(response.status),
448425
response.message,
449426
response.chain.size());
450-
451-
if (response.status == ResponseStatus::kResponseComplete) {
452-
result_->delta_rating += 100;
453-
}
454427
if (response.chain.size() > 0) {
455-
result_->delta_rating += 50;
456428
storeChain(std::move(response.chain));
457429
} else {
458-
result_->delta_rating -= 50;
459430
result_->error = BlocksyncRequest::Error::kIncompleteResponse;
460431
}
461432
}
@@ -554,11 +525,6 @@ namespace fc::sync::blocksync {
554525
break;
555526
}
556527
}
557-
558-
if (!result_->blocks_available.empty()) {
559-
result_->delta_rating +=
560-
(result_->blocks_available.size() + result_->parents.size()) * 5;
561-
}
562528
}
563529

564530
libp2p::Host &host_;

core/node/blocksync_request.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ namespace fc::sync::blocksync {
3434
/// Not 0 if error occured
3535
std::error_code error;
3636

37-
/// Change rating for this peer
38-
int64_t delta_rating = 0;
39-
4037
/// Blocks which were requested
4138
std::vector<CbCid> blocks_requested;
4239

core/node/main/builder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ namespace fc::node {
364364
storage::LevelDB::create(config.join("ipld_leveldb")).value();
365365
o.ipld_leveldb =
366366
std::make_shared<storage::ipfs::LeveldbDatastore>(o.ipld_leveldb_kv);
367-
o.ipld = o.ipld_leveldb;
368367
o.ipld = *storage::cids_index::loadOrCreateWithProgress(
369368
config.genesisCar(), false, boost::none, o.ipld, log());
370369
auto snapshot_cids{loadSnapshot(config, o)};

core/node/sync_job.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ namespace fc::sync {
454454
ts = _ts.value();
455455
} else {
456456
peers_->onError(*r.from);
457-
r.delta_rating -= 500;
458457
}
459458

460459
if (ts) {

core/storage/mpool/mpool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ namespace fc::storage::mpool {
628628
std::shared_lock head_lock(head_mutex_);
629629
const auto height = head_->height();
630630
OUTCOME_TRY(interpeted, env_context.interpreter_cache->get(head_->key));
631-
auto env{std::make_shared<vm::runtime::Env>(env_context, ts_main, head_)};
631+
OUTCOME_TRY(env, vm::runtime::Env::make(env_context, ts_main, head_));
632632
head_lock.unlock();
633633
env->state_tree = std::make_shared<vm::state::StateTreeImpl>(
634634
env->ipld, interpeted.state_root);

core/vm/interpreter/impl/interpreter_impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ namespace fc::vm::interpreter {
146146
return InterpreterError::kDuplicateMiner;
147147
}
148148

149-
auto env = std::make_shared<Env>(env_context_, ts_branch, tipset);
149+
OUTCOME_TRY(env, Env::make(env_context_, ts_branch, tipset));
150150

151151
auto cron{[&]() -> outcome::result<void> {
152152
OUTCOME_TRY(receipt,
@@ -171,10 +171,10 @@ namespace fc::vm::interpreter {
171171
OUTCOME_TRY(parent, env_context_.ts_load->load(tipset->getParents()));
172172
for (auto epoch{parent->height() + 1}; epoch < tipset->height();
173173
++epoch) {
174-
env->setHeight(epoch);
174+
OUTCOME_TRY(env->setHeight(epoch));
175175
OUTCOME_TRY(cron());
176176
}
177-
env->setHeight(tipset->height());
177+
OUTCOME_TRY(env->setHeight(tipset->height()));
178178
}
179179

180180
nextStep(&metricMessages);

core/vm/runtime/env.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ namespace fc::vm::runtime {
3737

3838
/// Environment contains objects that are shared by runtime contexts
3939
struct Env : std::enable_shared_from_this<Env> {
40-
Env(const EnvironmentContext &env_context,
40+
static outcome::result<std::shared_ptr<Env>> make(
41+
const EnvironmentContext &env_context,
4142
TsBranchPtr ts_branch,
4243
TipsetCPtr tipset);
4344

@@ -47,7 +48,7 @@ namespace fc::vm::runtime {
4748
TokenAmount reward;
4849
};
4950

50-
void setHeight(ChainEpoch height);
51+
outcome::result<void> setHeight(ChainEpoch height);
5152

5253
outcome::result<Apply> applyMessage(const UnsignedMessage &message,
5354
size_t size);
@@ -61,7 +62,8 @@ namespace fc::vm::runtime {
6162
ChainEpoch epoch; // mutable epoch for cron()
6263
TsBranchPtr ts_branch;
6364
TipsetCPtr tipset;
64-
Pricelist pricelist;
65+
Pricelist pricelist{0};
66+
TokenAmount base_circulating;
6567
};
6668

6769
struct Execution : std::enable_shared_from_this<Execution> {

0 commit comments

Comments
 (0)