Skip to content

Commit

Permalink
Merge pull request #843 from tonlabs/update-deps
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
mskvortsov authored Jan 24, 2023
2 parents 4e97449 + 7d345d8 commit ccfe9fd
Show file tree
Hide file tree
Showing 10 changed files with 216 additions and 263 deletions.
355 changes: 155 additions & 200 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license-file = 'LICENSE.md'
name = 'tvm_linker'
readme = 'README.md'
repository = 'https://github.com/tonlabs/TVM-linker'
version = '0.18.4'
version = '0.19.0'

[[bin]]
name = 'tvm_linker'
Expand All @@ -33,11 +33,11 @@ serde_json = '1.0.41'
sha2 = '0.10'
simplelog = '0.5.3'
serde = { features = [ 'derive' ], version = '1.0.100' }
ton_abi = { git = 'https://github.com/tonlabs/ton-labs-abi.git', tag = '2.3.7' }
ton_block = { features = [ 'gosh' ], git = 'https://github.com/tonlabs/ton-labs-block.git', tag = '1.8.3' }
ton_labs_assembler = { features = [ 'gosh' ], git = 'https://github.com/tonlabs/ton-labs-assembler.git', tag = '1.2.49' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.11.4' }
ton_vm = { features = [ 'gosh' ], git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.44' }
ton_abi = { git = 'https://github.com/tonlabs/ton-labs-abi.git', tag = '2.3.56' }
ton_block = { features = [ 'gosh' ], git = 'https://github.com/tonlabs/ton-labs-block.git', tag = '1.9.20' }
ton_labs_assembler = { features = [ 'gosh' ], git = 'https://github.com/tonlabs/ton-labs-assembler.git', tag = '1.2.76' }
ton_types = { git = 'https://github.com/tonlabs/ton-labs-types.git', tag = '1.12.6' }
ton_vm = { features = [ 'gosh' ], git = 'https://github.com/tonlabs/ton-labs-vm.git', tag = '1.8.100' }

[dev-dependencies]
assert_cmd = '2.0.5'
Expand Down
12 changes: 6 additions & 6 deletions src/disasm/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn disasm_graphviz_command(m: &ArgMatches) -> Status {
if dict.len().is_err() {
bail!("empty internal methods dictionary")
}
let key = method_id.serialize().unwrap().into();
let key = SliceData::load_cell(method_id.serialize()?)?;
let data = dict.get(key).map_err(|e| format_err!("{}", e))?
.ok_or_else(|| format_err!("internal method {} not found", method_id))?;
let cell = data.into_cell();
Expand Down Expand Up @@ -193,7 +193,7 @@ fn print_code_dict(cell: &Cell, key_size: usize) {
}
for (key, slice) in dict.iter().map(|r| r.unwrap()) {
let cell = key.into_cell().unwrap();
let id = SliceData::from(cell).get_next_int(key_size).unwrap();
let id = SliceData::load_cell(cell).unwrap().get_next_int(key_size).unwrap();
println!();
print_entrypoint(id as i32, None);
println!("{}", disasm(&mut slice.clone()));
Expand Down Expand Up @@ -223,7 +223,7 @@ fn disasm_text_command(m: &ArgMatches) -> Status {
let mut roots = deserialize_cells_tree(&mut csor).map_err(|e| format_err!("{}", e))?;

if m.is_present("RAW") {
println!("{}", disasm_ex(&mut SliceData::from(roots.get(0).unwrap()), true));
println!("{}", disasm_ex(&mut SliceData::load_cell_ref(roots.get(0).unwrap())?, true));
return Ok(())
}

Expand Down Expand Up @@ -276,13 +276,13 @@ fn disasm_text_command(m: &ArgMatches) -> Status {
print_code_dict(&assigned["dict-c3"], 32);
println!(";; internal transaction entry point");
print_entrypoint(0, Some("internal"));
println!("{}", disasm(&mut SliceData::from(&assigned["internal"])));
println!("{}", disasm(&mut SliceData::load_cell_ref(&assigned["internal"])?));
println!(";; external transaction entry point");
print_entrypoint(-1, Some("external"));
println!("{}", disasm(&mut SliceData::from(&assigned["external"])));
println!("{}", disasm(&mut SliceData::load_cell_ref(&assigned["external"])?));
println!(";; ticktock transaction entry point");
print_entrypoint(-2, Some("ticktock"));
println!("{}", disasm(&mut SliceData::from(&assigned["ticktock"])));
println!("{}", disasm(&mut SliceData::load_cell_ref(&assigned["ticktock"])?));
} else if let Ok(assigned) = shape_fun_c.captures(&code) {
println!(";; fun-c selector detected");
println!(";; internal functions dictionary");
Expand Down
10 changes: 5 additions & 5 deletions src/disasm/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl Loader {
Ok(code.clone())
}
} else {
let code = self.load(&mut SliceData::from(cell), false).unwrap_or_else(|_| {
let code = self.load(&mut SliceData::load_cell_ref(cell)?, false).unwrap_or_else(|_| {
// failed to load the cell - emit it as-is
vec!(Instruction::new(".cell").with_param(InstructionParameter::Cell { cell: cell.clone(), collapsed: false }))
});
Expand Down Expand Up @@ -1824,7 +1824,7 @@ impl DelimitedHashmapE {
}
}
for i in 0..slice.remaining_references() {
let child = SliceData::from(slice.reference(i).unwrap());
let child = SliceData::load_cell(slice.reference(i)?)?;
let mut next = path.clone();
next.push(i as u8);
if let Ok(v) = Self::locate(child, target, next) {
Expand All @@ -1834,10 +1834,10 @@ impl DelimitedHashmapE {
fail!("not found")
}
pub fn mark(&mut self) -> Result<()> {
let dict_slice = SliceData::from(self.dict.data().unwrap());
let dict_slice = SliceData::load_cell_ref(self.dict.data().unwrap())?;
for entry in self.dict.iter() {
let (key, mut slice) = entry?;
let id = SliceData::from(key).get_next_int(self.dict.bit_len())?;
let id = SliceData::load_builder(key)?.get_next_int(self.dict.bit_len())?;
let loc = Self::locate(dict_slice.clone(), &slice, vec!())?;
let mut loader = Loader::new(false);
let code = loader.load(&mut slice, true)?;
Expand All @@ -1852,7 +1852,7 @@ impl DelimitedHashmapE {
text += &format!("{}.cell ", indent);
text += &format!("{{ ;; #{}\n", cell.repr_hash().to_hex_string());
let inner_indent = String::from(" ") + indent;
let mut slice = SliceData::from(cell);
let mut slice = SliceData::load_cell_ref(cell).unwrap();
if let Some((id, offset, code)) = self.map.get(&path) {
let aux = slice.get_next_slice(*offset).unwrap();
text += &format!("{}.blob x{}\n", inner_indent, aux.to_hex_string());
Expand Down
4 changes: 2 additions & 2 deletions src/disasm/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ fn round_trip_test(filename: &str, check_bin: bool) {
let raw0 = &std::fs::read_to_string(filename).unwrap();
let bin0 = base64::decode(raw0).unwrap();
let toc0 = ton_types::deserialize_tree_of_cells(&mut std::io::Cursor::new(bin0)).unwrap();
let mut asm0 = disasm(&mut SliceData::from(toc0.clone()));
let mut asm0 = disasm(&mut SliceData::load_cell(toc0.clone()).unwrap());
let toc1 = ton_labs_assembler::compile_code_to_cell(&asm0.clone()).unwrap();
let mut asm1 = disasm(&mut SliceData::from(toc1.clone()));
let mut asm1 = disasm(&mut SliceData::load_cell(toc1.clone()).unwrap());

if !check_bin {
asm0 = cut_asm_hashes(asm0);
Expand Down
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use ton_block::{Deserializable, Message, StateInit, Serializable, Account, MsgAd
use std::io::Write;
use std::{path::Path};
use testcall::{call_contract, MsgInfo, TestCallParams, TraceLevel};
use ton_types::{BuilderData, SliceData, Result, Status, AccountId, BagOfCells, BocSerialiseMode, UInt256};
use ton_types::{SliceData, Result, Status, AccountId, BagOfCells, BocSerialiseMode, UInt256};
use std::env;
use disasm::commands::disasm_command;
use ton_labs_assembler::{Line, compile_code_to_cell};
Expand Down Expand Up @@ -223,7 +223,7 @@ fn linker_main() -> Status {
Some(data) => {
let buf = hex::decode(data).map_err(|e| format_err!("data argument has invalid format: {}", e))?;
let len = buf.len() * 8;
let body: SliceData = BuilderData::with_raw(buf, len)?.into_cell()?.into();
let body = SliceData::from_raw(buf, len);
Some(body)
},
None => {
Expand Down Expand Up @@ -502,11 +502,7 @@ fn run_test_subcmd(matches: &ArgMatches) -> Status {
.map_err(|e| format_err!("failed to resolve body {}: {}", hex_str, e))?;

let (buf, buf_bits) = decode_hex_string(resolved.text)?;
let body: SliceData = BuilderData::with_raw(buf, buf_bits)
.map_err(|e| format_err!("failed to pack body in cell: {}", e))?
.into_cell()
.map_err(|e| format_err!("failed to pack body in cell: {}", e))?
.into();
let body = SliceData::from_raw(buf, buf_bits);
(Some(body), Some(matches.value_of("SIGN")))
},
None => (build_body(matches, Some(address.to_string()))?, None),
Expand Down Expand Up @@ -647,15 +643,16 @@ fn build_body(matches: &ArgMatches, address: Option<String>) -> Result<Option<Sl
}
)?;
let is_internal = matches.is_present("INTERNAL");
let body: SliceData = build_abi_body(
let body = build_abi_body(
abi_file.unwrap(),
method_name.unwrap(),
&params,
header,
key_file,
is_internal,
address,
)?.into_cell()?.into();
)?;
let body = SliceData::load_builder(body)?;
Ok(Some(body))
} else if mask == 0 {
Ok(None)
Expand Down
6 changes: 3 additions & 3 deletions src/methdict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn prepare_methods<T>(
where
T: Clone + Default + Eq + std::fmt::Display + Serializable + std::hash::Hash,
{
let bit_len = SliceData::from(T::default().serialize().unwrap()).remaining_bits();
let bit_len = SliceData::load_cell(T::default().serialize().unwrap()).unwrap().remaining_bits();
let mut map = HashmapE::with_bit_len(bit_len);
let mut dbg = DbgInfo::default();
insert_methods(&mut map, &mut dbg, methods, adjust_entry_points)?;
Expand All @@ -39,8 +39,8 @@ where
T: Clone + Default + Eq + std::fmt::Display + Serializable + std::hash::Hash,
{
for pair in methods.iter() {
let key: SliceData = pair.0.clone().serialize()
.map_err(|e| (pair.0.clone(), format!("Failed to serialize data: {}", e)))?.into();
let key: SliceData = SliceData::load_cell(pair.0.clone().serialize()
.map_err(|e| (pair.0.clone(), format!("Failed to serialize data: {}", e)))?).unwrap();
let mut val = compile_code_debuggable(pair.1.clone()).map_err(|e| {
(pair.0.clone(), e.to_string())
})?;
Expand Down
14 changes: 8 additions & 6 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,10 @@ impl ParseEngine {
for item in data_vec {
let mut ptr = *item.0;
for subitem in item.1 {
dict.set(ptr_to_builder(ptr).unwrap().into_cell().unwrap().into(), &subitem.write().unwrap_or_default().into_cell().unwrap().into()).unwrap();
dict.set(
SliceData::load_builder(ptr_to_builder(ptr).unwrap()).unwrap(),
&SliceData::load_builder(subitem.write().unwrap_or_default()).unwrap()
).unwrap();
ptr += subitem.size();
}
}
Expand All @@ -954,15 +957,15 @@ impl ParseEngine {
globl_cell.append_bit_zero().unwrap();
}
pers_dict.set(
ptr_to_builder(self.persistent_base + OFFSET_GLOBL_DATA).unwrap().into_cell().unwrap().into(),
&globl_cell.into_cell().unwrap().into()
SliceData::load_builder(ptr_to_builder(self.persistent_base + OFFSET_GLOBL_DATA).unwrap()).unwrap(),
&SliceData::load_builder(globl_cell).unwrap()
).unwrap();

pers_dict.data().cloned()
}

fn encode_computed_cell(&self, cell: &Cell, toplevel: bool) -> Lines {
let slice = SliceData::from(cell);
let slice = SliceData::load_cell(cell.clone()).unwrap();
let mut lines = vec!();
let opening = if toplevel { "{\n" } else { ".cell {\n" };
lines.push(Line::new(opening, "", 0));
Expand Down Expand Up @@ -1142,7 +1145,6 @@ mod tests {
use ton_vm::executor::Engine;
use ton_labs_assembler::compile_code;
use ton_vm::stack::{Stack, StackItem};
use std::sync::Arc;

#[test]
fn test_parser_testlib() {
Expand Down Expand Up @@ -1233,7 +1235,7 @@ mod tests {
)).expect("Couldn't compile code");

let mut stack = Stack::new();
stack.push(StackItem::Slice(data_dict.into_cell().unwrap().into()));
stack.push(StackItem::Slice(SliceData::load_builder(data_dict).unwrap()));

let mut engine = Engine::with_capabilities(0).setup_with_libraries(
code, None, Some(stack), None, vec![]
Expand Down
31 changes: 15 additions & 16 deletions src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ impl Program {
data_dict = HashmapE::with_hashmap(64, persistent_data)
}
}
let key = ptr_to_builder(persistent_base)?.into_cell()?.into();
let key = SliceData::load_builder(ptr_to_builder(persistent_base)?)?;
let data = BuilderData::with_raw(bytes.to_vec(), PUBLIC_KEY_LENGTH * 8)?;
data_dict.set(key, &data.into_cell()?.into())
data_dict.set(key, &SliceData::load_builder(data)?)
.map_err(|e| format_err!("failed to pack pubkey to data dictionary: {}", e))?;
let mut builder = BuilderData::new();
builder
.append_bit_one().unwrap()
.checked_append_reference(data_dict.data().unwrap().clone()).unwrap();
.append_bit_one()?
.checked_append_reference(data_dict.data().unwrap().clone())?;
builder.into_cell()
}

Expand Down Expand Up @@ -166,7 +166,7 @@ impl Program {
];
let mut internal_selector = compile_code_debuggable(internal_selector_text)
.map_err(|e| format_err!("unexpected error while compiling internal selector: {}", e))?;
internal_selector.0.append_reference(self.internal_method_dict()?.unwrap_or_default().into());
internal_selector.0.append_reference(SliceData::load_cell(self.internal_method_dict()?.unwrap_or_default())?);

// adjust hash of internal_selector cell
let hash = internal_selector.0.cell().repr_hash();
Expand All @@ -176,7 +176,7 @@ impl Program {

let (mut main_selector, main_selector_dbg) = compile_code_debuggable(self.entry())
.map_err(|e| format_err!("unexpected error while compiling main selector: {}", e))?;
main_selector.append_reference(self.public_method_dict(remove_ctor)?.unwrap_or_default().into());
main_selector.append_reference(SliceData::load_cell(self.public_method_dict(remove_ctor)?.unwrap_or_default())?);
main_selector.append_reference(internal_selector.0);

// adjust hash of main_selector cell
Expand Down Expand Up @@ -215,13 +215,12 @@ impl Program {

let mut entry_points = vec![];
for id in -2..1i32 {
let key = id.serialize()?
.into();
let value = dict.0.remove(key).unwrap();
let key = SliceData::load_cell(id.serialize()?)?;
let value = dict.0.remove(key)?;
entry_points.push(value.unwrap_or_default());
}

internal_selector.0.append_reference(SliceData::from(dict.0.data().unwrap_or(&Cell::default())));
internal_selector.0.append_reference(SliceData::load_cell(dict.0.data().cloned().unwrap_or_default())?);
self.dbgmap.append(&mut dict.1);

let version = self.engine.version();
Expand Down Expand Up @@ -356,7 +355,7 @@ pub fn load_from_file(contract_file: &str) -> Result<StateInit> {
// try appending a dummy library cell if there is no such cell in the tvc file
if cell.references_count() == 2 {
let mut adjusted_cell = BuilderData::from(cell);
adjusted_cell.append_reference(BuilderData::default());
adjusted_cell.checked_append_reference(Cell::default())?;
cell = adjusted_cell.into_cell()?;
}
StateInit::construct_from_cell(cell)
Expand All @@ -372,10 +371,10 @@ pub fn load_stateinit(file_name: &str) -> Result<(SliceData, Vec<u8>)> {
let mut root = root_cells[0].clone();
if root.references_count() == 2 { // append empty library cell
let mut adjusted_cell = BuilderData::from(root);
adjusted_cell.append_reference(BuilderData::default());
adjusted_cell.checked_append_reference(Cell::default())?;
root = adjusted_cell.into_cell()?;
}
Ok((SliceData::from(root), orig_bytes))
Ok((SliceData::load_cell(root)?, orig_bytes))
}

pub fn get_now() -> u32 {
Expand Down Expand Up @@ -528,7 +527,7 @@ mod tests {
src: None,
now: 1,
bounced: false,
body: Some(body.into_cell().unwrap().into())
body: Some(SliceData::load_builder(body).unwrap())
},
None,
None,
Expand Down Expand Up @@ -574,7 +573,7 @@ mod tests {
src: None,
now: 1,
bounced: false,
body: Some(body.into_cell().unwrap().into())
body: Some(SliceData::load_builder(body).unwrap())
},
None,
None,
Expand Down Expand Up @@ -633,7 +632,7 @@ mod tests {
src: None,
now: 1,
bounced: false,
body: Some(body.into_cell().unwrap().into())
body: Some(SliceData::load_builder(body).unwrap())
},
None,
None,
Expand Down
Loading

0 comments on commit ccfe9fd

Please sign in to comment.