Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
salaheldinsoliman committed Apr 19, 2024
2 parents 6ede969 + be8cc21 commit 35044f4
Show file tree
Hide file tree
Showing 93 changed files with 838 additions and 371 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/[email protected]
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Build
run: cargo build --verbose --release
- name: Run tests
Expand All @@ -38,7 +38,7 @@ jobs:
uses: actions/[email protected]
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Build
run: cargo build --verbose --release
- name: Run tests
Expand All @@ -65,7 +65,7 @@ jobs:
run: unzip c:\llvm.zip -d c:/
- name: Add LLVM to Path
run: echo "c:\llvm16.0\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
with:
components: clippy
- name: Build
Expand All @@ -88,7 +88,7 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Get LLVM
run: curl -sSL --output llvm16.0-mac-arm.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm16-0/llvm16.0-mac-arm.tar.xz
- name: Extract LLVM
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Get LLVM
run: wget -q -O llvm16.0-mac-intel.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm16-0/llvm16.0-mac-intel.tar.xz
- name: Extract LLVM
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.72.0
toolchain: 1.74.0
components: |
llvm-tools
clippy
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Build
run: cargo build --verbose
- name: Run tests
Expand All @@ -144,7 +144,7 @@ jobs:
# Use C:\ as D:\ might run out of space
- name: "Use C: for rust temporary files"
run: echo "CARGO_TARGET_DIR=C:\target" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
with:
components: clippy
# We run clippy on Linux in the lint job above, but this does not check #[cfg(windows)] items
Expand All @@ -170,7 +170,7 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Get LLVM
run: curl -sSL --output llvm16.0-mac-arm.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm16-0/llvm16.0-mac-arm.tar.xz
- name: Extract LLVM
Expand All @@ -196,7 +196,7 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Get LLVM
run: wget -q -O llvm16.0-mac-intel.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm16-0/llvm16.0-mac-intel.tar.xz
- name: Extract LLVM
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- name: Setup yarn
run: npm install -g yarn
- uses: actions/download-artifact@v3
Expand Down Expand Up @@ -309,7 +309,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: dtolnay/rust-toolchain@1.72.0
- uses: dtolnay/rust-toolchain@1.74.0
- uses: actions/download-artifact@v3
with:
name: solang-linux-x86-64
Expand Down Expand Up @@ -348,7 +348,7 @@ jobs:
# We can't run substrate node as a github actions service, since it requires
# command line arguments. See https://github.com/actions/runner/pull/1152
- name: Start substrate contracts node
run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:ad6da01 substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:62a8a6c substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
id: substrate
- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -390,7 +390,7 @@ jobs:
# We can't run substrate node as a github actions service, since it requires
# command line arguments. See https://github.com/actions/runner/pull/1152
- name: Start substrate
run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:ad6da01 substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
run: echo id=$(docker run -d -p 9944:9944 ghcr.io/hyperledger/solang-substrate-ci:62a8a6c substrate-contracts-node --dev --rpc-external -lwarn,runtime::contracts=trace) >> $GITHUB_OUTPUT
id: substrate
- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -486,7 +486,7 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.72.0
toolchain: 1.74.0
components: llvm-tools
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
Expand Down
24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "Apache-2.0"
build = "build.rs"
description = "Solang Solidity Compiler"
keywords = [ "solidity", "compiler", "solana", "polkadot", "substrate" ]
rust-version = "1.72.0"
rust-version = "1.74.0"
edition = "2021"
exclude = [ "/.*", "/docs", "/examples", "/solana-library", "/tests", "/integration", "/vscode", "/testdata" ]

Expand All @@ -21,8 +21,8 @@ rand = "0.8"
num-bigint = { version = "0.4", features = ["rand"]}
num-traits = "0.2"
num-integer = "0.1"
clap = {version = "4.1", features = ["derive"]}
clap_complete = "4.1"
clap = {version = "4.5", features = ["derive"]}
clap_complete = "4.5"
hex = "0.4"
tiny-keccak = { version = "2.0", features = ["keccak"] }
serde_json = "1.0"
Expand All @@ -31,9 +31,9 @@ serde_derive = { version = "1.0" }
inkwell = { version = "0.4.0", features = ["target-webassembly", "no-libffi-linking", "llvm16-0"], optional = true }
blake2-rfc = "0.2.18"
handlebars = "5.1"
contract-metadata = "3.2"
contract-metadata = "4.0.2"
semver = { version = "1.0", features = ["serde"] }
tempfile = "3.9"
tempfile = "3.10"
libc = { version = "0.2", optional = true }
tower-lsp = { version = "0.20", optional = true }
tokio = { version = "1.27", features = ["rt", "io-std", "macros"], optional = true }
Expand All @@ -54,15 +54,15 @@ anchor-syn = { version = "0.29.0", features = ["idl-build"] }
convert_case = "0.6"
parse-display = "0.9"
parity-scale-codec = "3.6"
ink_env = "4.3.0"
ink_metadata = "4.3.0"
ink_env = "5.0.0"
ink_metadata = "5.0.0"
scale-info = "2.10"
petgraph = "0.6"
wasmparser = "0.121.0"
wasm-encoder = "0.41"
wasmparser = "0.202.0"
wasm-encoder = "0.202"
toml = "0.8"
wasm-opt = { version = "0.113.0", optional = true }
contract-build = { version = "3.2", optional = true }
wasm-opt = { version = "0.116.0", default-features = false, optional = true }
contract-build = { version = "4.0.2", optional = true }
primitive-types = { version = "0.12", features = ["codec"] }
normalize-path = "0.2.1"
bitflags = "2.4"
Expand Down Expand Up @@ -90,7 +90,7 @@ borsh = "1.1"
borsh-derive = "1.1"
rayon = "1"
walkdir = "2.4"
ink_primitives = "4.3.0"
ink_primitives = "5.0.0"
wasm_host_attr = { path = "tests/wasm_host_attr" }
num-bigint = { version = "0.4", features = ["rand", "serde"]}

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY . src
WORKDIR /src/stdlib/
RUN make

