diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml index d6dffe23..d1f2d17e 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/build-and-test.yaml @@ -6,7 +6,7 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - + jobs: code-quality: name: 'Code Quality Checks' diff --git a/kllvm/ulm.k b/kllvm/ulm.k index 50704233..eb94ee0e 100644 --- a/kllvm/ulm.k +++ b/kllvm/ulm.k @@ -62,7 +62,7 @@ module ULM-HOOKS | "EVMC_FAILURE" [function] | "EVMC_INVALID_INSTRUCTION" [function] | "EVMC_UNDEFINED_INSTRUCTION" [function] - | "EVMC_OUT_OF_GAS" [function] + | "EVMC_OUT_OF_GAS" [function] | "EVMC_BAD_JUMP_DESTINATION" [function] | "EVMC_STACK_OVERFLOW" [function] | "EVMC_STACK_UNDERFLOW" [function] diff --git a/rust-semantics/execution/let.md b/rust-semantics/execution/let.md index 6e990bbe..714b9543 100644 --- a/rust-semantics/execution/let.md +++ b/rust-semantics/execution/let.md @@ -48,23 +48,23 @@ module RUST-LET Values:Map => Values[NextId <- V] requires notBool mayBeDefaultTypedInt(V) - // Handling tuple assignments + // Handling tuple assignments rule - let (Variable:PatternNoTopAlt | .PatternNoTopAlts , RemainingToAssign:Patterns):TuplePattern - = ptrValue(_,tuple(Val:Value, ValList:ValueList)) ; + let (Variable:PatternNoTopAlt | .PatternNoTopAlts , RemainingToAssign:Patterns):TuplePattern + = ptrValue(_,tuple(Val:Value, ValList:ValueList)) ; => - let Variable = ptrValue(null, Val); - ~> let (RemainingToAssign:Patterns:TuplePatternItems):TuplePattern + let Variable = ptrValue(null, Val); + ~> let (RemainingToAssign:Patterns:TuplePatternItems):TuplePattern = ptrValue(null, tuple(ValList)); - + rule - let (.Patterns):TuplePattern = ptrValue(_,tuple(.ValueList)); + let (.Patterns):TuplePattern = ptrValue(_,tuple(.ValueList)); => .K - + // Handles the case where the tuple pattern on the let expression has an extra comma, removing it rule - let (Ps:Patterns,):TuplePattern = V:PtrValue; + let (Ps:Patterns,):TuplePattern = V:PtrValue; => let (Ps):TuplePattern = V; diff --git a/rust-semantics/expression/integer-operations.md b/rust-semantics/expression/integer-operations.md index 86405d76..21d488fd 100644 --- a/rust-semantics/expression/integer-operations.md +++ b/rust-semantics/expression/integer-operations.md @@ -10,7 +10,7 @@ module RUST-INTEGER-ARITHMETIC-OPERATIONS imports private RUST-SHARED-SYNTAX imports private RUST-REPRESENTATION - // Operations are implemented only for the same types, + // Operations are implemented only for the same types, // as implicit type casting (coercion) is not available // in Rust. @@ -69,7 +69,7 @@ module RUST-INTEGER-ARITHMETIC-OPERATIONS requires B =/=K 0p64 rule ptrValue(_, i64(A):Value) % ptrValue(_, i64(B):Value) => ptrValue(null, i64(A %sMInt B)) requires B =/=K 0p64 - + rule ptrValue(_, u64(A):Value) * ptrValue(_, u64(B):Value) => ptrValue(null, u64(A *MInt B)) rule ptrValue(_, u64(A):Value) + ptrValue(_, u64(B):Value) => ptrValue(null, u64(A +MInt B)) rule ptrValue(_, u64(A):Value) - ptrValue(_, u64(B):Value) => ptrValue(null, u64(A -MInt B)) diff --git a/rust-semantics/expression/loops.md b/rust-semantics/expression/loops.md index 766d2c0c..af593065 100644 --- a/rust-semantics/expression/loops.md +++ b/rust-semantics/expression/loops.md @@ -7,24 +7,24 @@ module RUST-LOOP-EXPRESSIONS syntax IteratorLoopExpression ::= "for1" Pattern "limit" PtrValue BlockExpression | "for2" Pattern "limit" PtrValue BlockExpression - rule for Patt:Identifier:PatternNoTopAlt | R:PatternNoTopAlts in ptrValue(_, intRange(First, Last)) B:BlockExpression => + rule for Patt:Identifier:PatternNoTopAlt | R:PatternNoTopAlts in ptrValue(_, intRange(First, Last)) B:BlockExpression => { .InnerAttributes let Patt = ptrValue(null, First); - (for1 Patt | R limit ptrValue(null, Last) B):IteratorLoopExpression; + (for1 Patt | R limit ptrValue(null, Last) B):IteratorLoopExpression; .NonEmptyStatements }; requires checkIntOfSameType(First, Last) - rule for1 Patt:Identifier:PatternNoTopAlt | .PatternNoTopAlts limit Last B:BlockExpression => - if (Patt :: .PathExprSegments):PathExprSegments < Last - { - .InnerAttributes B; - (for2 Patt | .PatternNoTopAlts limit Last B):IteratorLoopExpression; + rule for1 Patt:Identifier:PatternNoTopAlt | .PatternNoTopAlts limit Last B:BlockExpression => + if (Patt :: .PathExprSegments):PathExprSegments < Last + { + .InnerAttributes B; + (for2 Patt | .PatternNoTopAlts limit Last B):IteratorLoopExpression; .NonEmptyStatements }; - - rule for2 Patt:Identifier:PatternNoTopAlt | .PatternNoTopAlts limit ptrValue(_, LastValue) #as Last B:BlockExpression => + + rule for2 Patt:Identifier:PatternNoTopAlt | .PatternNoTopAlts limit ptrValue(_, LastValue) #as Last B:BlockExpression => incrementPatt(Patt, LastValue) ~> for1 Patt:Identifier:PatternNoTopAlt | .PatternNoTopAlts limit Last B rule while (E:ExpressionExceptStructExpression) S:BlockExpression => if E { .InnerAttributes S; while(E)S; .NonEmptyStatements}; diff --git a/rust-semantics/expression/struct.md b/rust-semantics/expression/struct.md index 48242ecc..b5c267ac 100644 --- a/rust-semantics/expression/struct.md +++ b/rust-semantics/expression/struct.md @@ -16,70 +16,70 @@ module RUST-EXPRESSION-STRUCT | fromStructExpressionWithAssignmentsBuildFieldsMap(TypePath, StructExprFields, Map) // From Struct Expression to struct(P, F). Case 1, field names are not given: - rule - I:TypePath { L:StructBases } => fromStructExpressionWithLiteralsBuildFieldsMap(I, L, VL, .Map) - ... + rule + I:TypePath { L:StructBases } => fromStructExpressionWithLiteralsBuildFieldsMap(I, L, VL, .Map) + ... I VL - + rule fromStructExpressionWithLiteralsBuildFieldsMap(I:TypePath, (E:Expression, RL):StructBases, FieldNameList:List, FieldsMap:Map) - => E ~> fromStructExpressionWithLiteralsBuildFieldsMap(I, RL, FieldNameList, FieldsMap) ... + => E ~> fromStructExpressionWithLiteralsBuildFieldsMap(I, RL, FieldNameList, FieldsMap) ... - rule - - ptrValue(_, V:Value):PtrValue ~> + rule + + ptrValue(_, V:Value):PtrValue ~> fromStructExpressionWithLiteralsBuildFieldsMap( - I:TypePath, - RL:StructBases, - (FieldNameList):List ListItem(FieldName), + I:TypePath, + RL:StructBases, + (FieldNameList):List ListItem(FieldName), FieldsMap:Map) - => fromStructExpressionWithLiteralsBuildFieldsMap(I, RL, FieldNameList, FieldsMap (FieldName |-> NVI):Map ) - ... + => fromStructExpressionWithLiteralsBuildFieldsMap(I, RL, FieldNameList, FieldsMap (FieldName |-> NVI):Map ) + ... VALUES:Map => VALUES[NVI <- V] NVI:Int => NVI +Int 1 - requires notBool (FieldName in_keys(FieldsMap)) + requires notBool (FieldName in_keys(FieldsMap)) - rule - fromStructExpressionWithLiteralsBuildFieldsMap(I:TypePath, .StructBases, .List, FieldsMap:Map) - => struct(I, FieldsMap) - ... + rule + fromStructExpressionWithLiteralsBuildFieldsMap(I:TypePath, .StructBases, .List, FieldsMap:Map) + => struct(I, FieldsMap) + ... // From Struct Expression to struct(P, F). Case 2, field names are given: - rule - I:TypePath { S:MaybeStructExprFieldsOrStructBase } => fromStructExpressionWithAssignmentsBuildFieldsMap(I, S, .Map) - ... + rule + I:TypePath { S:MaybeStructExprFieldsOrStructBase } => fromStructExpressionWithAssignmentsBuildFieldsMap(I, S, .Map) + ... - rule + rule fromStructExpressionWithAssignmentsBuildFieldsMap( - Name:TypePath, + Name:TypePath, ((FieldName:Identifier : Le:Expression):StructExprField, RS):StructExprFields, FieldsMap:Map) => Le ~> FieldName ~> fromStructExpressionWithAssignmentsBuildFieldsMap(Name, RS, FieldsMap) ... - rule + rule ptrValue(_, V:Value):PtrValue ~> FieldName:Identifier ~> fromStructExpressionWithAssignmentsBuildFieldsMap( - Name:TypePath, + Name:TypePath, RS:StructExprFields, FieldsMap:Map ) => fromStructExpressionWithAssignmentsBuildFieldsMap( Name, RS, FieldsMap (FieldName |-> NVI):Map ) - ... + ... VALUES:Map => VALUES[NVI <- V] NVI:Int => NVI +Int 1 rule fromStructExpressionWithAssignmentsBuildFieldsMap( - Name:TypePath, + Name:TypePath, .StructExprFields, FieldsMap:Map ) => struct(Name, FieldsMap) diff --git a/rust-semantics/preprocessing/initialization.md b/rust-semantics/preprocessing/initialization.md index 6ba1301f..f00f9b5d 100644 --- a/rust-semantics/preprocessing/initialization.md +++ b/rust-semantics/preprocessing/initialization.md @@ -20,9 +20,9 @@ module INITIALIZATION ... - + rule - structParser(Name:TypePath, ((FN:Identifier : FT:Type):StructField , RF:StructFields):StructFields) => + structParser(Name:TypePath, ((FN:Identifier : FT:Type):StructField , RF:StructFields):StructFields) => structParser(Name:TypePath, RF:StructFields) ... @@ -38,7 +38,7 @@ module INITIALIZATION ... - + rule structParser(_Name:TypePath, .StructFields) => .K diff --git a/rust-semantics/representation.md b/rust-semantics/representation.md index 504e2993..0a196371 100644 --- a/rust-semantics/representation.md +++ b/rust-semantics/representation.md @@ -163,11 +163,11 @@ module RUST-REPRESENTATION rule checkIntOfType(u256(_), u256) => true rule checkIntOfType(_, _) => false [owise] - rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u8) requires checkIntOfType(B, u8) + rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u8) requires checkIntOfType(B, u8) rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, i8) requires checkIntOfType(B, i8) - rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u16) requires checkIntOfType(B, u16) + rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u16) requires checkIntOfType(B, u16) rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, i16) requires checkIntOfType(B, i16) - rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u32) requires checkIntOfType(B, u32) + rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u32) requires checkIntOfType(B, u32) rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, i32) requires checkIntOfType(B, i32) rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, u64) requires checkIntOfType(B, u64) rule checkIntOfSameType(A:Value, B:Value) => checkIntOfType(A, i64) requires checkIntOfType(B, i64) diff --git a/tests/execution/constant_lookup.rs b/tests/execution/constant_lookup.rs index d29c68bd..ef2f467f 100644 --- a/tests/execution/constant_lookup.rs +++ b/tests/execution/constant_lookup.rs @@ -16,9 +16,9 @@ pub trait ConstantValueLookup { fn lookup_constant(&self) -> u64 { :: constant_lookup :: SAMPLE_CONSTANT } - fn lookup_constant_with_type(&self) -> u64 { + fn lookup_constant_with_type(&self) -> u64 { let x = 100_u64 + :: constant_lookup :: SAMPLE_CONSTANT; - x + x } } diff --git a/tests/execution/if_expressions.rs b/tests/execution/if_expressions.rs index ffc4fea7..6583919a 100644 --- a/tests/execution/if_expressions.rs +++ b/tests/execution/if_expressions.rs @@ -11,18 +11,18 @@ pub trait IfExpressions { #[upgrade] fn upgrade(&self) {} - - fn if_expression(&self) -> u64 { + + fn if_expression(&self) -> u64 { if 80_u64 == 80_u64 { 1_u64 - } + } } - fn if_else_expression(&self) -> u64 { + fn if_else_expression(&self) -> u64 { if 80_u64 != 80_u64 { 1_u64 @@ -32,7 +32,7 @@ pub trait IfExpressions { } - fn if_else_if_expression(&self) -> u64 { + fn if_else_if_expression(&self) -> u64 { if 80_u64 != 80_u64 { 1_u64 diff --git a/tests/execution/loops.rs b/tests/execution/loops.rs index 97d75a98..5a8e095f 100644 --- a/tests/execution/loops.rs +++ b/tests/execution/loops.rs @@ -11,29 +11,29 @@ pub trait LoopExpressions { #[upgrade] fn upgrade(&self) {} - - fn iterator_evaluation(&self){ + + fn iterator_evaluation(&self){ for i in 1_u64..10_u64 { let x = i * 2_u64; }; } - fn while_evaluation(&self){ + fn while_evaluation(&self){ while 1_u64 < 1_u64 { - let x: u64 = 2_u64; + let x: u64 = 2_u64; }; } - fn iterator_with_variables(&self) { + fn iterator_with_variables(&self) { let y = 20_u64; - let z = 10_u64; + let z = 10_u64; for i in z..y { let x = i * 2_u64; }; } - fn iterator_with_same_pattern(&self) { + fn iterator_with_same_pattern(&self) { let i = 1_u64; for i in i..i+3_u64 { let x = i * 2_u64; diff --git a/tests/execution/top_level_fn.rs b/tests/execution/top_level_fn.rs index 564177fe..d6923e9c 100644 --- a/tests/execution/top_level_fn.rs +++ b/tests/execution/top_level_fn.rs @@ -12,11 +12,11 @@ pub trait TopLevelFn { #[upgrade] fn upgrade(&self) {} - fn call_top_level(&self, v: u64) -> u64 { + fn call_top_level(&self, v: u64) -> u64 { ::top_level_fn::top_level(v) } - fn call_top_level_no_arg(&self) -> u64 { + fn call_top_level_no_arg(&self) -> u64 { ::top_level_fn::top_level_no_arg() } } diff --git a/tests/syntax/staking.rs b/tests/syntax/staking.rs index ded9ff71..176cf0ea 100644 --- a/tests/syntax/staking.rs +++ b/tests/syntax/staking.rs @@ -7,7 +7,7 @@ use multiversx_sc::imports::*; pub const YEARLY_INTEREST: u64 = 7_000; -pub const BPS: u64 = 100_000; +pub const BPS: u64 = 100_000; pub const SECONDS_IN_DAY: u64 = 24 * 60 * 60; pub const SECONDS_IN_YEAR: u64 = 365_u64 * SECONDS_IN_DAY; @@ -50,7 +50,7 @@ pub trait Staking { self.call_value().single_fungible_esdt(); require!(token_id == self.staking_token().get(), "Wrong token ID."); require!(amount > BigUint::zero(), "Amount must be greater than 0"); - + let caller = self.blockchain().get_caller(); self.staked_balances(&caller).set(self.staked_balances(&caller).get() + &amount); diff --git a/tests/syntax/uniswap_v_2_router.rs b/tests/syntax/uniswap_v_2_router.rs index cbf1e355..a5272ed0 100644 --- a/tests/syntax/uniswap_v_2_router.rs +++ b/tests/syntax/uniswap_v_2_router.rs @@ -26,7 +26,7 @@ mod pair_proxy { #[view(getReserve0)] #[storage_mapper("reserve0")] fn reserve0(&self) -> SingleValueMapper; - + #[view(getReserve1)] #[storage_mapper("reserve1")] fn reserve1(&self) -> SingleValueMapper; diff --git a/tests/ulm-contracts/ulm.rs b/tests/ulm-contracts/ulm.rs index 56f50c2c..c1d0b1af 100644 --- a/tests/ulm-contracts/ulm.rs +++ b/tests/ulm-contracts/ulm.rs @@ -20,7 +20,7 @@ pub const EVMC_STATIC_MODE_VIOLATION: u64 = 13_u64; pub const EVMC_PRECOMPILE_FAILURE: u64 = 14_u64; pub const EVMC_NONCE_EXCEEDED: u64 = 15_u64; -extern { +extern { // block parameters fn sample_method(&self) -> u256; fn GasLimit(&self) -> u256; @@ -35,7 +35,7 @@ extern { // transaction parameters fn GasPrice(&self) -> u256; fn Origin(&self) -> u256; - + // message parameters fn Address(&self) -> u160; fn Caller(&self) -> u160; @@ -44,7 +44,7 @@ extern { // chain parameters fn ChainId(&self) -> u256; - + // account getters fn GetAccountBalance(&self, acct: u160) -> u256; fn GetAccountCode(&self, acct: u160) -> Bytes; @@ -67,7 +67,7 @@ extern { fn Log2(topic0: u256, topic1: u256, data: Bytes); fn Log3(topic0: u256, topic1: u256, topic2: u256, data: Bytes); fn Log4(topic0: u256, topic1: u256, topic2: u256, topic3: u256, data: Bytes); - + fn MessageResult(gas: u256, data: Bytes, status: u256, target: u256) -> MessageResult; fn Create(value: u256, data: Bytes, gas: u256) -> MessageResult; fn Create2(value: u256, data: Bytes, salt: Bytes, gas: u256) -> MessageResult; diff --git a/tests/ulm-with-contract/endpoints.1.run b/tests/ulm-with-contract/endpoints.1.run index 46df2443..01bec977 100644 --- a/tests/ulm-with-contract/endpoints.1.run +++ b/tests/ulm-with-contract/endpoints.1.run @@ -1,19 +1,19 @@ -push "myEndpoint"; -hold_string_from_test_stack; +push "myEndpoint"; +hold_string_from_test_stack; push "uint64"; -hold_list_values_from_test_stack; -push 123_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +push 123_u64; +hold_list_values_from_test_stack; +encode_call_data; -return_value; -mock CallData; +return_value; +mock CallData; call_contract 12345; return_value; check_eq (); -push_status; -check_eq 2; +push_status; +check_eq 2; output_to_arg; call :: test_helpers :: decode_single_u64; return_value; check_eq 126_u64 \ No newline at end of file diff --git a/tests/ulm-with-contract/endpoints.notfound.run b/tests/ulm-with-contract/endpoints.notfound.run index d7911d3b..2fce4e94 100644 --- a/tests/ulm-with-contract/endpoints.notfound.run +++ b/tests/ulm-with-contract/endpoints.notfound.run @@ -1,17 +1,17 @@ -push "noEndpoint"; -hold_string_from_test_stack; +push "noEndpoint"; +hold_string_from_test_stack; push "uint64"; -hold_list_values_from_test_stack; -push 123_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +push 123_u64; +hold_list_values_from_test_stack; +encode_call_data; -return_value; -mock CallData; +return_value; +mock CallData; call_contract 12345; return_value; check_eq (); -push_status; +push_status; check_eq 3 diff --git a/tests/ulm-with-contract/events.1.run b/tests/ulm-with-contract/events.1.run index a777cae0..493b6ea5 100644 --- a/tests/ulm-with-contract/events.1.run +++ b/tests/ulm-with-contract/events.1.run @@ -4,12 +4,12 @@ push "logEvent"; hold_string_from_test_stack; push "uint64"; push "uint64"; -hold_list_values_from_test_stack; +hold_list_values_from_test_stack; push 123_u64; -push 555_u64; -hold_list_values_from_test_stack; -encode_call_data; -return_value; +push 555_u64; +hold_list_values_from_test_stack; +encode_call_data; +return_value; mock CallData; call_contract 12345; diff --git a/tests/ulm-with-contract/require.false.run b/tests/ulm-with-contract/require.false.run index a1513199..4e8a416a 100644 --- a/tests/ulm-with-contract/require.false.run +++ b/tests/ulm-with-contract/require.false.run @@ -1,10 +1,10 @@ push "myEndpoint"; hold_string_from_test_stack; -push "uint64"; -hold_list_values_from_test_stack; +push "uint64"; +hold_list_values_from_test_stack; push 0_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +encode_call_data; return_value; mock CallData; diff --git a/tests/ulm-with-contract/require.true.run b/tests/ulm-with-contract/require.true.run index 4e0ec987..9ae345d2 100644 --- a/tests/ulm-with-contract/require.true.run +++ b/tests/ulm-with-contract/require.true.run @@ -1,10 +1,10 @@ push "myEndpoint"; -hold_string_from_test_stack; +hold_string_from_test_stack; push "uint64"; -hold_list_values_from_test_stack; +hold_list_values_from_test_stack; push 123_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +encode_call_data; return_value; mock CallData; diff --git a/tests/ulm-with-contract/storage.256.run b/tests/ulm-with-contract/storage.256.run index 045db759..b5b52615 100644 --- a/tests/ulm-with-contract/storage.256.run +++ b/tests/ulm-with-contract/storage.256.run @@ -2,12 +2,12 @@ mock SetAccountStorageHook ( 475865108809552657266889536530284350694862432529262 mock GetAccountStorageHook ( 47586510880955265726688953653028435069486243252926274554489699639913455891751 ) ulmIntResult(1000000000000000000000000000000000000000000000000000000000000, u256); push "setMyData256"; -hold_string_from_test_stack; +hold_string_from_test_stack; push "uint256"; hold_list_values_from_test_stack; push 1_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_u256; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +encode_call_data; return_value; mock CallData; @@ -20,8 +20,8 @@ check_eq 2; push "getMyData256"; -hold_string_from_test_stack; -encode_call_data; +hold_string_from_test_stack; +encode_call_data; return_value; mock CallData; diff --git a/tests/ulm-with-contract/storage.key.run b/tests/ulm-with-contract/storage.key.run index 8053ec84..e89191c8 100644 --- a/tests/ulm-with-contract/storage.key.run +++ b/tests/ulm-with-contract/storage.key.run @@ -2,14 +2,14 @@ mock SetAccountStorageHook ( 102449170657514660420724820116079240224535800280019 mock GetAccountStorageHook ( 10244917065751466042072482011607924022453580028001931068470547844249081769915 ) ulmIntResult(123, u256); push "setMyDataKey"; -hold_string_from_test_stack; +hold_string_from_test_stack; push "uint64"; push "uint64"; -hold_list_values_from_test_stack; +hold_list_values_from_test_stack; push 555_u64; push 123_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +encode_call_data; return_value; mock CallData; @@ -22,12 +22,12 @@ check_eq 2; push "getMyDataKey"; -hold_string_from_test_stack; +hold_string_from_test_stack; push "uint64"; -hold_list_values_from_test_stack; +hold_list_values_from_test_stack; push 555_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +encode_call_data; return_value; mock CallData; diff --git a/tests/ulm-with-contract/storage.simple.run b/tests/ulm-with-contract/storage.simple.run index 6b89cd21..6ad0b98e 100644 --- a/tests/ulm-with-contract/storage.simple.run +++ b/tests/ulm-with-contract/storage.simple.run @@ -2,12 +2,12 @@ mock SetAccountStorageHook ( 738663589423117231874453614695099632837440602528266 mock GetAccountStorageHook ( 73866358942311723187445361469509963283744060252826659833950887638461707973283 ) ulmIntResult(123, u256); push "setMyData"; -hold_string_from_test_stack; +hold_string_from_test_stack; push "uint64"; hold_list_values_from_test_stack; push 123_u64; -hold_list_values_from_test_stack; -encode_call_data; +hold_list_values_from_test_stack; +encode_call_data; return_value; mock CallData; @@ -20,8 +20,8 @@ check_eq 2; push "getMyData"; -hold_string_from_test_stack; -encode_call_data; +hold_string_from_test_stack; +encode_call_data; return_value; mock CallData; diff --git a/ulm-semantics/main/hooks/bytes.md b/ulm-semantics/main/hooks/bytes.md index fab7b2e2..32380b59 100644 --- a/ulm-semantics/main/hooks/bytes.md +++ b/ulm-semantics/main/hooks/bytes.md @@ -306,7 +306,7 @@ module ULM-SEMANTICS-HOOKS-BYTES rule ulmBytesDecodeBytes(ptrValue(_, u64(BytesId)), L:Int) => ulmBytesDecodeBytes(ulmBytesId(BytesId), L:Int) - rule ulmBytesDecodeBytes(ulmBytesValue(B:Bytes), L:Int) + rule ulmBytesDecodeBytes(ulmBytesValue(B:Bytes), L:Int) => tupleExpression ( ulmBytesNew(substrBytes(B, L, lengthBytes(B))) , ulmBytesNew(substrBytes(B, 0, L)) diff --git a/ulm-semantics/main/preprocessing/events.md b/ulm-semantics/main/preprocessing/events.md index d13c5af1..d0c4288d 100644 --- a/ulm-semantics/main/preprocessing/events.md +++ b/ulm-semantics/main/preprocessing/events.md @@ -24,7 +24,7 @@ module ULM-PREPROCESSING-EVENTS , eventSignature: ValueOrError ) - rule + rule ulmPreprocessEvent (... fullMethodPath: Method:PathInExpression diff --git a/ulm-semantics/main/preprocessing/storage.md b/ulm-semantics/main/preprocessing/storage.md index f3875a8b..72a313bf 100644 --- a/ulm-semantics/main/preprocessing/storage.md +++ b/ulm-semantics/main/preprocessing/storage.md @@ -8,7 +8,7 @@ module ULM-PREPROCESSING-STORAGE imports private ULM-PREPROCESSING-SYNTAX-PRIVATE imports private ULM-REPRESENTATION - rule + rule ulmPreprocessStorage (... fullMethodPath: Method:PathInExpression diff --git a/ulm-semantics/test/execution.md b/ulm-semantics/test/execution.md index 13513d94..7ad6ef31 100644 --- a/ulm-semantics/test/execution.md +++ b/ulm-semantics/test/execution.md @@ -29,7 +29,7 @@ module ULM-TEST-SYNTAX | "call_contract" Int | "init_contract" Int | "clear_pgm" - | "hold" KItem + | "hold" KItem | "output_to_arg" | "push_status" | "check_eq" Int @@ -68,60 +68,60 @@ module ULM-TEST-EXECUTION // for mocking tests rule UTH:ULMTestTypeHolder ~> EI:ExecutionItem => EI ~> UTH ... rule UTHL:ULMTestTypeHolderList ~> EI:ExecutionItem => EI ~> UTHL ... - rule UTH1:ULMTestTypeHolder ~> UTH2:ULMTestTypeHolder - => (UTH1, UTH2):ULMTestTypeHolderList ... - rule UTH:ULMTestTypeHolder ~> UTHL:ULMTestTypeHolderList - => (UTH, UTHL):ULMTestTypeHolderList ... + rule UTH1:ULMTestTypeHolder ~> UTH2:ULMTestTypeHolder + => (UTH1, UTH2):ULMTestTypeHolderList ... + rule UTH:ULMTestTypeHolder ~> UTHL:ULMTestTypeHolderList + => (UTH, UTHL):ULMTestTypeHolderList ... rule hold_string_from_test_stack => ptr_holder P ... ListItem(P) L:List => L rule ptr_holder ptrValue(_, V) => value_holder V ... - + // TODO: Rework the implementation of the productions related to list value holding // Ref - https://github.com/Pi-Squared-Inc/rust-demo-semantics/pull/167#discussion_r1813386536 rule hold_list_values_from_test_stack => list_ptrs_holder L ~> list_values_holder .List ... L:List => .List - rule list_ptrs_holder ListItem(I) LPH ~> list_values_holder LLH - => I ~> list_ptrs_holder LPH ~> list_values_holder LLH ... + rule list_ptrs_holder ListItem(I) LPH ~> list_values_holder LLH + => I ~> list_ptrs_holder LPH ~> list_values_holder LLH ... rule ptrValue(_, V) ~> list_ptrs_holder LPH ~> list_values_holder LLH - => list_ptrs_holder LPH ~> list_values_holder ListItem(V) LLH ... + => list_ptrs_holder LPH ~> list_values_holder ListItem(V) LLH ... rule list_ptrs_holder .List => .K ... rule hold I => value_holder I ... rule encode_call_data_to_string ~> list_values_holder ARGS , list_values_holder PTYPES , value_holder FNAME , .ULMTestTypeHolderList - => Bytes2String(encodeCallData(FNAME, PTYPES, ARGS)) + => Bytes2String(encodeCallData(FNAME, PTYPES, ARGS)) ... - - + + rule encode_call_data_to_string - ~> value_holder FNAME - => Bytes2String(encodeCallData(FNAME, .List, .List)) + ~> value_holder FNAME + => Bytes2String(encodeCallData(FNAME, .List, .List)) ... [owise] rule encode_call_data ~> list_values_holder ARGS , list_values_holder PTYPES , value_holder FNAME , .ULMTestTypeHolderList - => ulmBytesNew(encodeCallData(FNAME, PTYPES, ARGS)) + => ulmBytesNew(encodeCallData(FNAME, PTYPES, ARGS)) ... - + rule encode_call_data ~> value_holder FNAME - => ulmBytesNew(encodeCallData(FNAME, .List, .List)) + => ulmBytesNew(encodeCallData(FNAME, .List, .List)) ... [owise] rule encode_constructor_data ~> list_values_holder ARGS , list_values_holder PTYPES , .ULMTestTypeHolderList - => ulmBytesNew(encodeConstructorData(PTYPES, ARGS)) + => ulmBytesNew(encodeConstructorData(PTYPES, ARGS)) ... - + rule encode_constructor_data - => ulmBytesNew(encodeConstructorData(.List, .List)) + => ulmBytesNew(encodeConstructorData(.List, .List)) ... [owise]