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

Add support for Soroban external calls 🎉 #1679

Conversation

salaheldinsoliman
Copy link
Contributor

This PR adds support for Soroban external calls. This is the first step to support value transfers from inside Soroban contracts.
What a follow up PR should do is support encoding/decoding of a bigger range of value types.

Signed-off-by: salaheldinsoliman <[email protected]>
@salaheldinsoliman salaheldinsoliman force-pushed the feat/soroban-cross-contract branch from a659b6a to 2708969 Compare January 26, 2025 11:25
@salaheldinsoliman salaheldinsoliman marked this pull request as ready for review January 26, 2025 11:26
Signed-off-by: salaheldinsoliman <[email protected]>
Signed-off-by: salaheldinsoliman <[email protected]>
Signed-off-by: salaheldinsoliman <[email protected]>
Signed-off-by: salaheldinsoliman <[email protected]>
@salaheldinsoliman salaheldinsoliman self-assigned this Jan 26, 2025
Copy link
Contributor

@seanyoung seanyoung left a comment

Choose a reason for hiding this comment

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

Please rename Expression::PointerPosition

Looks great otherwise!

Comment on lines 2152 to 2160
Expression::PointerPosition { pointer } => {
let ptr = expression(target, bin, pointer, vartab, function, ns);
let data = bin.vector_bytes(ptr);
let res = bin
.builder
.build_ptr_to_int(data, bin.context.i64_type(), "sesa");

res.unwrap().into()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please help me understand Expression::PointerPosition . It takes a vector (e.g. Type::DynamicString), gets the pointer and converts the pointer to i64 (even though pointers are 32 bit in wasm).

How about renaming it to Expression::VectorData ?

Copy link
Contributor Author

@salaheldinsoliman salaheldinsoliman Feb 8, 2025

Choose a reason for hiding this comment

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

The expression is used to get the ptr position in linear memory as an i64, then it is passed to Soroban's host (as a param to a host function that needs it)
The i64 rationale is that Soroban host always takes i64 values. And that expression is only used in Soroban at the moment

Signed-off-by: salaheldinsoliman <[email protected]>
Signed-off-by: salaheldinsoliman <[email protected]>
Signed-off-by: salaheldinsoliman <[email protected]>
@salaheldinsoliman salaheldinsoliman merged commit 07ad1a1 into hyperledger-solang:main Feb 8, 2025
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants