Skip to content

Commit efa9648

Browse files
committed
Cairo v0.13.1.
1 parent ab6d079 commit efa9648

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+423
-359
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN ./docker_common_deps.sh
1414
RUN curl https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.6.12+commit.27d51765 -o /usr/local/bin/solc-0.6.12
1515
RUN echo 'f6cb519b01dabc61cab4c184a3db11aa591d18151e362fcae850e42cffdfb09a /usr/local/bin/solc-0.6.12' | sha256sum --check
1616
RUN chmod +x /usr/local/bin/solc-0.6.12
17-
RUN npm install -g --unsafe-perm ganache@7.4.3 [email protected]
17+
RUN npm install -g --unsafe-perm ganache@7.9.0 [email protected]
1818

1919
COPY . /app
2020
RUN chown -R starkware:starkware /app

WORKSPACE

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ http_file(
3333
],
3434
)
3535

36+
http_file(
37+
name = "solc-0.8.24",
38+
downloaded_file_path = "solc-0.8.24",
39+
executable = True,
40+
sha256 = "fb03a29a517452b9f12bcf459ef37d0a543765bb3bbc911e70a87d6a37c30d5f",
41+
urls = ["https://binaries.soliditylang.org/linux-amd64/solc-linux-amd64-v0.8.24+commit.e11b9ed9"],
42+
)
43+
3644
http_archive(
3745
name = "rules_python",
3846
patch_args = ["-p1"],
@@ -52,7 +60,7 @@ http_archive(
5260
"//src/starkware/starknet/compiler/v1:BUILD." + CAIRO_COMPILER_ARCHIVE,
5361
),
5462
strip_prefix = "cairo",
55-
url = "https://github.com/starkware-libs/cairo/releases/download/v2.6.0-rc.0/release-x86_64-unknown-linux-musl.tar.gz",
63+
url = "https://github.com/starkware-libs/cairo/releases/download/v2.6.0/release-x86_64-unknown-linux-musl.tar.gz",
5664
)
5765

