Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fakedev9999 committed Feb 20, 2025
1 parent 3f67cbd commit 44ef872
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 44 deletions.
14 changes: 3 additions & 11 deletions book/fault_proofs/proposer.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ The proposer is configured through various environment variables. Create a `.env

| Variable | Description | Default Value |
|----------|-------------|---------------|
| `PROPOSAL_INTERVAL_IN_BLOCKS` | Number of L2 blocks between proposals | `1000` |
| `PROPOSAL_INTERVAL_IN_BLOCKS` | Number of L2 blocks between proposals | `1800` |
| `FETCH_INTERVAL` | Polling interval in seconds | `30` |
| `ENABLE_GAME_RESOLUTION` | Whether to enable automatic game resolution | `false` |
| `ENABLE_GAME_RESOLUTION` | Whether to enable automatic game resolution | `true` |
| `MAX_GAMES_TO_CHECK_FOR_RESOLUTION` | Maximum number of games to check for resolution | `100` |
| `FAST_FINALITY_MODE` | Enable fast finality with proofs | `false` |

```env
# Required Configuration
Expand All @@ -56,11 +55,10 @@ GAME_TYPE= # Type identifier for the dispute game (must match fact
PRIVATE_KEY= # Private key for transaction signing
# Optional Configuration
PROPOSAL_INTERVAL_IN_BLOCKS=1000 # Number of L2 blocks between proposals
PROPOSAL_INTERVAL_IN_BLOCKS=1800 # Number of L2 blocks between proposals
FETCH_INTERVAL=30 # Polling interval in seconds
ENABLE_GAME_RESOLUTION=false # Whether to enable automatic game resolution
MAX_GAMES_TO_CHECK_FOR_RESOLUTION=100 # Maximum number of games to check for resolution
FAST_FINALITY_MODE=false # Enable fast finality mode with proofs
```

### Configuration Steps
Expand Down Expand Up @@ -101,12 +99,6 @@ When enabled (`ENABLE_GAME_RESOLUTION=true`), the proposer:
- Maintains proper spacing between proposals based on configuration
- Tracks the latest valid proposal for proper sequencing

### Fast Finality Mode
When enabled (`FAST_FINALITY_MODE=true`), the proposer:
- Includes proofs with proposals for faster finality
- Adds additional data to game creation transactions
- Enables immediate validation of proposals

## Logging

The proposer uses the `tracing` crate for logging with a default level of INFO. You can adjust the log level by setting the `RUST_LOG` environment variable:
Expand Down
8 changes: 1 addition & 7 deletions book/fault_proofs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ cargo run --bin proposer

1. The proposer will automatically create new games at regular intervals (every 1800 blocks with the default config)
2. You can view created games on a block explorer using the factory address and the game address in the proposer logs

## Next Steps

Once you've seen the basic flow:
1. Try `ENABLE_GAME_RESOLUTION=true` to automatically resolve unchallenged games
2. Try enabling `FAST_FINALITY_MODE=true` to include proofs on game creation and get faster finality
3. Try removing the `USE_SP1_MOCK_VERIFIER=true` flag and use [Succinct Prover Network](https://docs.succinct.xyz/docs/sp1/generating-proofs/prover-network) with [deployed SP1 Verifiers](https://docs.succinct.xyz/docs/sp1/verification/onchain/contract-addresses) for production
3. The proposer will also attempt to resolve unchallenged games after the challenge period expires

## Troubleshooting

Expand Down
26 changes: 9 additions & 17 deletions fault_proof/bin/proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,13 @@ where
/// `l2_block_number`: the L2 block number we are proposing the output root for.
/// `parent_game_index`: the index of the parent game.
async fn create_game(&self, l2_block_number: U256, parent_game_index: u32) -> Result<()> {
let extra_data = if self.config.fast_finality_mode {
tracing::info!("Creating game with fast finality mode");

let proof = vec![];
<(U256, u32, bool, Vec<u8>)>::abi_encode_packed(&(
l2_block_number,
parent_game_index,
self.config.fast_finality_mode,
proof,
))
} else {
tracing::info!("Creating game with non fast finality mode");
tracing::info!(
"Creating game at L2 block number: {:?}, with parent game index: {:?}",
l2_block_number,
parent_game_index
);

<(U256, u32)>::abi_encode_packed(&(l2_block_number, parent_game_index))
};
let extra_data = <(U256, u32)>::abi_encode_packed(&(l2_block_number, parent_game_index));

let receipt = self
.factory
Expand All @@ -99,10 +91,10 @@ where
.get_receipt()
.await?;

let game_address = receipt.inner.logs()[0].address();

let game_address =
Address::from_slice(&receipt.inner.logs()[0].inner.data.topics()[1][12..]);
tracing::info!(
"New game {:?} created with tx {:?}",
"\x1b[1mNew game at address {:?} created with tx {:?}\x1b[0m",
game_address,
receipt.transaction_hash
);
Expand Down
10 changes: 1 addition & 9 deletions fault_proof/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ pub struct ProposerConfig {
/// When game resolution is enabled, the proposer will attempt to resolve games that are
/// unchallenged up to `max_games_to_check_for_resolution` games behind the latest game.
pub max_games_to_check_for_resolution: u64,

/// Whether to enable fast finality mode.
/// When fast finality mode is enabled, the proposer will propose games with a proof that
/// the proposal is valid.
pub fast_finality_mode: bool,
}

impl ProposerConfig {
Expand All @@ -62,14 +57,11 @@ impl ProposerConfig {
.parse()?,
game_type: env::var("GAME_TYPE").expect("GAME_TYPE not set").parse()?,
enable_game_resolution: env::var("ENABLE_GAME_RESOLUTION")
.unwrap_or("false".to_string())
.unwrap_or("true".to_string())
.parse()?,
max_games_to_check_for_resolution: env::var("MAX_GAMES_TO_CHECK_FOR_RESOLUTION")
.unwrap_or("100".to_string())
.parse()?,
fast_finality_mode: env::var("FAST_FINALITY_MODE")
.unwrap_or("false".to_string())
.parse()?,
})
}
}

0 comments on commit 44ef872

Please sign in to comment.