RUN rustup default 1.72.0
RUN rustup default 1.74.0

WORKDIR /src
RUN cargo build --release
Expand Down
1 change: 1 addition & 0 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
| Sean Young | [@seanyoung](https://github.com/seanyoung) | seanyoung#0481 |
| Lucas Steuernagel | [@LucasSte](https://github.com/LucasSte) | LucasSte#2331 |
| Cyrill Leutwiler | [@xermicus](https://github.com/xermicus) | kägifret#8095 |
| Salaheldin Soliman| [@salaheldinsoliman](https://github.com/salaheldinsoliman) | salaheldinsoliman |
2 changes: 1 addition & 1 deletion docs/aqd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Solang Aqd simplifies this process by accepting these parameters as command-line
Additionally, it ensures the submitted transaction aligns with the expected values in the Interface Description Language (IDL).

.. note::
If unsure, you can always check the expected arguements and accounts for a specific function by using the ``show`` subcommand.
If unsure, you can always check the expected arguments and accounts for a specific function by using the ``show`` subcommand.

Options specific to the ``call`` subcommand:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/code_gen_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Dead Storage pass

Loading from contract storage, or storing to contract storage is expensive. This optimization removes any
redundant load from and store to contract storage. If the same variable is read twice, then the value from
the first load is re-used. Similarly, if there is are two successive stores to the same variable, the first
the first load is re-used. Similarly, if there are two successive stores to the same variable, the first
one is removed as it is redundant. For example:

.. include:: ./examples/dead_storage_elimination.sol
Expand Down
2 changes: 1 addition & 1 deletion docs/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Option 5: Build Solang from source

In order to build Solang from source, you will need:

* Rust version 1.72.0 or higher
* Rust version 1.74.0 or higher
* A C++ compiler with support for C++17
* A build of LLVM based on the Solana LLVM tree. There are a few LLVM patches required that are not upstream yet.

Expand Down
14 changes: 8 additions & 6 deletions docs/language/events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ syntax.
be passed for Solana's ``sol_log_data`` system call, regardless if the ``indexed`` keyword is present or not.
This behavior follows what Solana's Anchor framework does.

In Polkadot, the topic fields are always the hash of the value of the field. Ethereum only hashes fields
which do not fit in the 32 bytes. Since a cryptographic hash is used, it is only possible to compare the topic against a
known value.
In Polkadot, field topics are culculated the same as in `ink! v5.0 <https://use.ink/basics/events/#topics>`_:
Topic fields are either the encoded value of the field or its blake2b256 hash
if the encoded value length exceeds 32 bytes.

An event can be declared in a contract, or outside.

Expand All @@ -49,8 +49,10 @@ make it clearer which exact event is being emitted.
.. include:: ../examples/event_positional_fields.sol
:code: solidity

In the transaction log, the first topic of an event is the keccak256 hash of the signature of the
event. The signature is the event name, followed by the fields types in a comma separated list in parentheses. So
the first topic for the second UserModified event would be the keccak256 hash of ``UserModified(address,uint64)``.
In the transaction log, the topic of an event is the blake2b256 hash of the signature of the
event. The signature is the event name, followed by the fields types in a comma separated list in parentheses,
like event signatures in `Ethereum Solidity <https://docs.soliditylang.org/en/v0.8.25/abi-spec.html#events>`_. So
the first topic for the second UserModified event would be the blake2b256 hash of ``UserModified(address,uint64)``.
You can leave this topic out by declaring the event ``anonymous``. This makes the event slightly smaller (32 bytes
less) and makes it possible to have 4 ``indexed`` fields rather than 3.

2 changes: 1 addition & 1 deletion docs/language/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The ``using`` declaration can be done on file scope. In this case, the type must
be specified in place of ``*``. The first argument must match the type that is
be used in the ``using`` declaration.

If a user-defined type is used, the the ``global`` keyword can be used. This
If a user-defined type is used, the ``global`` keyword can be used. This
means the ``using`` binding can be used in any file, even when the type is
imported.

Expand Down
6 changes: 3 additions & 3 deletions docs/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Solidity parser and semantics tests
In the `tests <https://github.com/hyperledger/solang/tree/main/tests>`_ directory, there are
a lot of tests which call `fn parse_and_resolve()`. This function parses Solidity, and returns
the *namespace*: all the resolved contracts, types, functions, etc (as much as could be resolved),
and all the compiler diagnositics, i.e. compiler warnings and errors. These tests check that
and all the compiler diagnostics, i.e. compiler warnings and errors. These tests check that
the compiler parser and semantic analysis work correctly.

Note that Solidity can import other soldity files using the ``import`` statement. There are further
tests which create a file cache with filenames and and their contents, to ensure that imports
Note that Solidity can import other solidity files using the ``import`` statement. There are further
tests which create a file cache with filenames and their contents, to ensure that imports
work as expected.


Expand Down
2 changes: 2 additions & 0 deletions integration/anchor/tests/call_anchor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { AnchorProvider, Program } from '@coral-xyz/anchor';
import {
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/UniswapV2ERC20.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { weight, createConnection, deploy, transaction, aliceKeypair, daveKeypair, query } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down
4 changes: 3 additions & 1 deletion integration/polkadot/UniswapV2Factory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { weight, createConnection, deploy, transaction, aliceKeypair, daveKeypair, query } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down Expand Up @@ -58,7 +60,7 @@ describe('UniswapV2Factory', () => {

let events: DecodedEvent[] = res0.contractEvents;
expect(events.length).toEqual(1)
expect(events[0].event.identifier).toBe('PairCreated')
expect(events[0].event.identifier).toBe('UniswapV2Factory::PairCreated')
expect(events[0].args[0].toString()).toBe(TEST_ADDRESSES[0])
expect(events[0].args[1].toString()).toBe(TEST_ADDRESSES[1])
expect(events[0].args[3].eq(1)).toBeTruthy();
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/UniswapV2Pair.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { weight, query, createConnection, deploy, transaction, aliceKeypair, daveKeypair } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/array_struct_mapping_storage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { weight, createConnection, deploy, aliceKeypair, transaction, query } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/arrays.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import crypto from 'crypto';
import { createConnection, deploy, transaction, aliceKeypair, weight, query, } from './index';
Expand Down
6 changes: 4 additions & 2 deletions integration/polkadot/asserts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { weight, createConnection, deploy, transaction, aliceKeypair, query, } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down Expand Up @@ -42,8 +44,8 @@ describe('Deploy asserts contract and test', () => {
throw new Error("should not succeed");
}, (res) => res);

// Error 25 is ContractReverted
expect(res2.dispatchError.toHuman()).toEqual({ "Module": { "error": "0x19000000", "index": "8" } });
// Error 26 is ContractReverted
expect(res2.dispatchError.toHuman()).toEqual({ "Module": { "error": "0x1a000000", "index": "8" } });

let res3 = await query(conn, alice, contract, "var");

Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/balances.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { weight, createConnection, deploy, transaction, aliceKeypair, daveKeypair, query } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# SPDX-License-Identifier: Apache-2.0

set -e

dup_contracts=$(grep -r '^contract .* {' | grep -v node_modules | awk '{ print $2 }' | sort | uniq -d)
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/builtins.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { createConnection, deploy, transaction, aliceKeypair, query, } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down
2 changes: 2 additions & 0 deletions integration/polkadot/builtins2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { createConnection, deploy, aliceKeypair, weight, query } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down
6 changes: 4 additions & 2 deletions integration/polkadot/call_flags.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: Apache-2.0

import expect from 'expect';
import { createConnection, deploy, aliceKeypair, query, debug_buffer, } from './index';
import { ContractPromise } from '@polkadot/api-contract';
Expand Down Expand Up @@ -54,9 +56,9 @@ describe('Deploy the CallFlags contract and tests for various call flag combinat
const flags = [CallFlags.TAIL_CALL];
const answer = await query(conn, alice, contract, "echo", [contract.address, foo, voyager, flags]);
const { index, error } = answer.result.asErr.asModule;
// Module 8 error 0x15 is ReentranceDenied in the contracts pallet
// Module 8 error 0x16 is ReentranceDenied in the contracts pallet
expect(index.toJSON()).toStrictEqual(8);
expect(error.toJSON()).toStrictEqual("0x15000000");
expect(error.toJSON()).toStrictEqual("0x16000000");
});

it('fails with the input forwarding flag', async function () {
Expand Down
Loading

0 comments on commit 35044f4

Please sign in to comment.