Closed joshuef closed 3 months ago
EDIT: We already perform this
Also, earlier, when a node sees a double spend during validation, it'd take Vec<SignedSpends>.sort().take(2)
and would store that + propagate that to other peers, but currently it is removed from the code.
Would that help here? I feel like currently, in case of a double spend, the state for each node is different, but if we sort,accumulate them, we'd get a consistent state among nodes and seeing if a spend is a double spend is relatively easy?
Closing in favour of 1904
This pull request primarily modifies the
sn_client/src/api.rs
,sn_networking/src/driver.rs
,sn_networking/src/event/kad.rs
,sn_networking/src/lib.rs
,sn_networking/src/spends.rs
,sn_networking/src/transfers.rs
,sn_node/src/put_validation.rs
, andsn_node/src/replication.rs
files, focusing on improving the handling of spend records and double spend attempts in the network. The changes include renaming methods and adding a new configuration option to accumulate spend attempts, which can help the client decide whether to retry an operation.Method Renaming:
get_signed_spend_from_record
is renamed toget_solitary_signed_spend_from_record
and now returns an error if a double spend attempt is detected. [1] [2] [3] [4]New Configuration Option:
accumulate_spend_attempts
is added toGetRecordCfg
. This option determines whether to accumulate all double spend attempts and return them, which can help the client decide whether to retry the operation. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Handling of Spend Records:
get_valid_spend
method and the addition of a new methodtry_fetch_solitary_spend_from_network
. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Other Changes:
sn_node/src/put_validation.rs
, a comment is added to clarify that at most two spends for the same unique public key are expected.sn_node/src/replication.rs
, a comment is added to explain that the code does not care about how many nodes are storing a record, and that it can error out withSplitRecord
and keep retrying so it does not replicateDoubleSpendAttempted
spends.