-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Fix Bytes
, Vec
and String
buffer ownership
#6142
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Benchmark for 746b0faClick to view benchmark
|
Benchmark for 63595e5Click to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
June 22, 2024 09:22
ef917df
to
51fa76d
Compare
Benchmark for 04f1b88Click to view benchmark
|
Benchmark for 15ecc8eClick to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
June 24, 2024 13:00
2231a36
to
0184dad
Compare
Benchmark for 2fd48e5Click to view benchmark
|
Benchmark for 3cc7e6dClick to view benchmark
|
Benchmark for f92675fClick to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
June 25, 2024 07:32
993f345
to
1d49b98
Compare
Benchmark for 5ff35a0Click to view benchmark
|
Benchmark for 8e33560Click to view benchmark
|
Benchmark for 3228c41Click to view benchmark
|
xunilrj
changed the title
Fix
Fix Jun 25, 2024
std::Bytes
buffer ownershipBytes
, Vec
and String
buffer ownership
Benchmark for c593846Click to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
June 27, 2024 12:55
8512164
to
afe8bdd
Compare
Benchmark for 85b15ceClick to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
June 27, 2024 16:09
afe8bdd
to
79d17bb
Compare
Benchmark for 6c51ec1Click to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
June 28, 2024 14:35
79d17bb
to
1856980
Compare
Benchmark for c44da0aClick to view benchmark
|
IGI-111
added
the
breaking
May cause existing user code to break. Requires a minor or major release.
label
Jul 1, 2024
IGI-111
previously approved these changes
Jul 1, 2024
Benchmark for 040c3a6Click to view benchmark
|
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
July 2, 2024 06:36
fcb18c9
to
f9372bd
Compare
xunilrj
force-pushed
the
xunilrj/make-bytes-own-buffer
branch
from
July 8, 2024 16:12
02e1c09
to
d51cb05
Compare
Benchmark for 172fa09Click to view benchmark
|
JoshuaBatty
approved these changes
Jul 8, 2024
IGI-111
approved these changes
Jul 8, 2024
Benchmark for b913132Click to view benchmark
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a problem with
std::Bytes
,std::Vec
andstd::String
buffer ownership. It also fixes a problem with buffer overflow when encoding huge types.Buffer Ownership
Currently, types like
Bytes
,Vec
andString
do not guarantee ownership of their buffer. That means that we can very easily alias the underlying buffer and change its mutability by simply creating a new instance.For example:
Type Inference bug
I also had to fix a small problem with the type inference of method applications. The problem is that sometimes the type check does not return an error on the first pass, but the type is still not concrete.
For example
x.get(0) == Some(2)
, becomeseq(x.get(0), Some(2))
.After the first pass,
x.get(0)
is correctly inferred to beOption<u8>
; butSome(2)
is only typed asOption<Numeric>
. This happens because the first pass starts withTypeInfo::Unknown
. We can use the argument types here because they may still be non-concrete types like "Self".What the fix is doing is that it checks if the inferred type
is_concrete
, assuming thatNumeric
is not. This will make "Some(2)" be type-checked again at the second pass, after monomorphization and be correctly typed as "Option".IR Verification errors
This PR also improves the error message for IR verification. Now the error is shown inside the printed IR.
Script to update contract-ids (optional)
At
test/update-contract-ids.sh
there is a small script that automatically updates contract ids. Unfortunately, given the indirect nature of contract calls, it is impossible for the script to know which contract it needs to compile. So we need to specify the path to the contract.We also need to pass the compiler flags, because in some cases we use
debug
profile, and in others we userelease
.In the example above, the path and flags are appended in the bash script. I failed trying to inject commands, so I think the append is safe.
I can remove this from the PR, if we find that this is not the solution we want at the moment.
Checklist
Breaking*
orNew Feature
labels where relevant.