Skip to content

Commit

Permalink
Move SCP background signature verification to after de-dupe check
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed Nov 15, 2024
1 parent 77dea72 commit a70db72
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/overlay/Peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,15 +908,6 @@ Peer::recvAuthenticatedMessage(AuthenticatedMessage&& msg)
}
}

// Verify SCP signatures when in the background
if (useBackgroundThread() && msg.v0().message.type() == SCP_MESSAGE)
{
auto& envelope = msg.v0().message.envelope();
PubKeyUtils::verifySig(envelope.statement.nodeID, envelope.signature,
xdr::xdr_to_opaque(mNetworkID, ENVELOPE_TYPE_SCP,
envelope.statement));
}

// NOTE: Additionally, we may use state snapshots to verify TRANSACTION type
// messages in the background.

Expand Down Expand Up @@ -984,6 +975,16 @@ Peer::recvAuthenticatedMessage(AuthenticatedMessage&& msg)
{
return true;
}

// Verify SCP signatures when in the background
if (useBackgroundThread() && msg.v0().message.type() == SCP_MESSAGE)
{
auto& envelope = msg.v0().message.envelope();
PubKeyUtils::verifySig(envelope.statement.nodeID, envelope.signature,
xdr::xdr_to_opaque(mNetworkID, ENVELOPE_TYPE_SCP,
envelope.statement));
}

// Subtle: move `msgTracker` shared_ptr into the lambda, to ensure
// its destructor is invoked from main thread only. Note that we can't use
// unique_ptr here, because std::function requires its callable
Expand Down

0 comments on commit a70db72

Please sign in to comment.