Describe the bug
When fetching interactions from GQL - duplicate interactions (having the same txId) are not prevented from being evaluated twice, resulting in unintended state changes.
To Reproduce
Add logs to ArweaveGatewayInteractionsLoader that log all the interactions processed for the contract
Load the contract - blAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U using arweave.net with a clean cache
const warp = WarpFactory.forMainnet(defaultCacheOptions, true);
const contract = await warp.contract('blAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U')
const { cachedValue } = await contract.readState(
// a valid sort key for an interaction that gets processed twice
'000001307087,0000000000000,0cbe0824cdf7ba421c49d08ebf6cd0957d0396da8ebe78107a37baa31ed5bbe4',
);
You'll see that the interaction fTpFLc_GKVpXlbxHgVrfDSI4BzBVnREuMSeOL0TBJf4 is processed twice (and logged out twice). The first evaluation adds murdock object to state.records - the second throws an errory. The result is the following evaluation result (condensed for readababiity):
{
"state": {
"records": {
"murdock": {
...object added in first evaluation
},
...other records
}
...other state
}
"validity": {
...other interactions
"fTpFLc_GKVpXlbxHgVrfDSI4BzBVnREuMSeOL0TBJf4": false
},
"errorMessages": {
....other interactions
"fTpFLc_GKVpXlbxHgVrfDSI4BzBVnREuMSeOL0TBJf4": "This name already exists in an active lease"
}
Expected behavior
Each interaction ID is only processed once.
ok, I've accepted the version with the map for now, as I've noted on discord - we will soon introduce processing of interactions in 'batches', so memory usage should no longer be a concern.
Describe the bug When fetching interactions from GQL - duplicate interactions (having the same txId) are not prevented from being evaluated twice, resulting in unintended state changes.
To Reproduce
ArweaveGatewayInteractionsLoader
that log all the interactions processed for the contractblAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U
using arweave.net with a clean cachefTpFLc_GKVpXlbxHgVrfDSI4BzBVnREuMSeOL0TBJf4
is processed twice (and logged out twice). The first evaluation addsmurdock
object tostate.records
- the second throws an errory. The result is the following evaluation result (condensed for readababiity):Expected behavior Each interaction ID is only processed once.
Proposed Change Proposed change here
Desktop (please complete the following information):