Skip to content

Commit

Permalink
Merge pull request #89 from worldcoin/kit/payload-builder-tests
Browse files Browse the repository at this point in the history
fix(payload-builder): Fix payload builder tests
  • Loading branch information
0xKitsune authored Dec 21, 2024
2 parents 4be055e + c86e75a commit 268f6a9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion world-chain-builder/crates/world/node/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ async fn test_dup_pbh_nonce() -> eyre::Result<()> {

let raw_tx_0 = ctx.raw_pbh_tx_bytes(signer.clone(), 0, 0).await;
ctx.node.rpc.inject_tx(raw_tx_0.clone()).await?;
let raw_tx_1 = ctx.raw_pbh_tx_bytes(signer.clone(), 0, 1).await;
let raw_tx_1 = ctx.raw_pbh_tx_bytes(signer.clone(), 0, 0).await;

// Now that the nullifier has successfully been stored in
// the `ExecutedPbhNullifierTable`, inserting a new tx with the
Expand Down
44 changes: 21 additions & 23 deletions world-chain-builder/crates/world/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use reth::revm::witness::ExecutionWitnessRecord;
use reth::revm::{DatabaseCommit, State};
use reth::transaction_pool::{BestTransactionsAttributes, TransactionPool};
use reth_basic_payload_builder::{
BuildArguments, BuildOutcome, BuildOutcomeKind, MissingPayloadBehaviour, PayloadBuilder,
PayloadConfig,
is_better_payload, BuildArguments, BuildOutcome, BuildOutcomeKind, MissingPayloadBehaviour,
PayloadBuilder, PayloadConfig,
};
use reth_chain_state::ExecutedBlock;
use reth_evm::{ConfigureEvm, NextBlockEnvAttributes};
Expand All @@ -36,7 +36,7 @@ use reth_provider::{
};
use reth_transaction_pool::error::{InvalidPoolTransactionError, PoolTransactionError};
use reth_transaction_pool::{BestTransactions, ValidPoolTransaction};
use revm::{Database, StateBuilder};
use revm::Database;
use revm_primitives::{
BlockEnv, Bytes, CfgEnvWithHandlerCfg, EVMError, EnvWithHandlerCfg, InvalidTransaction,
ResultAndState, TxEnv, B256, U256,
Expand Down Expand Up @@ -298,7 +298,10 @@ where
impl<Pool, Client, EvmConfig, Txs> PayloadBuilder<Pool, Client>
for WorldChainPayloadBuilder<EvmConfig, Txs>
where
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = OpChainSpec> + BlockReaderIdExt,
Client: StateProviderFactory
+ ChainSpecProvider<ChainSpec = OpChainSpec>
+ BlockReaderIdExt
+ Clone,
Pool: TransactionPool<Transaction: WorldChainPoolTransaction<Consensus = TransactionSigned>>,
EvmConfig: ConfigureEvm<Header = Header, Transaction = TransactionSigned>,
Txs: OpPayloadTransactions,
Expand Down Expand Up @@ -326,23 +329,20 @@ where
// system txs, hence on_missing_payload we return [MissingPayloadBehaviour::AwaitInProgress].
fn build_empty_payload(
&self,
_client: &Client,
_config: PayloadConfig<Self::Attributes>,
client: &Client,
config: PayloadConfig<Self::Attributes>,
) -> Result<OpBuiltPayload, PayloadBuilderError> {
// TODO:
// let args = BuildArguments {
// client,
// config,
// // we use defaults here because for the empty payload we don't need to execute anything
// pool: NoopWorldChainTransactionPool::default(),
// cached_reads: Default::default(),
// cancel: Default::default(),
// best_payload: None,
// };
// self.build_payload(args)?
// .into_payload()
// .ok_or_else(|| PayloadBuilderError::MissingPayload)
todo!()
let args = BuildArguments {
client: client.clone(),
config,
pool: NoopWorldChainTransactionPool::default(),
cached_reads: Default::default(),
cancel: Default::default(),
best_payload: None,
};
self.build_payload(args)?
.into_payload()
.ok_or_else(|| PayloadBuilderError::MissingPayload)
}
}

Expand Down Expand Up @@ -695,10 +695,8 @@ impl<EvmConfig, Client> WorldChainPayloadBuilderCtx<EvmConfig, Client> {
}

/// Returns true if the fees are higher than the previous payload.
/// TODO: PBH
pub fn is_better_payload(&self, total_fees: U256) -> bool {
// self.inner.is_better_payload( total_fees)
todo!()
is_better_payload(self.inner.best_payload.as_ref(), total_fees)
}

/// Commits the withdrawals from the payload attributes to the state.
Expand Down

0 comments on commit 268f6a9

Please sign in to comment.