Skip to content

Anchor fix#1

Open
seanyoung wants to merge 589 commits intomainfrom
anchor-fix
Open

Anchor fix#1
seanyoung wants to merge 589 commits intomainfrom
anchor-fix

Conversation

@seanyoung
Copy link
Copy Markdown
Owner

No description provided.

xermicus and others added 30 commits June 23, 2023 14:08
)

A try catch statement does not need to decode the return values if it is not interested.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
…yperledger-solang#1374)

If the acessor function returns a single struct, then the members should be returned. If
any of those members are structs, then those members will remain structs.

	contract C {
		struct S { int a; bool b; }

		S public s;

		function foo() public {
			(int a, bool b) = this.s();
		}
	}

Also, the accesor function should be declared `external` and therefore not accessible
as an internal function call.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: xermicus <cyrill@parity.io>
Solana 1.16.1
Ubuntu 22.04 rather than 20.04
Anchor 0.28.0

Signed-off-by: Sean Young <sean@mess.org>
…lang#1384)

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
…cally allocated (hyperledger-solang#1400)

Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
* Added get_file_contents_of_file_no

Signed-off-by: Ben Kushigian <ben.kushigian@certora.com>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
…structors

Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: xermicus <cyrill@parity.io>
Signed-off-by: Lucas Steuernagel <lucas.tnagel@gmail.com>
Signed-off-by: Govardhan G D <chioni1620@gmail.com>
seanyoung and others added 30 commits February 10, 2025 17:12
This should be compiled as: function returning void

Fixes: hyperledger-solang#1727

Signed-off-by: Sean Young <sean@mess.org>
This PR adds support for `extendPersistentTtl()` method in Soroban,
along with a test and documentation. Also, the Soroban testing
infrastructure has been refactored to allow more flexible environment
manipulation.

[Documentation for
`extend_ttl`](https://developers.stellar.org/docs/build/smart-contracts/getting-started/storing-data#managing-contract-data-ttls-with-extend_ttl)
Fixes hyperledger-solang#1669

#### Changes 
- Added support for `extendPersistentTtl` as a method on `uint64` for
the Soroban target.
- In the Soroban SDK, `extend_ttl` is a generic function (`IntoVal<Env,
Val>`)
```rust
pub fn extend_ttl<K>(&self, key: &K, threshold: u32, extend_to: u32)
where
    K: IntoVal<Env, Val>,
```
but Solidity does not support that, so it's implemented as a method
instead.
- One assertion in the `different_storage_types` test is affected due to
changes in diagnostic capture. A follow-up PR will address this.

---------

Signed-off-by: Tarek <tareknaser360@gmail.com>
)

This PR aims to support Soroban authorization framework: 
-
https://github.com/stellar/stellar-protocol/blob/master/core/cap-0046-11.md
-
https://developers.stellar.org/docs/build/smart-contracts/example-contracts/auth

Here are some keynotes to consider:

1- Unlike Solidity, Soroban performs its auth checks using the host. For
instance, Soroban doesn't have the construct of `if msg.sender == addr`,
however this check is done via a host function `addr.require_auth`.

2- Another function was added `authAsCurrContract`. This is needed for
deeper calls. To understand this, take a look at
https://github.com/stellar/soroban-examples/tree/main/deep_contract_auth.
What I have done here actually is test the auth framework using the
above provided example of nested calls.

---------

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
This PR aims to do the following:
1- Add a proper framework for Soroban encoding/decoding scheme
(https://github.com/stellar/stellar-protocol/blob/master/core/cap-0046-01.md),
so it is easier for further contributions to support other types.
2- Add support for integers of bit-width 128, to serve as an example for
other contributions.

---------

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: Samuel Moelius <35515885+smoelius@users.noreply.github.com>
- Fix rust 1.86.0 clippies
- Build with rust 1.82.0 - required by dependencies
- Remove repolinter as it is not working and no longer required by
hyperledger

Signed-off-by: Sean Young <sean@mess.org>
This PR fixes hyperledger-solang#1684 by checking the statuses of two commands in the
build.rs file.

Signed-off-by: Samuel Moelius <sam@moeli.us>
This PR fixes infinite lops in the reaching definitions and dead storage
code.

The two added test files are based on ones from Solidity:
-
https://github.com/ethereum/solidity/blob/develop/test/libsolidity/smtCheckerTests/loops/do_while_break_2.sol
-
https://github.com/ethereum/solidity/blob/develop/test/libsolidity/smtCheckerTests/loops/do_while_break_2_fail.sol

If you add `dbg!(block_no)` between the next two lines and run Solang on
either of the test files, you will find that a block is visited
repeatedly:
https://github.com/hyperledger-solang/solang/blob/279ee911260d74c78acace41d753c5376a7e942e/src/codegen/reaching_definitions.rs#L56-L57

If you fix that infinite loop and add `dbg!(block_no)` between the next
two lines, you will again find that a block is visited repeatedly:
https://github.com/hyperledger-solang/solang/blob/279ee911260d74c78acace41d753c5376a7e942e/src/codegen/dead_storage.rs#L109-L110

In both cases, the problem appears to be that edges are added to the
`blocks_todo` queue unconditionally.

My understanding of these algorithms is that they try to iterate to a
fixpoint. Hence, I changed each loop so that:
- a flag records whether a _state change_ has occurred
- at the end of each loop iteration, the edge is added to the queue only
if the flag is set

Furthermore, I analyzed each loop to try to determine what constitutes a
state change. On this point, I invite scrutiny.

Nits are welcome on anything, though.

Signed-off-by: Samuel Moelius <sam@moeli.us>
Signed-off-by: Kwame Bryan <kwame.bryan@gmail.com>

* fixed typo in builtin.rs
Signed-off-by: Maxim Evtush <154841002+maximevtush@users.noreply.github.com>
- "langauge" → "language"
  - "accaptable" → "acceptable"
  - "transction" → "transaction"
  - "adeds" → "added"
  - "debuging" → "debugging"
  - "succesful" → "successful"
  - "vallues" → "values"
  - "overriden" → "overridden"

Signed-off-by: Tomás Andróil <tomasandroil@gmail.com>
One is in an assertion message. All others are in comments.

Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
)

From what I can tell, this change affects no tests.

Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
Some Soroban dependencies require rust version >= 1.84

---------

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Fixes hyperledger-solang#1799 by renaming `binary` to `bin`.

This turned out to be a smaller change than going the other way (1205
replacements vs. 1496).

Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
This is a small bugfix for the case when `abi.encode()` is called with
empty arguments.

Without this change, if you run the following command, you get a panic:
```sh
$ cargo run compile --target=polkadot testdata/solidity/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_v2.sol
...
thread 'main' panicked at src/codegen/encoding/mod.rs:169:46:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
The cause of the panic is this function:
```sol
    function f0() public pure returns (bytes memory) {
        return abi.encode();
    }
```
With the change, the command completes successfully.

Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
The PR's main change is to store a reference to the `Namespace` in the
`Binary`:
https://github.com/hyperledger-solang/solang/blob/6fccc021a759153f1d7802e7738d1b52f120e576/src/emit/binary.rs#L153

This saves having to pass the `Namespace` around while emitting code.

I tried to find all functions that take both a `Binary` and `Namespace`
and make it so that they instead take just a `Binary` and access the
`Namespace` therefrom, but I'm not 100% certain I found all such
functions.

All tests pass for me locally following these changes.

Signed-off-by: Samuel Moelius <samuel.moelius@trailofbits.com>
`base64ct` requires rust 1.85:

https://github.com/hyperledger-solang/solang/actions/runs/15507747207/job/43664695727#step:6:19

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
…dger-solang#1786)

Fixes hyperledger-solang#1677

---------

Signed-off-by: Tarek <tareknaser360@gmail.com>
Co-authored-by: salaheldinsoliman <49910731+salaheldinsoliman@users.noreply.github.com>
This PR brings:
- Support for `mappings` in Soroban. 
- Bug fix: support constructors in `codegen`. This will allow
constructors to be called with parameters

---------

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
This PR aims to support a Stellar Asset Contract:
https://developers.stellar.org/docs/tokens/stellar-asset-contract.
This involved:
- Supporting constructors with args
- Bug fix in mappings support
- Accepting strings as args

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: Sean Young <sean@mess.org>
Co-authored-by: Sean Young <sean@mess.org>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: Sean Young <sean@mess.org>
Co-authored-by: Sean Young <sean@mess.org>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: Pratyksh <pratykshgupta9999@gmail.com>
)

Xermicus made huge improvements to the Polkadot target. Lucas made huge
improvements to the Solana target and optimization passes of the
compiler.

We thank both for their code contributions and their many ideas. We hope
to see you again.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Sean Young <sean@mess.org>
Note that inkwell 0.6.0 does not work with Soroban yet. Something for a
later date.

Signed-off-by: Sean Young <sean@mess.org>
…1821)

Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Co-authored-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Co-authored-by: salaheldinsoliman <49910731+salaheldinsoliman@users.noreply.github.com>
Signed-off-by: Sean Young <sean@mess.org>
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.