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 print functionality to Soroban contracts #1659

Conversation

salaheldinsoliman
Copy link
Contributor

@salaheldinsoliman salaheldinsoliman commented Jul 14, 2024

This PR adds static string print functionality to Soroban contracts. This serves the following:

  1. print() statements
  2. Logging runtime errors.

However, the following findings might be interesting:
In both Solana and Polkadot, the VM execution capacity can grasp a call to vector_new in the stdlib: https://github.com/hyperledger/solang/blob/06798cdeac6fd62ee98f5ae7da38f3af4933dc0f/stdlib/stdlib.c#L167

However, Soroban doesn't. That's why Soroban would need Solang to implement a more efficient way of printing dynamic strings.
@leighmcculloch

loc,
ty,
size: _,
initializer,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should really be: initializer: Some(initializer),

src/lib.rs Outdated
@@ -95,7 +95,7 @@ impl Target {

/// Size of a pointer in bits
pub fn ptr_size(&self) -> u16 {
if *self == Target::Solana {
if *self == Target::Solana || *self == Target::Soroban {
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought Soroban uses wasm which has 32 bit address space, unless it's wasm64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, that was a typo

@salaheldinsoliman
Copy link
Contributor Author

@seanyoung Can I get a second look on this one?

Comment on lines 494 to 497
run: |
export DBUS_SESSION_BUS_ADDRESS=/dev/null
export NO_AT_BRIDGE=1
xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" npm test -- --disable-gpu
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes don't fix the issue of the vscode test not working. For some reason the tap package is not installed, it's not xvfb-run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me just remove that and address it in a further PR then

@seanyoung
Copy link
Contributor

LGTM, thank you!

Signed-off-by: salaheldinsoliman <[email protected]>
@salaheldinsoliman salaheldinsoliman merged commit 420fbb8 into hyperledger-solang:main Sep 12, 2024
12 checks passed
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.

2 participants