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

New encoding for contract calls #5427

Merged
merged 24 commits into from
Mar 6, 2024
Merged

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Jan 2, 2024

Description

This PR implements the new encoding for contracts/scripts/predicates. #5512 and #5513

Contract Calls

When the new encoding is turned on using --experimental-new-encoding, contract calls like the example below will be "desugarized" differently now.

let base_asset_id = BASE_ASSET_ID;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);

let test_contract = abi(ContextTesting, other_contract_id.into());
let returned_contract_id = test_contract.get_id { gas: gas, coins: 0, asset_id: BASE_ASSET_ID.value}(1, 2, 3);

and will be transformed to

let base_asset_id = BASE_ASSET_ID;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);

let test_contract = abi(ContextTesting, other_contract_id.into());
let returned_contract_id = contract_call::<ContractId, _>(other_contract_id.into(), "get_id", (1, 2, 3), coins, asset_id, gas);

And the important part is the contract_call function in the std library. This function does all the encoding as necessary and delegates the actual call to an intrinsic function __contract_call. Allowing the protocol to evolve entirely in Sway.

pub fn contract_call<T, TArgs>(contract_id: b256, method_name: str, args: TArgs, coins: u64, asset_id: b256, gas: u64) -> T
where
    TArgs: AbiEncode
{
    let first_parameter = encode(method_name);
    let second_parameter = encode(args);
    let params = encode(
        (
            contract_id,
            asm(a: first_parameter.ptr()) { a: u64 },
            asm(a: second_parameter.ptr()) { a: u64 },
        )
    );
    __contract_call::<T>(params.ptr(), coins, asset_id, gas)
}

Contracts

On the other side, when the flag --expiremental-new-encoding is turned on, the contract specification like the one below is being transformed into all the decoding and encoding necessary.

The mains points are:

  • The compiler generates a function called __entry that decodes the method name and its arguments. The method is selected with a bunch of ifs at the moment, because we don´t have match for string slices. Then we decode the arguments using the correct type, which is a tuple with all the function arguments, and expand this tuple calling the function;
  • All the contract functions are converted to global functions prefixed with __contract_method;
  • Results are encoded and returned using the intrinsic call __retd.

Example:

abi SomeContract {
    fn some_function(a: u64) -> u64;
}

impl SomeContract for Contract {
    fn some_function(a: u64) -> u64 {
        1
    }
}

will be transformed into

fn __entry() {
    let method_name = decode_first_parameter();
    if method_name == "some_function" {
        let args = decode_second_parameter::<(u64,)>();
        let result = __contract_method_some_function(args.0);
        __retd(encode(result));
    }
    __revert(0);
}

Scripts and Predicates

The protocol to call scripts and predicates will also change and will be very similar to contracts. See more above. Now when the flag is turned on, the main function will not be entry point anymore. The compiler will actually generate an __entry function that will decode arguments and encode the result, like contracts.

For example:

fn main(a: u64) -> u64 {
    1
}

will be transformed into

fn __entry() {
    let args = decode_script_data::<(u64,)();
    let result = main(args.0);
    __retd(encode(result));
}

fn main(a: u64) -> u64 {
    1
}

Tests

To facilitate testing this PR introduces three changes to our test harness:

1 - A new parameter can be called to update test output files (abi and storage json). This facilitates when we only want to copy and paste these output files to their respective oracles. Brings the framework closer to a snapshot one.

> cargo r -p test --release -- --update-output-files

2 - Depending on the configuration at test.toml multiple executions of the same test will be scheduled. At the moment, tests that depend on the encoding will run with the --experimental-new-encoding flag automatically. For example:

Testing should_pass/language/main_args/main_args_copy_copy ... ok
Testing should_pass/language/main_args/main_args_copy_copy (New Encoding) ... ok

3 - A new script_data_new_encoding was created because we want to support and run tests with the two encoding for a time. This is also what flags tests to run with the flag on automatically.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj force-pushed the xunilrj/encoding-contract-call branch from 8e2fb13 to 9ecc867 Compare January 15, 2024 12:48
@xunilrj xunilrj force-pushed the xunilrj/encoding-contract-call branch from 9bf7f45 to 3d3ed89 Compare January 23, 2024 12:29
@xunilrj xunilrj force-pushed the xunilrj/encoding-contract-call branch from 70cd848 to ca811df Compare February 7, 2024 11:55
@xunilrj xunilrj force-pushed the xunilrj/encoding-contract-call branch from 07cbcef to 61f19de Compare February 15, 2024 20:37
Copy link

Benchmark for 1ddb756

Click to view benchmark
Test Base PR %
code_action 5.4±0.21ms 5.2±0.11ms -3.70%
code_lens 299.0±20.73ns 304.3±9.53ns +1.77%
compile 3.0±0.05s 3.5±0.06s +16.67%
completion 4.7±0.10ms 4.7±0.01ms 0.00%
did_change_with_caching 2.9±0.05s 3.4±0.03s +17.24%
document_symbol 964.6±20.64µs 1018.1±62.98µs +5.55%
format 89.4±3.63ms 89.6±2.84ms +0.22%
goto_definition 364.9±5.38µs 361.1±5.14µs -1.04%
highlight 8.8±0.17ms 8.8±0.17ms 0.00%
hover 552.1±22.25µs 580.3±7.23µs +5.11%
idents_at_position 122.9±0.31µs 122.5±0.44µs -0.33%
inlay_hints 663.4±49.25µs 666.5±57.70µs +0.47%
on_enter 483.1±18.23ns 492.3±16.76ns +1.90%
parent_decl_at_position 3.6±0.05ms 3.6±0.04ms 0.00%
prepare_rename 361.1±7.80µs 364.0±6.30µs +0.80%
rename 9.3±0.21ms 9.1±0.17ms -2.15%
semantic_tokens 1068.7±11.98µs 1066.1±92.80µs -0.24%
token_at_position 360.8±2.12µs 356.5±4.92µs -1.19%
tokens_at_position 3.6±0.16ms 3.6±0.07ms 0.00%
tokens_for_file 410.3±6.43µs 416.7±1.54µs +1.56%
traverse 38.5±0.90ms 37.8±0.82ms -1.82%

Copy link

Benchmark for c4c70fe

Click to view benchmark
Test Base PR %
code_action 5.2±0.13ms 5.2±0.11ms 0.00%
code_lens 285.7±8.32ns 288.8±19.54ns +1.09%
compile 3.0±0.03s 3.8±0.08s +26.67%
completion 5.1±0.19ms 4.9±0.16ms -3.92%
did_change_with_caching 2.9±0.04s 3.5±0.09s +20.69%
document_symbol 960.1±32.21µs 967.8±14.19µs +0.80%
format 72.2±0.70ms 73.4±2.23ms +1.66%
goto_definition 367.7±15.20µs 372.6±7.01µs +1.33%
highlight 8.8±0.16ms 8.8±0.07ms 0.00%
hover 532.9±5.65µs 598.2±26.49µs +12.25%
idents_at_position 122.6±0.44µs 125.4±1.30µs +2.28%
inlay_hints 655.4±27.44µs 663.9±25.44µs +1.30%
on_enter 476.2±19.12ns 499.0±14.14ns +4.79%
parent_decl_at_position 3.6±0.04ms 3.7±0.26ms +2.78%
prepare_rename 361.5±3.86µs 370.9±3.89µs +2.60%
rename 9.3±0.22ms 9.2±0.18ms -1.08%
semantic_tokens 1055.3±19.77µs 1076.7±16.55µs +2.03%
token_at_position 360.1±1.94µs 365.7±3.26µs +1.56%
tokens_at_position 3.6±0.05ms 3.6±0.07ms 0.00%
tokens_for_file 411.3±4.69µs 418.2±4.09µs +1.68%
traverse 38.9±1.17ms 39.5±0.73ms +1.54%

@Riskypounds

This comment was marked as spam.

Copy link

Benchmark for ff5bdb7

Click to view benchmark
Test Base PR %
code_action 5.1±0.03ms 5.4±0.10ms +5.88%
code_lens 286.1±9.14ns 335.8±11.66ns +17.37%
compile 3.0±0.06s 3.7±0.03s +23.33%
completion 4.8±0.18ms 5.0±0.12ms +4.17%
did_change_with_caching 3.1±0.04s 3.5±0.04s +12.90%
document_symbol 1036.9±34.72µs 963.0±16.97µs -7.13%
format 75.5±0.82ms 75.0±0.93ms -0.66%
goto_definition 379.8±6.16µs 373.1±7.33µs -1.76%
highlight 8.9±0.22ms 9.3±0.19ms +4.49%
hover 547.2±7.15µs 584.9±14.49µs +6.89%
idents_at_position 122.3±1.05µs 124.0±1.32µs +1.39%
inlay_hints 662.2±24.63µs 671.7±7.19µs +1.43%
on_enter 494.7±13.62ns 473.4±19.71ns -4.31%
parent_decl_at_position 3.6±0.06ms 3.7±0.07ms +2.78%
prepare_rename 377.4±12.36µs 370.3±6.66µs -1.88%
rename 9.1±0.05ms 9.6±0.14ms +5.49%
semantic_tokens 1043.1±40.91µs 1050.4±20.04µs +0.70%
token_at_position 369.7±3.70µs 364.1±3.29µs -1.51%
tokens_at_position 3.6±0.02ms 3.7±0.04ms +2.78%
tokens_for_file 415.4±2.91µs 411.7±2.59µs -0.89%
traverse 38.9±0.59ms 38.9±0.96ms 0.00%

Copy link
Contributor

@jjcnn jjcnn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it easier to see what's going on by looking at each commit separately, and I'm done all the way through to the one called "clean tests".

I'll continue with the rest of the commits tomorrow.

sway-core/src/ir_generation/function.rs Outdated Show resolved Hide resolved
sway-lib-core/src/codec.sw Outdated Show resolved Hide resolved
sway-core/src/semantic_analysis/program.rs Outdated Show resolved Hide resolved
@jjcnn
Copy link
Contributor

jjcnn commented Feb 27, 2024

I understand this example in principle, but there seems to be things missing:

let base_asset_id = BASE_ASSET_ID;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);

let test_contract = abi(ContextTesting, other_contract_id.into());
let returned_contract_id = test_contract.get_id { gas: gas, coins: 0, asset_id: BASE_ASSET_ID.value}(1, 2, 3);

[and] will be transformed to

let base_asset_id = BASE_ASSET_ID;
let other_contract_id = ContractId::from(0xa38576787f8900d66e6620548b6da8142b8bb4d129b2338609acd121ca126c10);

let test_contract = abi(ContextTesting, other_contract_id.into());
let returned_contract_id = contract_call::<ContractId, _>(other_contract_id.into(), "get_id", (1, 2, 3), coins, asset_id, gas);

Are gas and coins implicitly defined variables?

Is it necessary to defined base_asset_id instead of just using BASE_ASSET_ID in the contract call?

@xunilrj
Copy link
Contributor Author

xunilrj commented Feb 27, 2024

Are gas and coins implicitly defined variables?

No they are standard variables. Nothing special about them.

Is it necessary to defined base_asset_id instead of just using BASE_ASSET_ID in the contract call?

It is not necessary, but it is an option that we give when a contract call is made. See https://docs.fuel.network/docs/sway/sway-program-types/smart_contracts/#calling-a-smart-contract-from-a-script

You also have the option of specifying the following special parameters inside curly braces right before the main list of parameters:

gas: a u64 that represents the gas being forwarded to the contract when it is called.
coins: a u64 that represents how many coins are being forwarded with this call.
asset_id: a b256 that represents the ID of the asset type of the coins being forwarded.

@jjcnn
Copy link
Contributor

jjcnn commented Feb 28, 2024

Are gas and coins implicitly defined variables?

No they are standard variables. Nothing special about them.

So the examples are not self-contained, then? For instance, I see a variable gas which is not defined anywhere, and which is used to initialize the gas parameter to the contract call.

@ironcev
Copy link
Member

ironcev commented Feb 28, 2024

So the examples are not self-contained

Exactly, they are more like code snippets.

Copy link
Member

@ironcev ironcev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats for putting all this together @xunilrj!!

I am still going through the PR and connecting the dots. The overall mechanics is already clear (contract.method() being desugared into contract_call that in the end calls the intrinsic) but I still didn't touch the part with the heavy code generation.

The comments posted in this review are IMO negligible compared to the overall complexity and importance of the PR and can be ignored for now if there are more pressing issues.

The only one that I think can lead to bugs is the not fully qualified name in the contract_call function application.

I'll proceed with the review.

sway-core/src/decl_engine/associated_item_decl_id.rs Outdated Show resolved Hide resolved
sway-core/src/decl_engine/engine.rs Outdated Show resolved Hide resolved
sway-core/src/decl_engine/parsed_engine.rs Show resolved Hide resolved
sway-core/src/ir_generation.rs Outdated Show resolved Hide resolved
sway-core/src/ir_generation/compile.rs Outdated Show resolved Hide resolved
sway-core/src/language/parsed/expression/mod.rs Outdated Show resolved Hide resolved
sway-core/src/language/parsed/mod.rs Outdated Show resolved Hide resolved
@ironcev
Copy link
Member

ironcev commented Feb 29, 2024

General remark. @tritao's concern about debug symbols and loosing span information when desugaring is valid, especially in this approach when we generate the code by compiling code snippets. It looks to me we will need something like #line directive for generated code.

@ironcev
Copy link
Member

ironcev commented Feb 29, 2024

When I compile this simple predicate:

predicate;

fn main() -> bool {
   true
}

the compiler panics in aut_impl:

thread 'main' panicked at sway-core/src/semantic_analysis/ast_node/declaration/auto_impl.rs:679:9:
Handler { inner: RefCell { value: HandlerInner { errors: [SymbolNotFound { name: decode_script_data, span: Span { src (ptr): 0x55b8522472e0, source_id: None, start: 50, end: 68, as_str(): "decode_script_data" } }], warnings: [] } } } pub fn __entry() -> bool {
            let args = decode_script_data::<()>();
            main()
        }

Copy link

github-actions bot commented Mar 1, 2024

Benchmark for 5b9eac1

Click to view benchmark
Test Base PR %
code_action 5.2±0.10ms 5.7±0.29ms +9.62%
code_lens 295.8±7.09ns 300.4±7.64ns +1.56%
compile 3.1±0.07s 3.3±0.06s +6.45%
completion 5.3±0.27ms 5.1±0.41ms -3.77%
did_change_with_caching 3.0±0.03s 3.3±0.05s +10.00%
document_symbol 977.1±20.73µs 980.2±15.30µs +0.32%
format 73.3±1.02ms 71.6±1.53ms -2.32%
goto_definition 369.0±6.35µs 367.6±7.43µs -0.38%
highlight 8.8±0.05ms 9.1±0.28ms +3.41%
hover 547.2±13.29µs 544.0±8.71µs -0.58%
idents_at_position 122.1±0.57µs 122.3±1.06µs +0.16%
inlay_hints 659.0±28.01µs 678.6±10.76µs +2.97%
on_enter 481.6±6.82ns 469.1±15.27ns -2.60%
parent_decl_at_position 3.8±0.22ms 3.8±0.12ms 0.00%
prepare_rename 370.2±6.70µs 370.8±14.74µs +0.16%
rename 9.1±0.15ms 10.1±0.21ms +10.99%
semantic_tokens 1069.4±30.41µs 1050.3±7.57µs -1.79%
token_at_position 367.6±2.98µs 370.3±3.49µs +0.73%
tokens_at_position 3.9±0.27ms 3.9±0.27ms 0.00%
tokens_for_file 497.6±3.24µs 410.4±5.54µs -17.52%
traverse 39.4±0.86ms 40.4±1.05ms +2.54%

xunilrj added a commit that referenced this pull request Mar 1, 2024
This PR solves a problem for #5427.
When compiling the Rust SDK, the type below hangs the compiler
inside`find_parent`.

```sway
#[allow(dead_code)]
struct MegaExample<T, U> {
    a: ([U; 2], T),
    b: Vec<([EnumWGeneric<StructWTupleGeneric<StructWArrayGeneric<PassTheGenericOn<T>>>>; 1], u32)>,
}
```

Now, propagating when a change is made, not only the example compiles,
but we should also be able to optimize compilation in general.

In small benchmarks I made here, compiling the Rust SDK had a 2%
improvement (from `0m8.404s` to `0m8.258s`).

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
@xunilrj xunilrj force-pushed the xunilrj/encoding-contract-call branch from 287d8e8 to d201a36 Compare March 4, 2024 15:45
Copy link

github-actions bot commented Mar 4, 2024

Benchmark for e0acdae

Click to view benchmark
Test Base PR %
code_action 5.1±0.13ms 5.5±0.14ms +7.84%
code_lens 308.0±8.27ns 289.0±10.17ns -6.17%
compile 4.2±0.06s 5.9±0.05s +40.48%
completion 4.7±0.07ms 4.9±0.10ms +4.26%
did_change_with_caching 3.7±0.12s 5.2±0.04s +40.54%
document_symbol 1031.6±41.98µs 969.2±21.65µs -6.05%
format 73.3±0.60ms 71.0±1.65ms -3.14%
goto_definition 366.8±18.09µs 359.7±4.89µs -1.94%
highlight 8.8±0.43ms 9.1±0.18ms +3.41%
hover 540.4±8.30µs 590.3±10.91µs +9.23%
idents_at_position 121.6±0.18µs 122.6±0.88µs +0.82%
inlay_hints 649.6±23.76µs 671.2±27.77µs +3.33%
on_enter 492.9±13.18ns 510.5±16.75ns +3.57%
parent_decl_at_position 3.6±0.02ms 3.7±0.04ms +2.78%
prepare_rename 364.0±6.51µs 361.5±8.58µs -0.69%
rename 9.1±0.19ms 9.6±0.18ms +5.49%
semantic_tokens 1049.1±39.51µs 1033.3±19.23µs -1.51%
token_at_position 361.0±2.96µs 349.6±2.93µs -3.16%
tokens_at_position 3.6±0.04ms 3.7±0.02ms +2.78%
tokens_for_file 409.4±2.55µs 412.5±2.99µs +0.76%
traverse 37.2±1.17ms 43.1±1.58ms +15.86%

Copy link

github-actions bot commented Mar 4, 2024

Benchmark for c4a74da

Click to view benchmark
Test Base PR %
code_action 5.1±0.07ms 5.5±0.15ms +7.84%
code_lens 306.3±7.60ns 290.5±11.96ns -5.16%
compile 4.4±0.12s 5.9±0.07s +34.09%
completion 4.7±0.06ms 5.0±0.15ms +6.38%
did_change_with_caching 3.8±0.07s 5.5±0.12s +44.74%
document_symbol 944.2±6.67µs 969.2±14.64µs +2.65%
format 73.4±1.26ms 69.9±1.74ms -4.77%
goto_definition 358.0±8.67µs 357.4±4.12µs -0.17%
highlight 8.7±0.04ms 9.2±0.26ms +5.75%
hover 530.5±6.76µs 619.0±21.86µs +16.68%
idents_at_position 121.4±0.38µs 121.7±1.00µs +0.25%
inlay_hints 644.1±28.77µs 661.4±23.00µs +2.69%
on_enter 489.7±31.94ns 504.9±16.25ns +3.10%
parent_decl_at_position 3.6±0.07ms 3.7±0.03ms +2.78%
prepare_rename 358.4±7.22µs 364.3±5.78µs +1.65%
rename 9.2±0.16ms 9.7±0.32ms +5.43%
semantic_tokens 1022.1±16.84µs 1042.8±27.66µs +2.03%
token_at_position 355.5±1.95µs 357.4±3.25µs +0.53%
tokens_at_position 3.6±0.06ms 3.7±0.05ms +2.78%
tokens_for_file 449.0±1.72µs 416.3±13.82µs -7.28%
traverse 38.5±0.92ms 43.7±1.26ms +13.51%

Copy link

github-actions bot commented Mar 5, 2024

Benchmark for 900a91e

Click to view benchmark
Test Base PR %
code_action 5.4±0.08ms 5.4±0.03ms 0.00%
code_lens 292.4±11.19ns 290.4±6.92ns -0.68%
compile 4.6±0.17s 5.7±0.11s +23.91%
completion 4.9±0.35ms 4.9±0.19ms 0.00%
did_change_with_caching 3.7±0.11s 5.1±0.04s +37.84%
document_symbol 953.6±16.17µs 954.0±23.82µs +0.04%
format 73.3±1.00ms 69.4±0.91ms -5.32%
goto_definition 366.3±6.51µs 361.7±7.07µs -1.26%
highlight 9.0±0.05ms 9.1±0.15ms +1.11%
hover 531.7±6.01µs 587.3±8.30µs +10.46%
idents_at_position 121.6±0.22µs 122.0±2.03µs +0.33%
inlay_hints 662.0±22.33µs 672.4±22.50µs +1.57%
on_enter 488.6±14.05ns 490.4±14.65ns +0.37%
parent_decl_at_position 3.7±0.02ms 3.7±0.06ms 0.00%
prepare_rename 367.1±6.35µs 361.4±4.45µs -1.55%
rename 9.4±0.06ms 9.5±0.03ms +1.06%
semantic_tokens 1043.2±21.22µs 1053.0±12.19µs +0.94%
token_at_position 358.6±3.54µs 354.3±1.87µs -1.20%
tokens_at_position 3.7±0.03ms 3.7±0.03ms 0.00%
tokens_for_file 411.9±6.21µs 409.8±2.50µs -0.51%
traverse 37.5±1.11ms 42.7±1.39ms +13.87%

Copy link

github-actions bot commented Mar 5, 2024

Benchmark for 1fd53d4

Click to view benchmark
Test Base PR %
code_action 5.3±0.19ms 5.5±0.23ms +3.77%
code_lens 299.5±16.58ns 290.5±11.09ns -3.01%
compile 4.3±0.13s 5.8±0.05s +34.88%
completion 4.8±0.15ms 4.9±0.05ms +2.08%
did_change_with_caching 3.8±0.11s 5.2±0.04s +36.84%
document_symbol 964.0±19.48µs 1011.0±11.81µs +4.88%
format 73.7±0.82ms 70.7±3.11ms -4.07%
goto_definition 367.8±9.09µs 367.5±6.55µs -0.08%
highlight 9.0±0.03ms 9.1±0.05ms +1.11%
hover 546.4±8.79µs 674.6±15.91µs +23.46%
idents_at_position 122.5±0.68µs 123.3±0.63µs +0.65%
inlay_hints 665.1±16.33µs 671.6±11.90µs +0.98%
on_enter 486.8±16.56ns 491.0±17.38ns +0.86%
parent_decl_at_position 3.7±0.08ms 3.7±0.03ms 0.00%
prepare_rename 365.4±6.72µs 364.7±5.80µs -0.19%
rename 9.4±0.14ms 9.5±0.04ms +1.06%
semantic_tokens 1053.4±30.97µs 1056.1±20.37µs +0.26%
token_at_position 366.0±4.15µs 360.4±2.08µs -1.53%
tokens_at_position 3.7±0.02ms 3.7±0.02ms 0.00%
tokens_for_file 414.6±2.94µs 413.5±1.71µs -0.27%
traverse 37.9±1.18ms 43.9±1.95ms +15.83%

@xunilrj xunilrj marked this pull request as ready for review March 5, 2024 09:40
Copy link

github-actions bot commented Mar 6, 2024

Benchmark for ab66cd8

Click to view benchmark
Test Base PR %
code_action 5.7±0.18ms 5.5±0.09ms -3.51%
code_lens 288.9±9.88ns 302.7±15.52ns +4.78%
compile 4.7±0.12s 5.9±0.07s +25.53%
completion 5.7±0.46ms 5.0±0.12ms -12.28%
did_change_with_caching 3.9±0.07s 5.8±0.09s +48.72%
document_symbol 1049.9±22.60µs 1031.9±22.78µs -1.71%
format 75.3±0.68ms 69.5±1.02ms -7.70%
goto_definition 361.6±7.10µs 381.0±16.27µs +5.37%
highlight 9.8±0.30ms 9.2±0.15ms -6.12%
hover 541.3±12.48µs 607.4±15.46µs +12.21%
idents_at_position 121.9±0.35µs 123.7±0.99µs +1.48%
inlay_hints 684.8±16.99µs 680.0±13.71µs -0.70%
on_enter 479.0±18.10ns 492.2±12.81ns +2.76%
parent_decl_at_position 4.5±0.13ms 3.7±0.04ms -17.78%
prepare_rename 356.9±7.70µs 376.8±7.94µs +5.58%
rename 10.0±0.12ms 9.6±0.14ms -4.00%
semantic_tokens 1051.8±20.52µs 1071.0±9.51µs +1.83%
token_at_position 350.9±1.44µs 369.4±3.34µs +5.27%
tokens_at_position 4.4±0.15ms 3.7±0.03ms -15.91%
tokens_for_file 419.3±3.16µs 417.9±3.66µs -0.33%
traverse 39.8±1.30ms 46.5±1.61ms +16.83%

Copy link

github-actions bot commented Mar 6, 2024

Benchmark for 3f74b03

Click to view benchmark
Test Base PR %
code_action 5.3±0.18ms 5.5±0.13ms +3.77%
code_lens 286.8±8.79ns 287.4±9.40ns +0.21%
compile 4.4±0.12s 6.0±0.08s +36.36%
completion 5.0±0.11ms 5.2±0.16ms +4.00%
did_change_with_caching 4.0±0.13s 5.5±0.04s +37.50%
document_symbol 995.4±24.82µs 1051.4±52.48µs +5.63%
format 74.0±0.94ms 70.6±1.18ms -4.59%
goto_definition 367.9±10.50µs 375.0±6.55µs +1.93%
highlight 9.1±0.15ms 9.2±0.17ms +1.10%
hover 540.8±6.76µs 612.8±11.36µs +13.31%
idents_at_position 122.1±0.64µs 121.7±0.98µs -0.33%
inlay_hints 662.1±34.30µs 681.0±9.55µs +2.85%
on_enter 487.3±13.82ns 486.7±12.78ns -0.12%
parent_decl_at_position 3.7±0.05ms 3.8±0.04ms +2.70%
prepare_rename 361.9±3.92µs 375.5±5.33µs +3.76%
rename 9.5±0.25ms 9.9±0.07ms +4.21%
semantic_tokens 1050.6±12.45µs 1039.1±21.66µs -1.09%
token_at_position 360.6±1.98µs 365.1±19.96µs +1.25%
tokens_at_position 3.7±0.02ms 3.8±0.04ms +2.70%
tokens_for_file 416.1±2.74µs 412.9±12.40µs -0.77%
traverse 39.2±0.84ms 44.5±2.03ms +13.52%

Copy link

github-actions bot commented Mar 6, 2024

Benchmark for 58fe54e

Click to view benchmark
Test Base PR %
code_action 5.3±0.23ms 5.5±0.11ms +3.77%
code_lens 287.3±15.30ns 288.5±9.64ns +0.42%
compile 4.3±0.10s 5.8±0.10s +34.88%
completion 4.9±0.16ms 5.0±0.07ms +2.04%
did_change_with_caching 3.8±0.10s 5.3±0.06s +39.47%
document_symbol 980.1±15.35µs 958.7±30.88µs -2.18%
format 74.8±2.20ms 70.7±1.65ms -5.48%
goto_definition 367.3±6.02µs 376.4±5.28µs +2.48%
highlight 9.1±0.04ms 9.3±0.18ms +2.20%
hover 545.5±19.05µs 597.3±21.40µs +9.50%
idents_at_position 122.8±1.28µs 122.4±1.01µs -0.33%
inlay_hints 727.9±22.87µs 673.7±54.09µs -7.45%
on_enter 478.3±16.29ns 489.5±15.53ns +2.34%
parent_decl_at_position 3.7±0.03ms 3.7±0.05ms 0.00%
prepare_rename 371.9±18.98µs 372.4±8.56µs +0.13%
rename 9.5±0.29ms 9.7±0.21ms +2.11%
semantic_tokens 1077.9±38.43µs 1056.0±7.32µs -2.03%
token_at_position 359.3±2.92µs 367.5±3.26µs +2.28%
tokens_at_position 3.7±0.05ms 3.7±0.03ms 0.00%
tokens_for_file 428.8±5.62µs 411.5±2.44µs -4.03%
traverse 37.8±1.03ms 44.9±2.39ms +18.78%

@IGI-111 IGI-111 requested a review from ironcev March 6, 2024 19:51
@xunilrj xunilrj merged commit c24d731 into master Mar 6, 2024
35 checks passed
@xunilrj xunilrj deleted the xunilrj/encoding-contract-call branch March 6, 2024 21:33
@hal3e hal3e restored the xunilrj/encoding-contract-call branch March 7, 2024 11:46
xunilrj added a commit that referenced this pull request Mar 7, 2024
## Description

This fixes a bug introduced by
#5427, where the ABI was exporting
the "__entry" function instead of the "main".

When parsing and type checking I now mark function as "main" an only
later decide if the compilation will call the main or the entry.

I also moved the `is_entrypoint` method from the `TyAstNode` to the DCE
pass, because it is super specific to that pass.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
@hal3e hal3e deleted the xunilrj/encoding-contract-call branch March 8, 2024 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants