Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gh-1554] upgrade rust version and fix syntax errors. #1555

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/actions/rust-setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ runs:
- name: install protoc and related tools
shell: bash
run: scripts/dev_setup.sh -b -r


10 changes: 5 additions & 5 deletions crates/data_verify/src/brc20_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn process_indexer_entry(
Some(availablebalance),
Some(transferablebalance),
) = (
columns.get(0),
columns.first(),
columns.get(1),
columns.get(3),
columns.get(4),
Expand Down Expand Up @@ -322,7 +322,7 @@ fn update_coin_tsv(config: &DataConfig, tick_str: &str, amt_numeric: i32) -> Res
let line = line_result?;
let mut columns: Vec<&str> = line.split('\t').collect();

if let Some(existing_tick) = columns.get(0) {
if let Some(existing_tick) = columns.first() {
if existing_tick == &tick_str {
if let Some(leftforsupply) = columns.get_mut(1) {
let leftforsupply_numeric: i32 = leftforsupply.parse().unwrap_or_default();
Expand Down Expand Up @@ -351,7 +351,7 @@ fn read_coin_tsv(config: &DataConfig, name: &str) -> Result<(String, String)> {
let columns: Vec<&str> = line.split('\t').collect();

// Assuming the format is name, leftforsupply, limit, id
if let Some(existing_name) = columns.get(0) {
if let Some(existing_name) = columns.first() {
if existing_name == &name {
if let (Some(leftforsupply), Some(limit)) = (columns.get(1), columns.get(2)) {
return Ok((leftforsupply.to_string(), limit.to_string()));
Expand All @@ -378,7 +378,7 @@ fn tick_exists_in_coin_tsv(config: &DataConfig, tick: &str) -> Result<bool> {
for line_result in reader.lines() {
let line = line_result?;
let columns: Vec<&str> = line.split('\t').collect();
if let Some(existing_tick) = columns.get(0) {
if let Some(existing_tick) = columns.first() {
if existing_tick == &tick {
return Ok(true);
}
Expand All @@ -400,7 +400,7 @@ fn inscription_id_exists_in_failinscription_tsv(config: &DataConfig, txid: &str)
for line_result in reader.lines() {
let line = line_result?;
let columns: Vec<&str> = line.split('\t').collect();
if let Some(existing_txid) = columns.get(0) {
if let Some(existing_txid) = columns.first() {
// let iid = ("{}i0",txid);
if existing_txid == &format!("{}i0", txid) {
return Ok(true);
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-benchmarks/benches/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn bcs_serialized_size_benchmark(c: &mut Criterion) {
let l1_block = L1Block::default();
let mut group = c.benchmark_group("bcs_serialized_size");

let funcs = vec![
let funcs = [
BcsSerializeSizeFunContainer {
func: serialized_size,
name: "serialized_size",
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-benchmarks/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub fn create_btc_blk_tx(height: u64, block_file: String) -> Result<L1BlockWithB
let origin_block: Block = deserialize(&block_hex).unwrap();
let block = origin_block.clone();
let block_hash = block.header.block_hash();
let move_block = rooch_types::bitcoin::types::Block::try_from(block.clone()).unwrap();
let move_block = rooch_types::bitcoin::types::Block::from(block.clone());
Ok(L1BlockWithBody {
block: rooch_types::transaction::L1Block {
chain_id: RoochMultiChainID::Bitcoin.multichain_id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn test_submit_block() {
let bitcoin_txdata = block.txdata.clone();
let block_hash = block.header.block_hash();
let block_header: Header = block.header.into();
let move_block = rooch_types::bitcoin::types::Block::try_from(block.clone()).unwrap();
let move_block = rooch_types::bitcoin::types::Block::from(block.clone());

binding_test
.execute_l1_block(L1BlockWithBody {
Expand Down Expand Up @@ -100,7 +100,7 @@ fn test_utxo_progress() {
let height = 818677u64;
let block: Block = deserialize(&btc_block_bytes).unwrap();
let block_hash = block.header.block_hash();
let move_block = rooch_types::bitcoin::types::Block::try_from(block.clone()).unwrap();
let move_block = rooch_types::bitcoin::types::Block::from(block.clone());

binding_test
.execute_l1_block(L1BlockWithBody {
Expand Down
1 change: 0 additions & 1 deletion crates/rooch-key/src/keystore/memory_keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ impl InMemKeystore {
pub fn new_insecure_for_tests(initial_key_number: usize) -> Self {
let keys = (0..initial_key_number)
.map(|_| get_key_pair_from_red())
.map(|(addr, data)| (addr, data))
.collect::<BTreeMap<RoochAddress, EncryptionData>>();

Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-relayer/src/actor/bitcoin_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl BitcoinRelayer {
debug!("GetBlockHeaderResult: {:?}", block_result);

let block_height = block_result.header_info.height;
let block_body = rooch_types::bitcoin::types::Block::try_from(block_result.block)?;
let block_body = rooch_types::bitcoin::types::Block::from(block_result.block);

Ok(Some(L1BlockWithBody {
block: L1Block {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl<'a> AuthenticationKeyModule<'a> {
.call_function(&ctx, call)?
.into_result()
.map(|values| {
let value = values.get(0).expect("Expected return value");
let value = values.first().expect("Expected return value");
let result = MoveOption::<Vec<u8>>::from_bytes(&value.value)
.expect("Expected Option<address>");
result.into()
Expand Down
2 changes: 1 addition & 1 deletion crates/rooch-types/src/framework/account_coin_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a> AccountCoinStoreModule<'a> {
.call_function(&ctx, call)?
.into_result()
.map_err(|e| anyhow::anyhow!("Call coin store handle error:{}", e))?;
let object_id = match result.get(0) {
let object_id = match result.first() {
Some(value) => {
let object_id_result = MoveOption::<ObjectID>::from_bytes(&value.value)?;
Option::<ObjectID>::from(object_id_result)
Expand Down
6 changes: 3 additions & 3 deletions crates/rooch-types/src/framework/address_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<'a> AddressMapping<'a> {
.call_function(&ctx, call)?
.into_result()
.map(|values| {
let value = values.get(0).expect("Expected return value");
let value = values.first().expect("Expected return value");
let result = MoveOption::<AccountAddress>::from_bytes(&value.value)
.expect("Expected Option<address>");
result.into()
Expand Down Expand Up @@ -69,7 +69,7 @@ impl<'a> AddressMapping<'a> {
.call_function(&ctx, call)?
.into_result()
.map(|values| {
let value = values.get(0).expect("Expected return value");
let value = values.first().expect("Expected return value");
AccountAddress::from_bytes(&value.value).expect("Expected return address")
})?;
Ok(address)
Expand All @@ -89,7 +89,7 @@ impl<'a> AddressMapping<'a> {
.call_function(&ctx, call)?
.into_result()
.map(|values| {
let value0 = values.get(0).ok_or(anyhow::anyhow!(
let value0 = values.first().ok_or(anyhow::anyhow!(
"Address mapping handle expected return value"
))?;
let value1 = values.get(1).ok_or(anyhow::anyhow!(
Expand Down
2 changes: 1 addition & 1 deletion crates/testsuite/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ async fn assert_output(world: &mut World, orginal_args: String) {
orginal_args
);
for chunk in splited_args.chunks(3) {
let first = chunk.get(0).cloned();
let first = chunk.first().cloned();
let op = chunk.get(1).cloned();
let second = chunk.get(2).cloned();

Expand Down
27 changes: 27 additions & 0 deletions frameworks/bitcoin-move/doc/utxo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- [Resource `UTXO`](#0x4_utxo_UTXO)
- [Struct `UTXOSeal`](#0x4_utxo_UTXOSeal)
- [Resource `BitcoinUTXOStore`](#0x4_utxo_BitcoinUTXOStore)
- [Struct `CreatingUTXOEvent`](#0x4_utxo_CreatingUTXOEvent)
- [Struct `RemovingUTXOEvent`](#0x4_utxo_RemovingUTXOEvent)
- [Struct `TempState`](#0x4_utxo_TempState)
- [Constants](#@Constants_0)
- [Function `genesis_init`](#0x4_utxo_genesis_init)
Expand Down Expand Up @@ -41,6 +43,7 @@

<pre><code><b>use</b> <a href="">0x1::string</a>;
<b>use</b> <a href="">0x2::bag</a>;
<b>use</b> <a href="">0x2::event</a>;
<b>use</b> <a href="">0x2::object</a>;
<b>use</b> <a href="">0x2::simple_multimap</a>;
<b>use</b> <a href="">0x2::type_info</a>;
Expand Down Expand Up @@ -83,6 +86,30 @@ The UTXO Object



<a name="0x4_utxo_CreatingUTXOEvent"></a>

## Struct `CreatingUTXOEvent`

Event for creating UTXO


<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_CreatingUTXOEvent">CreatingUTXOEvent</a> <b>has</b> drop, store
</code></pre>



<a name="0x4_utxo_RemovingUTXOEvent"></a>

## Struct `RemovingUTXOEvent`

Event for remove UTXO


<pre><code><b>struct</b> <a href="utxo.md#0x4_utxo_RemovingUTXOEvent">RemovingUTXOEvent</a> <b>has</b> drop, store
</code></pre>



<a name="0x4_utxo_TempState"></a>

## Struct `TempState`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn native_execute_wasm_function(

match calling_function.call(&mut instance.store, wasm_func_args.as_slice()) {
Ok(ret) => {
let return_value = match ret.deref().get(0) {
let return_value = match ret.deref().first() {
Some(v) => v,
None => {
return build_err(
Expand Down
2 changes: 1 addition & 1 deletion moveos/moveos-store/src/tests/test_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn test_event_store() {
let event_ids = store.save_events(tx_events.clone()).unwrap();
assert_eq!(event_ids.len(), 2);
let event0 = store
.get_event(event_ids.get(0).cloned().unwrap())
.get_event(event_ids.first().cloned().unwrap())
.unwrap()
.unwrap();
assert_eq!(event0.event_type, tx_events[0].event_type);
Expand Down
2 changes: 1 addition & 1 deletion moveos/moveos-types/src/moveos_std/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a> EventModule<'a> {
.into_result()
.map_err(|e| anyhow::anyhow!("Call get event handle error:{}", e))?;

let event_handle_id = match result.get(0) {
let event_handle_id = match result.first() {
Some(value) => bcs::from_bytes::<ObjectID>(&value.value)?,
None => return Err(anyhow::anyhow!("Event handle should have event handle id")),
};
Expand Down
2 changes: 1 addition & 1 deletion moveos/moveos-types/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ impl State {
) {
let object_type_param = struct_tag
.type_params
.get(0)
.first()
.expect("The ObjectEntity<T> should have a type param");
match object_type_param {
TypeTag::Struct(struct_tag) => Some(struct_tag.as_ref().clone()),
Expand Down
6 changes: 3 additions & 3 deletions moveos/moveos-verifier/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ fn check_data_struct_func(extended_checker: &mut ExtendedChecker, module_env: &M
// So we need to skip inline functions.
continue;
}
for (_offset, instr) in fun.get_bytecode().unwrap().iter().enumerate() {
for instr in fun.get_bytecode().unwrap().iter() {
if let Bytecode::CallGeneric(finst_idx) = instr {
let FunctionInstantiation {
handle,
Expand Down Expand Up @@ -1392,7 +1392,7 @@ fn check_gas_validate_function(fenv: &FunctionEnv, _global_env: &GlobalEnv) -> (
//TODO FIXME

// Length of the return_types array has already been checked above, so unwrap directly here.
let first_return_type = return_types.get(0).unwrap();
let first_return_type = return_types.first().unwrap();
match first_return_type {
Type::Primitive(PrimitiveType::Bool) => (true, "".to_string()),
_ => (false, "Return type must be of type Bool.".to_string()),
Expand Down Expand Up @@ -1431,7 +1431,7 @@ fn check_gas_charge_post_function(fenv: &FunctionEnv, _global_env: &GlobalEnv) -
}

// Length of the return_types array has already been checked above, so unwrap directly here.
let first_return_type = return_types.get(0).unwrap();
let first_return_type = return_types.first().unwrap();
match first_return_type {
Type::Primitive(PrimitiveType::Bool) => (true, "".to_string()),
_ => (false, "Return type must be of type Bool.".to_string()),
Expand Down
8 changes: 4 additions & 4 deletions moveos/moveos-verifier/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ fn check_gas_validate_function(
return_signature: &Signature,
) -> bool {
// Content of the func_signature array has already been checked above, so unwrap directly here.
let first_parameter = func_signature.0.get(0).unwrap();
let first_parameter = func_signature.0.first().unwrap();

let check_struct_type = |_struct_handle_idx: &StructHandleIndex| -> bool {
//TODO FIXME
Expand All @@ -883,7 +883,7 @@ fn check_gas_validate_function(
}

// Content of the return_signature array has already been checked above, so unwrap directly here.
let first_return_signature = return_signature.0.get(0).unwrap();
let first_return_signature = return_signature.0.first().unwrap();
matches!(first_return_signature, SignatureToken::Bool)
}

Expand All @@ -893,7 +893,7 @@ fn check_gas_charge_post_function(
return_signature: &Signature,
) -> bool {
// Content of the func_signature array has already been checked above, so unwrap directly here.
let first_parameter = func_signature.0.get(0).unwrap();
let first_parameter = func_signature.0.first().unwrap();

let check_struct_type = |_struct_handle_idx: &StructHandleIndex| -> bool {
//TODO FIXME
Expand Down Expand Up @@ -928,7 +928,7 @@ fn check_gas_charge_post_function(
}

// Content of the return_signature array has already been checked above, so unwrap directly here.
let first_return_signature = return_signature.0.get(0).unwrap();
let first_return_signature = return_signature.0.first().unwrap();
matches!(first_return_signature, SignatureToken::Bool)
}

Expand Down
2 changes: 1 addition & 1 deletion moveos/moveos-wasm/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn put_data_on_stack(stack_alloc_func: &Function, store: &mut Store, data: &
.expect("call stackAlloc failed");
let return_value = result
.deref()
.get(0)
.first()
.expect("the stackAlloc func does not have return value");
let offset = return_value
.i32()
Expand Down
4 changes: 2 additions & 2 deletions moveos/moveos/src/gas/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ pub fn get_gas_schedule_entries<Resolver: MoveOSResolver>(
match field_value {
AnnotatedMoveValue::Struct(gas_entries_struct) => {
let (_, gas_entry_key) =
gas_entries_struct.value.get(0).unwrap();
gas_entries_struct.value.first().unwrap();
let (_, gas_entry_value) =
gas_entries_struct.value.get(1).unwrap();

Expand Down Expand Up @@ -1467,7 +1467,7 @@ fn extract_bytes_from_value(value: &AnnotatedMoveValue) -> Option<Vec<u8>> {
match value {
AnnotatedMoveValue::Bytes(v) => Some(v.clone()),
AnnotatedMoveValue::Struct(v) => {
let (_, item) = v.value.get(0).unwrap();
let (_, item) = v.value.first().unwrap();
match item {
AnnotatedMoveValue::Bytes(value) => Some(value.clone()),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion moveos/moveos/src/vm/tx_argument_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn get_object_type(type_tag: &TypeTag) -> Option<TypeTag> {
match type_tag {
TypeTag::Struct(s) => {
if is_object_struct(s) {
s.type_params.get(0).cloned()
s.type_params.first().cloned()
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion moveos/smt/src/jellyfish_merkle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ where
blob_sets: Vec<Vec<(SMTObject<K>, Option<SMTObject<V>>)>>,
) -> Result<(Vec<HashValue>, TreeUpdateBatch<K, V>)> {
let mut tree_cache = TreeCache::new(self.reader, state_root_hash);
for (_idx, blob_set) in blob_sets.into_iter().enumerate() {
for blob_set in blob_sets.into_iter() {
assert!(
!blob_set.is_empty(),
"Transactions that output empty write set should not be included.",
Expand Down
2 changes: 1 addition & 1 deletion moveos/smt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ where
let iter = self.iter(state_root, None)?;

let mut data = Vec::new();
for (_data_size, item) in iter.enumerate() {
for item in iter {
let (k, v) = item?;
data.push((k, v));
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.74.0
1.77.1
Loading