From 99d97ee1f0ec0136d6a6818931bfe6049c287a85 Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 14:38:04 -0700 Subject: [PATCH 1/7] Visual Studio project fixes Project didn't compile anymore --- Builds/VisualStudio/stellar-core.vcxproj | 7 +++++-- .../VisualStudio/stellar-core.vcxproj.filters | 21 +++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Builds/VisualStudio/stellar-core.vcxproj b/Builds/VisualStudio/stellar-core.vcxproj index befa464489..73e62b49c4 100644 --- a/Builds/VisualStudio/stellar-core.vcxproj +++ b/Builds/VisualStudio/stellar-core.vcxproj @@ -89,6 +89,7 @@ false ProgramDatabase + /bigobj %(AdditionalOptions) true @@ -145,6 +146,7 @@ exit /b 0 false ProgramDatabase + /bigobj %(AdditionalOptions) true @@ -201,6 +203,7 @@ exit /b 0 true 4060;4100;4127;4324;4408;4510;4512;4582;4583;4592 false + /bigobj %(AdditionalOptions) true @@ -602,7 +605,7 @@ exit /b 0 - + @@ -928,4 +931,4 @@ exit /b 0 - + \ No newline at end of file diff --git a/Builds/VisualStudio/stellar-core.vcxproj.filters b/Builds/VisualStudio/stellar-core.vcxproj.filters index 0250d563d8..ada0b6dbeb 100644 --- a/Builds/VisualStudio/stellar-core.vcxproj.filters +++ b/Builds/VisualStudio/stellar-core.vcxproj.filters @@ -822,9 +822,6 @@ invariant - - invariant - invariant\tests @@ -837,9 +834,6 @@ invariant\tests - - invariant\tests - database\tests @@ -870,6 +864,15 @@ overlay\tests + + invariant\tests + + + invariant + + + ledger\tests + @@ -1478,9 +1481,6 @@ invariant - - invariant - main @@ -1499,6 +1499,9 @@ overlay + + invariant + From 5d9896bdb7f6322187c1106a19cf63c7b79149f9 Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 14:39:01 -0700 Subject: [PATCH 2/7] warning police: unused variables --- src/transactions/OfferTests.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/transactions/OfferTests.cpp b/src/transactions/OfferTests.cpp index ab8a4c7ae7..20fe273571 100644 --- a/src/transactions/OfferTests.cpp +++ b/src/transactions/OfferTests.cpp @@ -1759,9 +1759,6 @@ TEST_CASE("create offer", "[tx][offers]") }); // Test when existing offers - auto reserve = app->getLedgerManager() - .getCurrentLedgerHeader() - .baseReserve; root.pay(acc1, xlm, txfee); REQUIRE_THROWS_AS( market.addOffer(acc1, {usd, xlm, Price{1, 1}, 501}), @@ -2590,9 +2587,6 @@ TEST_CASE("create offer", "[tx][offers]") { SECTION("selling native") { - auto reserve = app->getLedgerManager() - .getCurrentLedgerHeader() - .baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(2); auto acc1 = root.create("acc1", minBalance + 3 * txfee + 499); @@ -2626,9 +2620,6 @@ TEST_CASE("create offer", "[tx][offers]") SECTION("buying native") { - auto reserve = app->getLedgerManager() - .getCurrentLedgerHeader() - .baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(4); auto acc1 = root.create("acc1", minBalance + 5 * txfee); @@ -2671,9 +2662,6 @@ TEST_CASE("create offer", "[tx][offers]") SECTION("non-native") { - auto reserve = app->getLedgerManager() - .getCurrentLedgerHeader() - .baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(3); auto acc1 = root.create("acc1", minBalance + 4 * txfee); @@ -2713,8 +2701,6 @@ TEST_CASE("create offer", "[tx][offers]") { SECTION("issuer offers do not overflow selling liabilities") { - auto reserve = - app->getLedgerManager().getCurrentLedgerHeader().baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(3); auto acc1 = root.create("acc1", minBalance + 10000); auto cur1 = acc1.asset("CUR1"); @@ -2736,8 +2722,6 @@ TEST_CASE("create offer", "[tx][offers]") SECTION("issuer offers do not overflow buying liabilities") { - auto reserve = - app->getLedgerManager().getCurrentLedgerHeader().baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(3); auto acc1 = root.create("acc1", minBalance + 10000); auto cur1 = acc1.asset("CUR1"); @@ -2760,8 +2744,6 @@ TEST_CASE("create offer", "[tx][offers]") SECTION("issuer offers contribute buying liabilities to other assets") { - auto reserve = - app->getLedgerManager().getCurrentLedgerHeader().baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(3); auto acc1 = root.create("acc1", minBalance + 10000); auto cur1 = acc1.asset("CUR1"); @@ -2782,8 +2764,6 @@ TEST_CASE("create offer", "[tx][offers]") SECTION("issuer offers contribute selling liabilities to other assets") { - auto reserve = - app->getLedgerManager().getCurrentLedgerHeader().baseReserve; auto const minBalance = app->getLedgerManager().getMinBalance(3); auto acc1 = root.create("acc1", minBalance + 10000); auto cur1 = acc1.asset("CUR1"); From 7682c4342303ee693779a993bc4685b3871ddce8 Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 14:39:27 -0700 Subject: [PATCH 3/7] warning police: shadowed variable --- src/transactions/MergeTests.cpp | 1 - src/transactions/PaymentTests.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/transactions/MergeTests.cpp b/src/transactions/MergeTests.cpp index 07c64b13aa..0b83e67828 100644 --- a/src/transactions/MergeTests.cpp +++ b/src/transactions/MergeTests.cpp @@ -649,7 +649,6 @@ TEST_CASE("merge", "[tx][merge]") SECTION("destination with native buying liabilities") { auto& lm = app->getLedgerManager(); - auto txfee = lm.getTxFee(); auto minBal = lm.getMinBalance(1); auto acc1 = root.create("acc1", minBal + txfee); auto acc2 = root.create("acc2", minBal + txfee + 1); diff --git a/src/transactions/PaymentTests.cpp b/src/transactions/PaymentTests.cpp index 81ce7210fb..4fe1688f0c 100644 --- a/src/transactions/PaymentTests.cpp +++ b/src/transactions/PaymentTests.cpp @@ -130,7 +130,6 @@ TEST_CASE("payment", "[tx][payment]") auto const minBal0 = app->getLedgerManager().getMinBalance(0); auto const minBal3 = app->getLedgerManager().getMinBalance(3); - auto txfee = app->getLedgerManager().getTxFee(); auto const native = makeNativeAsset(); auto acc1 = root.create("acc1", minBal3 + 2 * txfee + 500); TestMarket market(*app); @@ -154,7 +153,6 @@ TEST_CASE("payment", "[tx][payment]") auto const minBal0 = app->getLedgerManager().getMinBalance(0); auto const minBal3 = app->getLedgerManager().getMinBalance(3); - auto txfee = app->getLedgerManager().getTxFee(); auto const native = makeNativeAsset(); auto acc1 = root.create("acc1", minBal3 + 2 * txfee + 500); TestMarket market(*app); From f2f9c4aeb49d672c5a72d7d60db6a23f8bf3a1f8 Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 14:39:45 -0700 Subject: [PATCH 4/7] warning police: size_t vs int --- src/ledger/LedgerManagerImpl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ledger/LedgerManagerImpl.cpp b/src/ledger/LedgerManagerImpl.cpp index 2c7b74447a..15260bb053 100644 --- a/src/ledger/LedgerManagerImpl.cpp +++ b/src/ledger/LedgerManagerImpl.cpp @@ -871,7 +871,8 @@ LedgerManagerImpl::closeLedger(LedgerCloseData const& ledgerData) // Note: Index from 1 rather than 0 to match the behavior of // storeTransaction and storeTransactionFee. Upgrades::storeUpgradeHistory(*this, lupgrade, - upgradeDelta.getChanges(), i + 1); + upgradeDelta.getChanges(), + static_cast(i + 1)); upgradeDelta.commit(); upgradeScope.commit(); } From 69e5ee11a22799fdde9c46b9d0b8153b977d3ec4 Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 14:40:42 -0700 Subject: [PATCH 5/7] warning police: int64_t vs uint32_t --- src/ledger/LiabilitiesTests.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/ledger/LiabilitiesTests.cpp b/src/ledger/LiabilitiesTests.cpp index 5cbbc35942..ede5f1e413 100644 --- a/src/ledger/LiabilitiesTests.cpp +++ b/src/ledger/LiabilitiesTests.cpp @@ -23,7 +23,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]") SECTION("add account selling liabilities") { auto addSellingLiabilities = - [&](int64_t initNumSubEntries, int64_t initBalance, + [&](uint32_t initNumSubEntries, int64_t initBalance, int64_t initSellingLiabilities, int64_t deltaLiabilities) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); ae.balance = initBalance; @@ -57,7 +57,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]") return res; }; auto addSellingLiabilitiesUninitialized = - [&](int64_t initNumSubEntries, int64_t initBalance, + [&](uint32_t initNumSubEntries, int64_t initBalance, int64_t deltaLiabilities) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); ae.balance = initBalance; @@ -75,7 +75,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]") if (res) { REQUIRE(af->getAccount().ext.v() == - (deltaLiabilities != 0)); + ((deltaLiabilities != 0) ? 1 : 0)); REQUIRE(af->getSellingLiabilities(lm) == deltaLiabilities); } else @@ -204,7 +204,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]") SECTION("add account buying liabilities") { - auto addBuyingLiabilities = [&](int64_t initNumSubEntries, + auto addBuyingLiabilities = [&](uint32_t initNumSubEntries, int64_t initBalance, int64_t initBuyingLiabilities, int64_t deltaLiabilities) { @@ -238,7 +238,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]") } return res; }; - auto addBuyingLiabilitiesUninitialized = [&](int64_t initNumSubEntries, + auto addBuyingLiabilitiesUninitialized = [&](uint32_t initNumSubEntries, int64_t initBalance, int64_t deltaLiabilities) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); @@ -390,11 +390,11 @@ TEST_CASE("liabilities", "[ledger][liabilities]") 0, lm.getMinBalance(0), INT64_MAX - lm.getMinBalance(0) - 1, 1)); - REQUIRE(!addBuyingLiabilities(INT64_MAX, INT64_MAX / 2 + 1, + REQUIRE(!addBuyingLiabilities(UINT32_MAX, INT64_MAX / 2 + 1, INT64_MAX / 2, 1)); - REQUIRE(!addBuyingLiabilities(INT64_MAX, INT64_MAX / 2, + REQUIRE(!addBuyingLiabilities(UINT32_MAX, INT64_MAX / 2, INT64_MAX / 2 + 1, 1)); - REQUIRE(addBuyingLiabilities(INT64_MAX, INT64_MAX / 2, + REQUIRE(addBuyingLiabilities(UINT32_MAX, INT64_MAX / 2, INT64_MAX / 2, 1)); } }); @@ -682,7 +682,7 @@ TEST_CASE("balance with liabilities", "[ledger][liabilities]") SECTION("account add balance") { - auto addBalance = [&](int64_t initNumSubEntries, int64_t initBalance, + auto addBalance = [&](uint32_t initNumSubEntries, int64_t initBalance, Liabilities initLiabilities, int64_t deltaBalance) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); @@ -779,9 +779,10 @@ TEST_CASE("balance with liabilities", "[ledger][liabilities]") SECTION("account add subentries") { - auto addSubEntries = [&](int64_t initNumSubEntries, int64_t initBalance, + auto addSubEntries = [&](uint32_t initNumSubEntries, + int64_t initBalance, int64_t initSellingLiabilities, - int64_t deltaNumSubEntries) { + int32_t deltaNumSubEntries) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); ae.balance = initBalance; ae.numSubEntries = initNumSubEntries; @@ -938,7 +939,7 @@ TEST_CASE("available balance and limit", "[ledger][liabilities]") SECTION("account available balance") { - auto checkAvailableBalance = [&](int64_t initNumSubEntries, + auto checkAvailableBalance = [&](uint32_t initNumSubEntries, int64_t initBalance, int64_t initSellingLiabilities) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); @@ -987,7 +988,7 @@ TEST_CASE("available balance and limit", "[ledger][liabilities]") SECTION("account available limit") { - auto checkAvailableLimit = [&](int64_t initNumSubEntries, + auto checkAvailableLimit = [&](uint32_t initNumSubEntries, int64_t initBalance, int64_t initBuyingLiabilities) { AccountEntry ae = LedgerTestUtils::generateValidAccountEntry(); From 7a6c0e894e4e1f2ea27a4b892c5ebf1bb129be5c Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 14:40:57 -0700 Subject: [PATCH 6/7] warning police: bool compared with int --- src/ledger/LiabilitiesTests.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ledger/LiabilitiesTests.cpp b/src/ledger/LiabilitiesTests.cpp index ede5f1e413..502803fef2 100644 --- a/src/ledger/LiabilitiesTests.cpp +++ b/src/ledger/LiabilitiesTests.cpp @@ -256,7 +256,8 @@ TEST_CASE("liabilities", "[ledger][liabilities]") REQUIRE(af->getSellingLiabilities(lm) == 0); if (res) { - REQUIRE(af->getAccount().ext.v() == (deltaLiabilities != 0)); + REQUIRE(af->getAccount().ext.v() == + ((deltaLiabilities != 0) ? 1 : 0)); REQUIRE(af->getBuyingLiabilities(lm) == deltaLiabilities); } else @@ -460,7 +461,7 @@ TEST_CASE("liabilities", "[ledger][liabilities]") if (res) { REQUIRE(tf->getTrustLine().ext.v() == - (deltaLiabilities != 0)); + ((deltaLiabilities != 0) ? 1 : 0)); REQUIRE(tf->getSellingLiabilities(lm) == deltaLiabilities); } else @@ -594,7 +595,8 @@ TEST_CASE("liabilities", "[ledger][liabilities]") REQUIRE(tf->getSellingLiabilities(lm) == 0); if (res) { - REQUIRE(tf->getTrustLine().ext.v() == (deltaLiabilities != 0)); + REQUIRE(tf->getTrustLine().ext.v() == + ((deltaLiabilities != 0) ? 1 : 0)); REQUIRE(tf->getBuyingLiabilities(lm) == deltaLiabilities); } else From d483a7e6143dea0914fd3025ddb785908dbc0f7a Mon Sep 17 00:00:00 2001 From: MonsieurNicolas Date: Mon, 6 Aug 2018 16:06:25 -0700 Subject: [PATCH 7/7] add a retry when running into error renaming file --- src/bucket/BucketManagerImpl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/bucket/BucketManagerImpl.cpp b/src/bucket/BucketManagerImpl.cpp index 76450f8995..5d4f6bc0db 100644 --- a/src/bucket/BucketManagerImpl.cpp +++ b/src/bucket/BucketManagerImpl.cpp @@ -184,7 +184,14 @@ BucketManagerImpl::adoptFileAsBucket(std::string const& filename, { std::string err("Failed to rename bucket :"); err += strerror(errno); - throw std::runtime_error(err); + // it seems there is a race condition with external systems + // retry after sleeping for a second works around the problem + std::this_thread::sleep_for(std::chrono::seconds(1)); + if (rename(filename.c_str(), canonicalName.c_str()) != 0) + { + // if rename fails again, surface the original error + throw std::runtime_error(err); + } } b = std::make_shared(canonicalName, hash);