Update sequence number processing#1519
Update sequence number processing#1519MonsieurNicolas wants to merge 8 commits intostellar:masterfrom
Conversation
There was a problem hiding this comment.
I don't like the idea of commonValid function changing anything. The name implies that it is pure function, but now it is not. I think we should drop idea of having common valid method with applying parameter and try to do something different here.
We call commonValid from two places:
checkValidto check validity before accepting transaction andapplyto check validity when applying transaction
And it the middle of it is fee and seq number processing (but only if applying is true!).
If we split that in 3 steps code could became clearer:
checkPreValid(needs better name - it iscommonValidPreSeqNumnow)checkSeqNumValidcheckPostValid(needs better name and additional parameterbalanceAfter)
Then checkValid could do something like this:
if (!checkPreValid()) return false;
if (!checkSeqNumValid()) return false;
if (!checkPostValid(mSigningAccount->getAccount().balance - mEnvelope.tx.fee)) return false;
And apply could do something like this:
if (!checkPreValid()) return false;
if (lm.getCurrentLedgerVersion() >= 10)
{
if (!checkSeqNumValid()) return false;
setSeqNum() and storeChange();
}
if (!checkPostValid(lm.getCurrentLedgerVersion() > 8 ? mSigningAccount->getAccount().balance - mEnvelope.tx.fee : mSigningAccount->getAccount().balance)) return false;
I think it will be much cleared that all those conditions with applying and account change inside validCommon method.
now that we use "CreateTestApplication", the version used by default is "latest"
Regardless of protocol version to allow consumers (like Horizon) to move to it 100% in the future
allows to perform more checks directly there instead of having the caller perform those; also removed some exceptions that are not relevant
053cfaf to
86f7307
Compare
|
@vogel I updated based on your feeback. I ended up changing back "Check" to only do checks (and moved the side effect code outside), it avoids introducing new functions and semantics that make it hard to work across protocol versions |
|
I like the changes! Now we only need to do full catchup with that ;) |
resolves #1445
this PR changes the way we update the sequence number in the account in preparation for the
BumpSeqOperation: