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

CAP-0015 Implementation #2419

Merged
merged 50 commits into from
Mar 26, 2020
Merged

Conversation

jonjove
Copy link
Contributor

@jonjove jonjove commented Feb 4, 2020

Implements https://github.com/stellar/stellar-protocol/blob/master/core/cap-0015.md

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v5.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copy link
Contributor

@MonsieurNicolas MonsieurNicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial review only - I didn't review " Update TransactionQueue for fee-bump transactions " and beyond

src/xdr/Stellar-transaction.x Show resolved Hide resolved
src/xdr/Stellar-transaction.x Show resolved Hide resolved
src/main/dumpxdr.cpp Outdated Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Outdated Show resolved Hide resolved
src/xdr/Stellar-transaction.x Outdated Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Show resolved Hide resolved
src/transactions/TransactionSQL.cpp Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Outdated Show resolved Hide resolved
src/transactions/FeeBumpTransactionFrame.cpp Outdated Show resolved Hide resolved
src/transactions/TransactionFrameBase.h Show resolved Hide resolved
src/herder/TransactionQueue.h Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
{
int64_t oldFee = (*oldTxIter)->getFeeBid();
if (fee < FEE_MULTIPLIER * oldFee)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tx->getResult().result.code(txINSUFFICIENT_FEE);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was decided on the tx endpoint: when we return txINSUFFICIENT_FEE, should we return some other information like fee required? (can be in XDR if this is only for Bump Fee or on the side)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we ever came to a final conclusion on this. I'd rather not do the change in XDR. I think adding a field to the JSON response like "recommended_fee" would probably be best. This assumes that we want a "submit-then-get-recommendation" model, but other models like "get-recommendation-before-submit" are also possible. We should follow up with the Horizon team to see if they have any input on how this interface should work (@ire-and-curses).

src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/herder/TxSetFrame.cpp Show resolved Hide resolved
src/herder/TxSetFrame.cpp Show resolved Hide resolved
Copy link
Contributor Author

@jonjove jonjove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed most of your comments and added many new tests. The remaining comments involve de-duplicating some code and re-ordering some commits, both of which I will do once we are otherwise satisfied with the PR.

src/xdr/Stellar-transaction.x Show resolved Hide resolved
src/xdr/Stellar-transaction.x Show resolved Hide resolved
src/xdr/Stellar-transaction.x Outdated Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Outdated Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/herder/TxSetFrame.cpp Show resolved Hide resolved
@MonsieurNicolas
Copy link
Contributor

List of warnings I am getting off 02a1fd614ed6a944a3df1734ae50458d2d11cb79

stellar-core/src/herder/TransactionQueue.cpp(72,9): warning C4018: '<=': signed/unsigned mismatch
stellar-core/src/herder/test/HerderTests.cpp(59,27): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(62,27): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(515,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(532,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(549,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(563,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(579,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(591,53): warning C4244: 'argument': conversion from 'const int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(600,53): warning C4244: 'argument': conversion from 'const int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(617,53): warning C4244: 'argument': conversion from 'const int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(633,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(646,53): warning C4244: 'argument': conversion from 'const int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(660,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/HerderTests.cpp(677,72): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/TransactionQueueTests.cpp(841,75): warning C4244: 'argument': conversion from 'int64_t' to 'int', possible loss of data
stellar-core/src/herder/test/UpgradesTests.cpp(1665,22): warning C4456: declaration of 'txSet' hides previous local declaration
stellar-core/src/herder/test/UpgradesTests.cpp(1655,10): message : see declaration of 'txSet'
stellar-core/src/transactions/test/TxEnvelopeTests.cpp(58,27): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/transactions/test/TxEnvelopeTests.cpp(61,27): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/transactions/test/TxResultsTests.cpp(47,27): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/transactions/test/TxResultsTests.cpp(50,27): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/transactions/TransactionFrame.cpp(280,59): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
stellar-core/src/transactions/TransactionFrame.cpp(480,23): warning C4244: 'initializing': conversion from 'int64_t' to 'uint32_t', possible loss of data
stellar-core/src/transactions/TransactionSQL.cpp(30,48): warning C4267: 'initializing': conversion from 'size_t' to 'uint32_t', possible loss of data
stellar-core/src/transactions/test/FeeBumpTransactionTests.cpp(43,23): warning C4244: '=': conversion from 'int64_t' to 'stellar::uint32', possible loss of data
stellar-core/src/transactions/test/FeeBumpTransactionTests.cpp(449,1): warning C4458: declaration of 'acc' hides class member
stellar-core/src/transactions/test/FeeBumpTransactionTests.cpp(459,13): message : see declaration of '____C_A_T_C_H____T_E_S_T____0::<lambda_a98f7efadea3c202b0f63eb5cc683e42>::acc'
stellar-core/src/transactions/test/FeeBumpTransactionTests.cpp(454,1): warning C4458: declaration of 'acc' hides class member
stellar-core/src/transactions/test/FeeBumpTransactionTests.cpp(459,13): message : see declaration of '____C_A_T_C_H____T_E_S_T____0::<lambda_a98f7efadea3c202b0f63eb5cc683e42>::acc'

@MonsieurNicolas
Copy link
Contributor

Patch for VS project

diff --git a/Builds/VisualStudio/stellar-core.vcxproj b/Builds/VisualStudio/stellar-core.vcxproj
index ce07d20e..37175e6f 100644
--- a/Builds/VisualStudio/stellar-core.vcxproj
+++ b/Builds/VisualStudio/stellar-core.vcxproj
@@ -317,17 +317,22 @@ exit /b 0
     <ClCompile Include="..\..\src\herder\QuorumIntersectionCheckerImpl.cpp" />
     <ClCompile Include="..\..\src\herder\test\QuorumIntersectionTests.cpp" />
     <ClCompile Include="..\..\src\ledger\test\LedgerCloseMetaStreamTests.cpp" />
+    <ClCompile Include="..\..\src\main\test\CommandHandlerTests.cpp" />
     <ClCompile Include="..\..\src\overlay\SurveyManager.cpp" />
     <ClCompile Include="..\..\src\overlay\SurveyMessageLimiter.cpp" />
     <ClCompile Include="..\..\src\overlay\test\SurveyManagerTests.cpp" />
     <ClCompile Include="..\..\src\overlay\test\SurveyMessageLimiterTests.cpp" />
     <ClCompile Include="..\..\src\test\FuzzerImpl.cpp" />
+    <ClCompile Include="..\..\src\transactions\FeeBumpTransactionFrame.cpp" />
     <ClCompile Include="..\..\src\transactions\PathPaymentOpFrameBase.cpp" />
     <ClCompile Include="..\..\src\transactions\PathPaymentStrictReceiveOpFrame.cpp" />
     <ClCompile Include="..\..\src\transactions\PathPaymentStrictSendOpFrame.cpp" />
     <ClCompile Include="..\..\src\transactions\simulation\SimulationMergeOpFrame.cpp" />
     <ClCompile Include="..\..\src\transactions\simulation\SimulationTransactionFrame.cpp" />
+    <ClCompile Include="..\..\src\transactions\test\FeeBumpTransactionTests.cpp" />
     <ClCompile Include="..\..\src\transactions\test\PathPaymentStrictSendTests.cpp" />
+    <ClCompile Include="..\..\src\transactions\TransactionFrameBase.cpp" />
+    <ClCompile Include="..\..\src\transactions\TransactionSQL.cpp" />
     <ClCompile Include="..\..\src\util\FileSystemException.cpp" />
     <ClCompile Include="..\..\src\work\BatchWork.cpp" />
     <ClCompile Include="..\..\src\historywork\DownloadBucketsWork.cpp" />
@@ -642,11 +647,14 @@ exit /b 0
     <ClInclude Include="..\..\src\overlay\SurveyManager.h" />
     <ClInclude Include="..\..\src\overlay\SurveyMessageLimiter.h" />
     <ClInclude Include="..\..\src\test\FuzzerImpl.h" />
+    <ClInclude Include="..\..\src\transactions\FeeBumpTransactionFrame.h" />
     <ClInclude Include="..\..\src\transactions\PathPaymentOpFrameBase.h" />
     <ClInclude Include="..\..\src\transactions\PathPaymentStrictReceiveOpFrame.h" />
     <ClInclude Include="..\..\src\transactions\PathPaymentStrictSendOpFrame.h" />
     <ClInclude Include="..\..\src\transactions\simulation\SimulationMergeOpFrame.h" />
     <ClInclude Include="..\..\src\transactions\simulation\SimulationTransactionFrame.h" />
+    <ClInclude Include="..\..\src\transactions\TransactionFrameBase.h" />
+    <ClInclude Include="..\..\src\transactions\TransactionSQL.h" />
     <ClInclude Include="..\..\src\work\BatchWork.h" />
     <ClInclude Include="..\..\src\historywork\DownloadBucketsWork.h" />
     <ClInclude Include="..\..\src\historywork\DownloadVerifyTxResultsWork.h" />
diff --git a/Builds/VisualStudio/stellar-core.vcxproj.filters b/Builds/VisualStudio/stellar-core.vcxproj.filters
index 232ec15c..6ab5dc81 100644
--- a/Builds/VisualStudio/stellar-core.vcxproj.filters
+++ b/Builds/VisualStudio/stellar-core.vcxproj.filters
@@ -1029,6 +1029,21 @@
     <ClCompile Include="..\..\src\overlay\test\SurveyMessageLimiterTests.cpp">
       <Filter>overlay\tests</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\main\test\CommandHandlerTests.cpp">
+      <Filter>main\tests</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\transactions\test\FeeBumpTransactionTests.cpp">
+      <Filter>transactions\tests</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\transactions\FeeBumpTransactionFrame.cpp">
+      <Filter>transactions</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\transactions\TransactionFrameBase.cpp">
+      <Filter>transactions</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\src\transactions\TransactionSQL.cpp">
+      <Filter>transactions</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\lib\util\easylogging++.h">
@@ -1778,6 +1793,15 @@
     <ClInclude Include="..\..\src\overlay\SurveyMessageLimiter.h">
       <Filter>overlay</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\transactions\FeeBumpTransactionFrame.h">
+      <Filter>transactions</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\transactions\TransactionFrameBase.h">
+      <Filter>transactions</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\src\transactions\TransactionSQL.h">
+      <Filter>transactions</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\AUTHORS" />

src/herder/TransactionQueue.h Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
{
int64_t oldFee = (*oldTxIter)->getFeeBid();
if (fee < FEE_MULTIPLIER * oldFee)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was decided on the tx endpoint: when we return txINSUFFICIENT_FEE, should we return some other information like fee required? (can be in XDR if this is only for Bump Fee or on the side)

src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/main/CommandHandler.cpp Outdated Show resolved Hide resolved
src/transactions/FeeBumpTransactionFrame.cpp Outdated Show resolved Hide resolved
src/transactions/FeeBumpTransactionFrame.cpp Outdated Show resolved Hide resolved
src/transactions/FeeBumpTransactionFrame.cpp Outdated Show resolved Hide resolved
@MonsieurNicolas
Copy link
Contributor

Latest warnings:

2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(240,32): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(241,32): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(582,60): warning C4245: 'argument': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(609,60): warning C4245: 'argument': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(623,60): warning C4245: 'argument': conversion from 'int' to 'uint32_t', signed/unsigned mismatch
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(906,40): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(935,38): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(963,44): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\herder\test\HerderTests.cpp(967,44): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\herder\test\TransactionQueueTests.cpp(700,5): warning C4018: '<': signed/unsigned mismatch
2>C:\src\stellar-core\src\herder\test\TransactionQueueTests.cpp(702,5): warning C4389: '==': signed/unsigned mismatch
2>C:\src\stellar-core\src\herder\test\TransactionQueueTests.cpp(718,1): warning C4389: '==': signed/unsigned mismatch
2>C:\src\stellar-core\src\transactions\test\FeeBumpTransactionTests.cpp(55,60): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\transactions\test\TxResultsTests.cpp(307,48): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\transactions\test\TxResultsTests.cpp(376,48): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\transactions\test\TxResultsTests.cpp(458,48): warning C4244: 'argument': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\transactions\TransactionFrame.cpp(272,51): warning C4267: 'argument': conversion from 'size_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\transactions\TransactionFrame.cpp(473,23): warning C4244: 'initializing': conversion from 'int64_t' to 'uint32_t', possible loss of data
2>C:\src\stellar-core\src\transactions\TransactionFrame.cpp(743,34): warning C4101: 'e': unreferenced local variable

src/transactions/TransactionBridge.cpp Outdated Show resolved Hide resolved
src/main/dumpxdr.cpp Outdated Show resolved Hide resolved
src/main/CommandHandler.cpp Outdated Show resolved Hide resolved
src/transactions/TransactionBridge.cpp Show resolved Hide resolved
src/transactions/TransactionBridge.cpp Outdated Show resolved Hide resolved
src/herder/HerderImpl.cpp Show resolved Hide resolved
src/overlay/Floodgate.cpp Outdated Show resolved Hide resolved
src/ledger/LedgerManagerImpl.cpp Outdated Show resolved Hide resolved
src/transactions/TransactionFrameBase.h Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Show resolved Hide resolved
@MonsieurNicolas
Copy link
Contributor

Left a few comments, mostly cosmetic @jonjove

src/transactions/TransactionFrame.cpp Show resolved Hide resolved
src/herder/test/HerderTests.cpp Show resolved Hide resolved
src/herder/test/HerderTests.cpp Show resolved Hide resolved
src/herder/test/TransactionQueueTests.cpp Show resolved Hide resolved
// because it is be used to represent the result of a Transaction.
struct InnerTransactionResult
{
int64 feeCharged;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there ever a case where feeCharged will not be zero? It seems that the test cases in src/transactions/test/FeeBumpTransactionTests.cpp assert that the feeCharged in the inner transaction result is zero. If that's the case then it would be helpful to add a comment indicating that feeCharged should be ignored and it's only there so that InnerTransactionResult is binary compatible with TransactionResult.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@MonsieurNicolas MonsieurNicolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question related to backward compatibility in the transaction queue

src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/herder/TransactionQueue.cpp Outdated Show resolved Hide resolved
src/herder/TransactionQueue.cpp Show resolved Hide resolved
src/transactions/TransactionFrame.cpp Show resolved Hide resolved
src/herder/test/TransactionQueueTests.cpp Show resolved Hide resolved
src/herder/test/TransactionQueueTests.cpp Show resolved Hide resolved
@MonsieurNicolas
Copy link
Contributor

r+ 8780721

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants