zink icon indicating copy to clipboard operation
zink copied to clipboard

refactor(compiler.rs): use hashmap for ABI storage

Open Timosdev99 opened this issue 2 months ago • 12 comments

this changes refactor the compiler to use Hashmap<String, Abi> instead of using Vec<Abi> for storing contracts ABIs

the reason for this pr is because the current implementation uses a Vec, which requires an O(n) linear search to look up an ABI by name. this method can become inefficient and a significant performance bottleneck as the number of ABIs increase. By using a HashMap, we achieve average O(1) lookup time by keying on the contract name leading to improvement in perfomance.

Timosdev99 avatar Oct 06 '25 00:10 Timosdev99

@clearloop @g4titanx what do you think about this change can I get a review on it

Timosdev99 avatar Oct 06 '25 09:10 Timosdev99

i added a unit test to verify that the compiler correctly generate the ABI for the log example contract

Timosdev99 avatar Oct 06 '25 11:10 Timosdev99

The CI is still broken XD, have you tried cargo test in the workspace?

clearloop avatar Oct 07 '25 05:10 clearloop

yes all test passed in the workspace locally

Timosdev99 avatar Oct 08 '25 14:10 Timosdev99

yes all test passed in the workspace locally

i dont think you ran all tests, check ci build. run cargo tt locally

g4titanx avatar Oct 08 '25 15:10 g4titanx

yes i did ran all the test Screenshot_20251008_161305

Timosdev99 avatar Oct 08 '25 16:10 Timosdev99

yes all test passed in the workspace locally

i dont think you ran all tests, check ci build. run cargo tt locally

but the error in the CI build suggest that some functions are not yet implemented in codegen/visitor/local.rs

Timosdev99 avatar Oct 08 '25 16:10 Timosdev99

interesting, I'll take a look tonight

clearloop avatar Oct 09 '25 06:10 clearloop

@clearloop are you still looking into this, wanted to make a pr to complete the functions that are yet to be added

Timosdev99 avatar Oct 10 '25 16:10 Timosdev99

@clearloop are you still looking into this, wanted to make a pr to complete the functions that are yet to be added

sry for the late, I'm AFKing these days XD, but likely it is caused by local cache! (e.g. you can pass the tests locally because you are running on cache)

clearloop avatar Oct 11 '25 03:10 clearloop

@clearloop are you still looking into this, wanted to make a pr to complete the functions that are yet to be added

sry for the late, I'm AFKing these days XD, but likely it is caused by local cache! (e.g. you can pass the tests locally because you are running on cache

But I cleared it by running cargo clean before running the test and it passed

Timosdev99 avatar Oct 11 '25 11:10 Timosdev99

blocked by #337

clearloop avatar Oct 15 '25 08:10 clearloop