fixed time conversion
This commit is contained in:
parent
3eb4fb7523
commit
35d09c642b
|
@ -29,6 +29,8 @@ pub enum TxCommand {
|
||||||
slot_length: u64,
|
slot_length: u64,
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
zero_time: u64,
|
zero_time: u64,
|
||||||
|
#[clap(short, long)]
|
||||||
|
zero_slot: u64,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
resolved_inputs,
|
resolved_inputs,
|
||||||
slot_length,
|
slot_length,
|
||||||
zero_time,
|
zero_time,
|
||||||
|
zero_slot,
|
||||||
} => {
|
} => {
|
||||||
let tx_bytes = if cbor {
|
let tx_bytes = if cbor {
|
||||||
fs::read(input)?
|
fs::read(input)?
|
||||||
|
@ -51,6 +52,7 @@ fn main() -> anyhow::Result<()> {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time,
|
zero_time,
|
||||||
|
zero_slot,
|
||||||
slot_length,
|
slot_length,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,12 +68,13 @@ pub fn eval_phase_two(
|
||||||
/// This function is the same as [`eval_phase_two`]
|
/// This function is the same as [`eval_phase_two`]
|
||||||
/// but the inputs are raw bytes.
|
/// but the inputs are raw bytes.
|
||||||
/// initial_budget expects (cpu, mem).
|
/// initial_budget expects (cpu, mem).
|
||||||
|
/// slot_config (zero_time, zero_slot, slot_length)
|
||||||
pub fn eval_phase_two_raw(
|
pub fn eval_phase_two_raw(
|
||||||
tx_bytes: &[u8],
|
tx_bytes: &[u8],
|
||||||
utxos_bytes: &[(Vec<u8>, Vec<u8>)],
|
utxos_bytes: &[(Vec<u8>, Vec<u8>)],
|
||||||
cost_mdls_bytes: &[u8],
|
cost_mdls_bytes: &[u8],
|
||||||
initial_budget: (u64, u64),
|
initial_budget: (u64, u64),
|
||||||
slot_config: (u64, u64),
|
slot_config: (u64, u64, u64),
|
||||||
run_phase_one: bool,
|
run_phase_one: bool,
|
||||||
) -> Result<Vec<Vec<u8>>, Error> {
|
) -> Result<Vec<Vec<u8>>, Error> {
|
||||||
let multi_era_tx = MultiEraTx::decode(Era::Babbage, tx_bytes)
|
let multi_era_tx = MultiEraTx::decode(Era::Babbage, tx_bytes)
|
||||||
|
@ -97,7 +98,8 @@ pub fn eval_phase_two_raw(
|
||||||
|
|
||||||
let sc = SlotConfig {
|
let sc = SlotConfig {
|
||||||
zero_time: slot_config.0,
|
zero_time: slot_config.0,
|
||||||
slot_length: slot_config.1,
|
zero_slot: slot_config.1,
|
||||||
|
slot_length: slot_config.2,
|
||||||
};
|
};
|
||||||
|
|
||||||
match multi_era_tx {
|
match multi_era_tx {
|
||||||
|
|
|
@ -24,7 +24,7 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
fn slot_to_begin_posix_time(slot: u64, sc: &SlotConfig) -> u64 {
|
fn slot_to_begin_posix_time(slot: u64, sc: &SlotConfig) -> u64 {
|
||||||
let ms_after_begin = slot * sc.slot_length;
|
let ms_after_begin = (slot - sc.zero_slot) * sc.slot_length;
|
||||||
sc.zero_time + ms_after_begin
|
sc.zero_time + ms_after_begin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ pub struct TimeRange {
|
||||||
|
|
||||||
pub struct SlotConfig {
|
pub struct SlotConfig {
|
||||||
pub slot_length: u64,
|
pub slot_length: u64,
|
||||||
|
pub zero_slot: u64,
|
||||||
pub zero_time: u64,
|
pub zero_time: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +92,8 @@ impl Default for SlotConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
zero_time: 1596491091,
|
zero_slot: 4492800,
|
||||||
|
zero_time: 1596059091000,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ fn test_eval() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -292,6 +293,7 @@ fn test_eval_1() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -561,6 +563,7 @@ fn test_eval_2() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -659,6 +662,7 @@ fn test_eval_3() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -925,6 +929,7 @@ fn test_eval_4() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1006,6 +1011,7 @@ fn test_eval_5() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1108,6 +1114,7 @@ fn test_eval_6() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1596059091000, // Mainnet network
|
zero_time: 1596059091000, // Mainnet network
|
||||||
|
zero_slot: 4492800,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1211,6 +1218,7 @@ fn test_eval_7() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1596059091000, // Mainnet network
|
zero_time: 1596059091000, // Mainnet network
|
||||||
|
zero_slot: 4492800,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1301,6 +1309,7 @@ fn test_eval_8() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1596059091000, // Mainnet network
|
zero_time: 1596059091000, // Mainnet network
|
||||||
|
zero_slot: 4492800,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1564,6 +1573,7 @@ fn eval_missing_redeemer() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1642,6 +1652,7 @@ fn eval_extraneous_redeemer() {
|
||||||
|
|
||||||
let slot_config = SlotConfig {
|
let slot_config = SlotConfig {
|
||||||
zero_time: 1660003200000, // Preview network
|
zero_time: 1660003200000, // Preview network
|
||||||
|
zero_slot: 0,
|
||||||
slot_length: 1000,
|
slot_length: 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue