Ethereum processor docker tests, barring send

We need the TX publication relay thingy for send to work (though that is the
point the test fails at).
This commit is contained in:
Luke Parker
2024-05-21 00:29:33 -04:00
parent ae8a27b876
commit 11ec9e3535
20 changed files with 305 additions and 91 deletions

View File

@@ -512,6 +512,7 @@ impl<N: Network, D: Db> KeyGen<N, D> {
ProcessorMessage::GeneratedKeyPair {
id,
substrate_key: generated_substrate_key.unwrap().to_bytes(),
// TODO: This can be made more efficient since tweaked keys may be a subset of keys
network_key: generated_network_key.unwrap().to_bytes().as_ref().to_vec(),
}
}

View File

@@ -63,9 +63,22 @@ fn instruction_from_output<N: Network>(
return (presumed_origin, None);
}
let Ok(shorthand) = Shorthand::decode(&mut data) else { return (presumed_origin, None) };
let Ok(instruction) = RefundableInInstruction::try_from(shorthand) else {
return (presumed_origin, None);
let shorthand = match Shorthand::decode(&mut data) {
Ok(shorthand) => shorthand,
Err(e) => {
info!("data in output {} wasn't valid shorthand: {e:?}", hex::encode(output.id()));
return (presumed_origin, None);
}
};
let instruction = match RefundableInInstruction::try_from(shorthand) {
Ok(instruction) => instruction,
Err(e) => {
info!(
"shorthand in output {} wasn't convertible to a RefundableInInstruction: {e:?}",
hex::encode(output.id())
);
return (presumed_origin, None);
}
};
let mut balance = output.balance();

View File

@@ -279,6 +279,8 @@ impl<N: Network, D: Db> ScannerHandle<N, D> {
activation_number: usize,
key: <N::Curve as Ciphersuite>::G,
) {
info!("Registering key {} in scanner at {activation_number}", hex::encode(key.to_bytes()));
let mut scanner_lock = self.scanner.write().await;
let scanner = scanner_lock.as_mut().unwrap();
assert!(
@@ -286,8 +288,6 @@ impl<N: Network, D: Db> ScannerHandle<N, D> {
"activation block of new keys was already scanned",
);
info!("Registering key {} in scanner at {activation_number}", hex::encode(key.to_bytes()));
if scanner.keys.is_empty() {
assert!(scanner.ram_scanned.is_none());
scanner.ram_scanned = Some(activation_number);

View File

@@ -116,7 +116,7 @@ impl<N: Network<Scheduler = Self>> SchedulerTrait<N> for Scheduler<N> {
assert!(self.coins.contains(&utxo.balance().coin));
}
let mut nonce = LastNonce::get(txn).map_or(1, |nonce| nonce + 1);
let mut nonce = LastNonce::get(txn).unwrap_or(1);
let mut plans = vec![];
for chunk in payments.as_slice().chunks(N::MAX_OUTPUTS) {
// Once we rotate, all further payments should be scheduled via the new multisig

View File

@@ -432,7 +432,7 @@ impl<N: UtxoNetwork<Scheduler = Self>> Scheduler<N> {
}
// If there's a UTXO to restore, restore it
// This is down now as if there is a to_restore output, and it was inserted into self.utxos
// This is done now as if there is a to_restore output, and it was inserted into self.utxos
// earlier, self.utxos.len() may become `N::MAX_INPUTS + 1`
// The prior block requires the len to be `<= N::MAX_INPUTS`
if let Some(to_restore) = to_restore {
@@ -442,9 +442,10 @@ impl<N: UtxoNetwork<Scheduler = Self>> Scheduler<N> {
txn.put(scheduler_key::<D, _>(&self.key), self.serialize());
log::info!(
"created {} plans containing {} payments to sign",
"created {} plans containing {} payments to sign, with {} payments pending scheduling",
plans.len(),
payments_at_start - self.payments.len(),
self.payments.len(),
);
plans
}
@@ -589,7 +590,8 @@ impl<N: UtxoNetwork<Scheduler = Self>> SchedulerTrait<N> for Scheduler<N> {
output: N::Output,
refund_to: N::Address,
) -> Plan<N> {
Plan {
let output_id = output.id().as_ref().to_vec();
let res = Plan {
key: output.key(),
// Uses a payment as this will still be successfully sent due to fee amortization,
// and because change is currently always a Serai key
@@ -597,7 +599,9 @@ impl<N: UtxoNetwork<Scheduler = Self>> SchedulerTrait<N> for Scheduler<N> {
inputs: vec![output],
change: None,
scheduler_addendum: (),
}
};
log::info!("refund plan for {} has ID {}", hex::encode(output_id), hex::encode(res.id()));
res
}
fn shim_forward_plan(output: N::Output, to: <N::Curve as Ciphersuite>::G) -> Option<Plan<N>> {

View File

@@ -426,7 +426,7 @@ impl<D: Db> Network for Ethereum<D> {
.get_block(BlockNumberOrTag::Finalized.into(), false)
.await
.map_err(|_| NetworkError::ConnectionError)?
.expect("no blocks were finalized")
.ok_or(NetworkError::ConnectionError)?
.header
.number
.unwrap();