5866
http_archive(

bazel_utils/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ sh_binary(
2020
srcs = ["@solc-0.6.12//file"],
2121
)
2222

23+
sh_binary(
24+
name = "solc-0.8.24",
25+
srcs = ["@solc-0.8.24//file"],
26+
)
27+
2328
py_library(
2429
name = "default_extract_artifacts_lib",
2530
srcs = [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"description": "",
66
"dependencies": {
7-
"ganache": "7.4.4"
7+
"ganache": "7.9.0"
88
},
99
"devDependencies": {},
1010
"author": "",

src/starkware/cairo/common/find_element.cairo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from starkware.cairo.common.math import assert_le, assert_le_felt, assert_nn_le
1+
from starkware.cairo.common.math import assert_le, assert_le_felt, assert_lt_felt, assert_nn_le
22

33
const FIND_ELEMENT_RANGE_CHECK_USAGE = 2;
44

@@ -67,7 +67,7 @@ func find_element{range_check_ptr}(array_ptr: felt*, elm_size, n_elms, key) -> (
6767
// Given an array sorted by its first field, returns the pointer to the first element in the array
6868
// whose first field is at least key. If no such item exists, returns a pointer to the end of the
6969
// array.
70-
// Prover assumption: all the keys (the first field in each item) are in [0, RANGE_CHECK_BOUND).
70+
// Assumption: the array is sorted as unsigned numbers.
7171
func search_sorted_lower{range_check_ptr}(array_ptr: felt*, elm_size, n_elms, key) -> (
7272
elm_ptr: felt*
7373
) {
@@ -105,7 +105,7 @@ func search_sorted_lower{range_check_ptr}(array_ptr: felt*, elm_size, n_elms, ke
105105
}
106106

107107
if (index != 0) {
108-
assert_le_felt(a=[elm_ptr - elm_size] + 1, b=key);
108+
assert_lt_felt(a=[elm_ptr - elm_size], b=key);
109109
}
110110

111111
return (elm_ptr=elm_ptr);
@@ -114,7 +114,7 @@ func search_sorted_lower{range_check_ptr}(array_ptr: felt*, elm_size, n_elms, ke
114114
// Given an array sorted by its first field, returns the pointer to the first element in the array
115115
// whose first field is exactly key. If no such item exists, returns an undefined pointer,
116116
// and success=0.
117-
// Prover assumption: all the keys (the first field in each item) are in [0, RANGE_CHECK_BOUND).
117+
// Assumption: the array is sorted as unsigned numbers.
118118
func search_sorted{range_check_ptr}(array_ptr: felt*, elm_size, n_elms, key) -> (
119119
elm_ptr: felt*, success: felt
120120
) {

src/starkware/cairo/lang/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.13.1a0
1+
0.13.1

src/starkware/cairo/lang/vm/cairo_pie.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -420,22 +420,15 @@ def verify_zip_format(cls, zf: zipfile.ZipFile):
420420
), "Invalid list of inner files in the CairoPIE zip."
421421

422422
# Make sure the file sizes are reasonable.
423-
file_size = lambda name: inner_files[name].file_size if name in inner_files else 0
424-
assert (
425-
file_size(cls.METADATA_FILENAME) < cls.MAX_SIZE
426-
), f"Invalid file size for {cls.METADATA_FILENAME}."
427-
assert (
428-
file_size(cls.MEMORY_FILENAME) < cls.MAX_SIZE
429-
), f"Invalid file size for {cls.MEMORY_FILENAME}."
430-
assert (
431-
file_size(cls.ADDITIONAL_DATA_FILENAME) < cls.MAX_SIZE
432-
), f"Invalid file size for {cls.ADDITIONAL_DATA_FILENAME}."
433-
assert (
434-
file_size(cls.EXECUTION_RESOURCES_FILENAME) < 10000
435-
), f"Invalid file size for {cls.EXECUTION_RESOURCES_FILENAME}."
436-
assert (
437-
file_size(cls.VERSION_FILENAME) < 10000
438-
), f"Invalid file size for {cls.VERSION_FILENAME}."
423+
for name, limit in (
424+
(cls.METADATA_FILENAME, cls.MAX_SIZE),
425+
(cls.MEMORY_FILENAME, cls.MAX_SIZE),
426+
(cls.ADDITIONAL_DATA_FILENAME, cls.MAX_SIZE),
427+
(cls.EXECUTION_RESOURCES_FILENAME, 10000),
428+
(cls.VERSION_FILENAME, 10000),
429+
):
430+
size = inner_files[name].file_size if name in inner_files else 0
431+
assert size < limit, f"Invalid file size {size} for {name}; limit is {limit}."
439432

440433
def get_segment(self, segment_info: SegmentInfo):
441434
return self.memory.get_range(

src/starkware/cairo/sharp/client_lib.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ class ClientLib:
1212
This is a slim wrapper around the SHARP API.
1313
"""
1414

15-
def __init__(self, service_url: str):
15+
def __init__(self, url: str):
1616
"""
1717
service_url is the SHARP url.
1818
"""
19-
self.service_url = service_url
19+
self.url = url
2020

2121
def add_job(self, cairo_pie: CairoPie) -> str:
2222
"""
@@ -48,13 +48,12 @@ def _send(self, action: str, payload: dict) -> dict:
4848
action: the action to be sent to the SHARP.
4949
payload: action specific parameters.
5050
"""
51-
5251
data = {
5352
"action": action,
5453
"request": payload,
5554
}
5655
http = urllib3.PoolManager()
5756
res = http.request(
58-
method="POST", url=self.service_url, body=json.dumps(data).encode("utf-8")
57+
method="POST", url=f"{self.url}{action}", body=json.dumps(data).encode("utf-8")
5958
)
6059
return json.loads(res.data.decode("utf-8"))

src/starkware/cairo/sharp/client_lib_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ class Response:
2323
data: bytes
2424

2525

26+
EXPECTED_URL = "https://some_url/"
27+
28+
2629
def test_add_job(monkeypatch: MonkeyPatch):
27-
expected_url = "some url"
2830
expected_data = {
2931
"action": "add_job",
3032
"request": {"cairo_pie": base64.b64encode(MockCairoPie().serialize()).decode("ascii")},
@@ -34,35 +36,34 @@ def test_add_job(monkeypatch: MonkeyPatch):
3436
# A mock function enforcing expected scenario.
3537
def check_expected(_, method: str, url: str, body: str):
3638
assert method == "POST"
37-
assert url == expected_url
39+
assert url == EXPECTED_URL + expected_data["action"]
3840
assert json.loads(body) == expected_data
3941
return Response(json.dumps({"cairo_job_key": expected_res}).encode("utf-8"))
4042

4143
monkeypatch.setattr(PoolManager, "request", check_expected)
4244

4345
# Test the scenario.
44-
client = ClientLib(expected_url)
46+
client = ClientLib(url=EXPECTED_URL)
4547
res = client.add_job(MockCairoPie())
4648
assert res == expected_res
4749

4850

4951
def test_get_status(monkeypatch: MonkeyPatch):
50-
expected_url = "some url"
5152
expected_id = "some id"
5253
expected_data = {"action": "get_status", "request": {"cairo_job_key": expected_id}}
5354
expected_res = "the status"
5455

5556
# A mock function enforcing expected scenario.
5657
def check_expected(_, method: str, url: str, body: str):
5758
assert method == "POST"
58-
assert url == expected_url
59+
assert url == EXPECTED_URL + expected_data["action"]
5960
assert json.loads(body) == expected_data
6061
return Response(json.dumps({"status": expected_res}).encode("utf-8"))
6162

6263
monkeypatch.setattr(PoolManager, "request", check_expected)
6364

6465
# Test the scenario.
65-
client = ClientLib(expected_url)
66+
client = ClientLib(url=EXPECTED_URL)
6667
res = client.get_status(expected_id)
6768
assert res == expected_res
6869

@@ -76,7 +77,7 @@ def check_expected(_, method: str, url: str, body: str):
7677
monkeypatch.setattr(PoolManager, "request", check_expected)
7778

7879
# Test the scenario.
79-
client = ClientLib("")
80+
client = ClientLib(url=EXPECTED_URL)
8081

8182
with pytest.raises(AssertionError, match="Error when sending job to SHARP:"):
8283
client.add_job(MockCairoPie())
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"prover_url": "https://testnet.provingservice.io",
2+
"url": "https://testnet.provingservice.io/",
33
"verifier_address": "0x07ec0D28e50322Eb0C159B9090ecF3aeA8346DFe",
44
"steps_limit": 1000000
55
}

0 commit comments

Comments
 (0)