Skip to content

Commit 67d43e6

Browse files
refactor(fault-proof): avoid IO under write lock (#693)
* fix: switch to RwLock for state * fix: lower fetch_interval for tests * fix: try with fetch_interval=5 * fix: test_proposer_recovery_after_canonical_head_invalidation * nit * fix: missing e2e feature flag * fix: up to 10 * fix: look up for correct parent_id * nit: bring back e2e feature * nit: docstring * fix: single lock on removing subtree of invalid games * refactor(fault-proof): avoid IO under write lock --------- Co-authored-by: Farhad Shabani <[email protected]>
1 parent 10b6333 commit 67d43e6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fault-proof/src/proposer.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,10 +987,12 @@ where
987987
/// - The game type does not respect the expected type when created.
988988
/// - The output root claim is invalid.
989989
pub async fn fetch_game(&self, index: U256) -> Result<GameFetchResult> {
990-
let mut state = self.state.write().await;
990+
{
991+
let state = self.state.read().await;
991992

992-
if state.games.contains_key(&index) {
993-
return Ok(GameFetchResult::AlreadyExists);
993+
if state.games.contains_key(&index) {
994+
return Ok(GameFetchResult::AlreadyExists);
995+
}
994996
}
995997

996998
let game = self.factory.gameAtIndex(index).call().await?;
@@ -1059,6 +1061,7 @@ where
10591061
"Valid game: adding to cache"
10601062
);
10611063

1064+
let mut state = self.state.write().await;
10621065
state.games.insert(
10631066
index,
10641067
Game {

0 commit comments

Comments
 (0)