Skip to content

Commit

Permalink
rusk: deal with execution-core changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Leegwater Simões committed Jul 3, 2024
1 parent ef017ad commit e2a2d82
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion rusk/src/lib/chain/rusk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Rusk {
}
}
let tx_id = hex::encode(unspent_tx.id());
if unspent_tx.inner.payload().fee().gas_limit > block_gas_left {
if unspent_tx.inner.payload().fee.gas_limit > block_gas_left {
info!("Skipping {tx_id} due gas_limit greater than left: {block_gas_left}");
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion rusk/src/lib/chain/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl VMExecution for Rusk {
info!("Received preverify request");
let tx = &tx.inner;
let existing_nullifiers = self
.existing_nullifiers(&tx.payload().tx_skeleton().nullifiers)
.existing_nullifiers(&tx.payload().tx_skeleton.nullifiers)
.map_err(|e| anyhow::anyhow!("Cannot check nullifiers: {e}"))?;

if !existing_nullifiers.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion rusk/src/lib/http/chain/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Query {
t.0.inner
.inner
.payload()
.contract_call()
.contract_call
.as_ref()
.map(|c| c.contract)
.unwrap_or(
Expand Down
32 changes: 15 additions & 17 deletions rusk/src/lib/http/chain/graphql/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,24 @@ impl Transaction<'_> {
let mut map = Map::new();
map.insert(
"root".into(),
json!(hex::encode(tx.payload().tx_skeleton().root.to_bytes())),
json!(hex::encode(tx.payload().tx_skeleton.root.to_bytes())),
);
let nullifiers: Vec<_> = tx
.payload()
.tx_skeleton()
.nullifiers()
.tx_skeleton
.nullifiers
.iter()
.map(|n| hex::encode(n.to_bytes()))
.collect();
map.insert("nullifier".into(), json!(nullifiers));
map.insert(
"deposit".into(),
json!(hex::encode(tx.payload().tx_skeleton().deposit.to_bytes())),
json!(hex::encode(tx.payload().tx_skeleton.deposit.to_bytes())),
);
let notes: Vec<_> = tx
.payload()
.tx_skeleton()
.outputs()
.tx_skeleton
.outputs
.iter()
.map(|n| {
let mut map = Map::new();
Expand Down Expand Up @@ -301,22 +301,20 @@ impl Transaction<'_> {
map.insert("notes".into(), json!(notes));

let mut fee = Map::new();
fee.insert("gas_limit".into(), json!(tx.payload().fee().gas_limit));
fee.insert("gas_price".into(), json!(tx.payload().fee().gas_price));
fee.insert("gas_limit".into(), json!(tx.payload().fee.gas_limit));
fee.insert("gas_price".into(), json!(tx.payload().fee.gas_price));
fee.insert(
"stealth_address".into(),
json!(bs58::encode(
tx.payload().fee().stealth_address().to_bytes()
)
.into_string()),
json!(bs58::encode(tx.payload().fee.stealth_address.to_bytes())
.into_string()),
);
fee.insert(
"sender".into(),
json!(hex::encode(tx.payload().fee().sender().to_bytes())),
json!(hex::encode(tx.payload().fee.sender.to_bytes())),
);
map.insert("fee".into(), json!(fee));

if let Some(c) = tx.payload().contract_call() {
if let Some(c) = &tx.payload().contract_call {
let mut call = Map::new();
call.insert("contract".into(), json!(hex::encode(c.contract)));
call.insert("fn_name".into(), json!(&c.fn_name));
Expand All @@ -332,18 +330,18 @@ impl Transaction<'_> {
}

pub async fn gas_limit(&self) -> u64 {
self.0.inner.payload().fee().gas_limit
self.0.inner.payload().fee.gas_limit
}

pub async fn gas_price(&self) -> u64 {
self.0.inner.payload().fee().gas_price
self.0.inner.payload().fee.gas_price
}

pub async fn call_data(&self) -> Option<CallData> {
self.0
.inner
.payload()
.contract_call()
.contract_call
.as_ref()
.map(|call| CallData {
contract: hex::encode(call.contract),
Expand Down
2 changes: 1 addition & 1 deletion rusk/src/lib/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn verify_proof(tx: &Transaction) -> Result<bool> {

// Maybe we want to handle internal serialization error too, currently
// they map to `false`.
Ok(rusk_abi::verify_proof(vd.to_vec(), tx.proof().clone(), pi))
Ok(rusk_abi::verify_proof(vd.to_vec(), tx.proof().to_vec(), pi))
}

fn fetch_verifier(circuit_name: &str) -> Vec<u8> {
Expand Down
4 changes: 2 additions & 2 deletions rusk/tests/services/multi_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ fn wallet_transfer(
.get_balance(0)
.expect("Failed to get the balance")
.value;
let fee_0 = txs[0].payload().fee();
let fee_0 = txs[0].payload().fee;
let fee_0 = fee_0.gas_limit * fee_0.gas_price;

let final_balance_1 = wallet
.get_balance(1)
.expect("Failed to get the balance")
.value;
let fee_1 = txs[1].payload().fee();
let fee_1 = txs[1].payload().fee;
let fee_1 = fee_1.gas_limit * fee_1.gas_price;

assert!(
Expand Down
2 changes: 1 addition & 1 deletion rusk/tests/services/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn wallet_transfer(
.get_balance(0)
.expect("Failed to get the balance")
.value;
let fee = tx.inner.inner.payload().fee();
let fee = tx.inner.inner.payload().fee;
let fee = gas_spent * fee.gas_price;

assert_eq!(
Expand Down

0 comments on commit e2a2d82

Please sign in to comment.