Skip to content

Commit

Permalink
refactor: dr_binary_id -> exec_program_id, tally_binary_id -> tally_p…
Browse files Browse the repository at this point in the history
…rogram_id
  • Loading branch information
gluax committed Oct 1, 2024
1 parent b38164d commit 493586f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions contract/src/msgs/data_requests/execute/post_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ impl ExecuteHandler for execute::post_request::Execute {
.set_data(to_json_binary(&hex_dr_id)?)
.add_event(Event::new("seda-data-request").add_attributes([
("dr_id", hex_dr_id.clone()),
("dr_binary_id", self.posted_dr.dr_binary_id.clone()),
("exec_program_id", self.posted_dr.exec_program_id.clone()),
("dr_inputs", self.posted_dr.dr_inputs.to_base64()),
("tally_binary_id", self.posted_dr.tally_binary_id.clone()),
("tally_program_id", self.posted_dr.tally_program_id.clone()),
("tally_inputs", self.posted_dr.tally_inputs.to_base64()),
("replication_factor", self.posted_dr.replication_factor.to_string()),
("consensus_filter", self.posted_dr.consensus_filter.to_base64()),
Expand All @@ -50,9 +50,9 @@ impl ExecuteHandler for execute::post_request::Execute {
let dr = DataRequest {
id: hex_dr_id,
version: self.posted_dr.version,
dr_binary_id: self.posted_dr.dr_binary_id,
exec_program_id: self.posted_dr.exec_program_id,
dr_inputs: self.posted_dr.dr_inputs,
tally_binary_id: self.posted_dr.tally_binary_id,
tally_program_id: self.posted_dr.tally_program_id,
tally_inputs: self.posted_dr.tally_inputs,
replication_factor: self.posted_dr.replication_factor,
consensus_filter: self.posted_dr.consensus_filter,
Expand Down
12 changes: 6 additions & 6 deletions contract/src/msgs/data_requests/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use super::{
use crate::{TestExecutor, TestInfo};

pub fn calculate_dr_id_and_args(nonce: u128, replication_factor: u16) -> PostDataRequestArgs {
let dr_binary_id = nonce.to_string().hash().to_hex();
let tally_binary_id = "tally_binary_id".hash().to_hex();
let exec_program_id = nonce.to_string().hash().to_hex();
let tally_program_id = "tally_program_id".hash().to_hex();
let dr_inputs = "dr_inputs".as_bytes().into();
let tally_inputs = "tally_inputs".as_bytes().into();

Expand All @@ -39,8 +39,8 @@ pub fn calculate_dr_id_and_args(nonce: u128, replication_factor: u16) -> PostDat

PostDataRequestArgs {
version,
dr_binary_id,
tally_binary_id,
exec_program_id,
tally_program_id,
dr_inputs,
tally_inputs,
memo: memo.as_slice().into(),
Expand All @@ -65,8 +65,8 @@ pub fn construct_dr(dr_args: PostDataRequestArgs, seda_payload: Vec<u8>, height:
DataRequest {
version,
id: dr_id.to_hex(),
dr_binary_id: dr_args.dr_binary_id,
tally_binary_id: dr_args.tally_binary_id,
exec_program_id: dr_args.exec_program_id,
tally_program_id: dr_args.tally_program_id,
dr_inputs: dr_args.dr_inputs,
tally_inputs: dr_args.tally_inputs,
memo: dr_args.memo,
Expand Down
10 changes: 5 additions & 5 deletions contract/src/msgs/data_requests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,17 +822,17 @@ fn check_data_request_id() {
// Expected DR ID for following DR:
// {
// "version": "0.0.1",
// "dr_binary_id": "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d",
// "exec_program_id": "044852b2a670ade5407e78fb2863c51de9fcb96542a07186fe3aeda6bb8a116d",
// "dr_inputs": "ZHJfaW5wdXRz",
// "tally_binary_id": "3a1561a3d854e446801b339c137f87dbd2238f481449c00d3470cfcc2a4e24a1",
// "tally_program_id": "3a1561a3d854e446801b339c137f87dbd2238f481449c00d3470cfcc2a4e24a1",
// "tally_inputs": "dGFsbHlfaW5wdXRz",
// "replication_factor": 1,
// "consensus_filter": "AA==",
// "gas_price": 10,
// "gas_limit": 10,
// "memo": "XTtTqpLgvyGr54/+ov83JyG852lp7VqzBrC10UpsIjg="
// }
let expected_dr_id = "ac63c09c88c23eeffce331f6ee993d172eaeffe88169edc04698092b86bd9f0d";
let expected_dr_id = "2399c8b5ea3cea169496647e3ec54edbad9e920c567b650272115afb89d6b6b1";

// compute and check if dr id matches expected value
let dr = test_helpers::calculate_dr_id_and_args(0, 1);
Expand All @@ -845,7 +845,7 @@ fn check_data_result_id() {
// Expected RESULT ID for the following Data Result:
// {
// "version": "0.0.1",
// "dr_id": "264b76bd166a8997c141a4b4b673b2cb5c90bfe313258a4083aaac1dd04e39c1",
// "dr_id": "74d7e8c9a77b7b4777153a32fcdf2424489f24cd59d3043eb2a30be7bba48306",
// "consensus": true,
// "exit_code": 0,
// "result": "Ghkvq84TmIuEmU1ClubNxBjVXi8df5QhiNQEC5T8V6w=",
Expand All @@ -854,7 +854,7 @@ fn check_data_result_id() {
// "payback_address": "",
// "seda_payload": ""
// }
let expected_result_id = "6b0ba1d7e6b1dbddb85c8dfc66ce2f4973b7ca94d5fd3d24f3122526853ab8db";
let expected_result_id = "74d7e8c9a77b7b4777153a32fcdf2424489f24cd59d3043eb2a30be7bba48306";
let dr_args = test_helpers::calculate_dr_id_and_args(0, 1);

// reveal sample
Expand Down
16 changes: 8 additions & 8 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ fn wasm_opt(sh: &Shell) -> Result<()> {

fn create_data_request(
id: [u8; 32],
dr_binary_id: [u8; 32],
tally_binary_id: [u8; 32],
exec_program_id: [u8; 32],
tally_program_id: [u8; 32],
replication_factor: u16,
tally_inputs: Vec<u8>,
reveals: HashMap<String, RevealBody>,
Expand All @@ -91,8 +91,8 @@ fn create_data_request(
build: semver::BuildMetadata::EMPTY,
},
id: id.to_hex(),
dr_binary_id: dr_binary_id.to_hex(),
tally_binary_id: tally_binary_id.to_hex(),
exec_program_id: exec_program_id.to_hex(),
tally_program_id: tally_program_id.to_hex(),
dr_inputs: Default::default(),
tally_inputs: tally_inputs.into(),
memo: Default::default(),
Expand All @@ -109,8 +109,8 @@ fn create_data_request(
}

fn tally_test_fixture(n: usize) -> Vec<DataRequest> {
let dr_binary_id: [u8; 32] = rand::random();
let tally_binary_id: [u8; 32] = rand::random();
let exec_program_id: [u8; 32] = rand::random();
let tally_program_id: [u8; 32] = rand::random();

(0..n)
.map(|_| {
Expand Down Expand Up @@ -146,8 +146,8 @@ fn tally_test_fixture(n: usize) -> Vec<DataRequest> {

create_data_request(
dr_id,
dr_binary_id,
tally_binary_id,
exec_program_id,
tally_program_id,
replication_factor,
inputs,
reveals,
Expand Down

0 comments on commit 493586f

Please sign in to comment.