Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 10 2017 22:42
    @jpitts banned @etherchamp1_twitter
  • Jun 05 2016 10:33
    @chriseth banned @adamskee
gggg
@novaknole:matrix.org
[m]
1000 slots for no reason. maybe there's something i am missing that we can do to this code to make it better
ekpyron
@daniel:ekpyron.org
[m]
You can try uint[1000] memory bla; test(bla); with function test(uint[1000] memory a) internal { a[0] = ...; }?
gggg
@novaknole:matrix.org
[m]
haha makes sense
you made it internal so memory copy to memory wouldn't happen
ekpyron
@daniel:ekpyron.org
[m]
It could stay public, as long as you call it internally.
gggg
@novaknole:matrix.org
[m]
yeah, public would work too for this case
ekpyron
@daniel:ekpyron.org
[m]
(just made it internal to emphasize it a bit ;-))
gggg
@novaknole:matrix.org
[m]
One more example and that should be it .. this is more interesting
function another() external returns(bytes memory){

       bytes memory k = hex"94C3";
       return k;

   }
it's really strange that 94C3 appears two times
isn't it ?
ekpyron
@daniel:ekpyron.org
[m]
I'd need to look into it... but it's well possible that currently the literal is allocated as temporary in memory from which a copy happens... there might actually be in-progress work to have the compiler avoid that (but I'm also not sure about that)...
But in general there's a lot of room to improve memory handling in solidity - we're working on it ;-).
gggg
@novaknole:matrix.org
[m]
Thanks a lot ekpyron for all the help.. 🤗
ekpyron
@daniel:ekpyron.org
[m]
👍️
hrkrshnn
@hrkrshnn:matrix.org
[m]
iirc, switching to --via-ir would already decrease some unnecessary memory allocations when compared to the current codegen. If you absolutely want cheaper code, this might be a solution for now.
gggg
@novaknole:matrix.org
[m]
hrkrshnn: I think the above example was compiled with --ir and it still produced the memory as I showed
i guess, sometimes it could help, but not in this case
cameel
@cameel:matrix.org
[m]
ekpyron: I think the above with some memory slots being allocated and unused is the effect of the bug that was fixed in ethereum/solidity#10341.
And the duplicate 94C3 comes from the fact that memory is always allocated for the return variable, even if the compiler could just reuse the variable that is being returned.
ekpyron
@daniel:ekpyron.org
[m]
Well possible!
Mitchell
@Mitchel23597421_twitter

Hi, we (my brother and me) build a algorithmic hedging protocol. The goal of hedgehog is to allow fully decentralized chain hedging against depreciation of on chain assets. Please look at the site for more information. We are curious about your opinion and if you would like to promote this towards your community? Please let me know and if you have further questions please let us know!

Kind regards,

Mitchell & Kevin Foesenek

https://hedgehog.financial

Antony Luvera
@_Anarz_twitter
Hi, I am working on a contract to implement interaction with an external contract which require to input a structure as a function parameter. This structure include a bytes type value and actually Remix doesnt compile if I use the exact same structure but it does if I replace bytes by bytes32, I was wondering if it will be interpreted the same way by the external contract ? My contract needs to be compiled with 0.7.6 and the target contract was compiled with 0.5.12. Maybe it can help to answer: If I disable optimization, the contract compile but with the Contract code size exceeds 24576 bytes message. I dont understand how optimization and bytes type are linked and why Remix isnt throwing me any error when the compilation fails, he just doesnt compile with bytes type in a struct (any struct, even in a called library..).
cameel
@cameel:matrix.org
[m]
@_Anarz_twitter: Can you show a small example that does not compile for you?
I'm not sure I understand the issue just from you description.
Antony Luvera
@_Anarz_twitter

Actually it concerns a large code base, it works if I try something like this :

pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;

//SPDX-License-Identifier: UNLICENSED

contract FailCompilation {
struct Test {
bytes Value;
}
}

but thats exactly the issue. In my contract, if I add any struct that contains a bytes value, Remix compiler wont compile and doesnt throw any error, but it works if I use bytes32 instead of bytes. Only if I enable optimization, without optimization I just have the Contract code size exceeds 24576 bytes warning from Remix but the compilation is done.

image.png
cameel
@cameel:matrix.org
[m]

Remix compiler wont compile and doesnt throw any error

This is weird.
Could you try to compile it locally with solc? That would remove some layers in between and might make the problem easier to diagnose.

It could be that your code is just crashing the compiler and remix does not show it. Compiling with solc would give you at least the location of the crash in the source, even if there's no message attached.
Antony Luvera
@_Anarz_twitter
Compiler error: Stack too deep when compiling inline assembly: Variable dataEnd is 2 slot(s) too deep inside the stack.
I confirm that the exact same code with bytes32 instead of bytes is successfully compiling with solc and optimization enabled
robinbryce
@robinbryce
hi, is there any way to issue CREATE2 so that the sender is an EOA ?
4 replies
cameel
@cameel:matrix.org
[m]
@_Anarz_twitter: Well, then you might want to try 0.8.2 and see if it helps. It has some new optimizations compared to 0.7.6. Other than that, you can try to restructure your code a bit to pack some locals and/or parameters into structs.
This is an ongoing issue that we're trying to solve with the optimizer but there are only 16 stack slots reachable at any given time so it's not that easy.
I wonder if we could do something to make this easier to debug though. The error not showing up in Remix is definitely a problem in my opinion.
Antony Luvera
@_Anarz_twitter
I'm having other issues with 0.8.2 but ok I'll try to solve since I have an error for them, I'll tell you how its going asap
Antony Luvera
@_Anarz_twitter
Exactly the same with 0.8.2..
Parv Garg
@parv3213
Does Slither work for Solidity 0.8.1? It does not seem to work for me. Any suggestions?
sobolevigor986
@sobolevigor986

Hi! I wonder, why does this code compile?

contract C {
    function foo() external pure returns (bytes memory) {
        return abi.encodePacked("b" "a" "r");
    }
}

This violates the language grammar, I suppose.

gggg
@novaknole:matrix.org
[m]
It should compile
Because you pass one single string
sobolevigor986
@sobolevigor986
According lo language grammar, I should use commas between args ("b","a","r")
gggg
@novaknole:matrix.org
[m]
Yeah but the way you use it is still one string
Read string literals in solidity docs
Your syntax is the same as concatinating strings
sobolevigor986
@sobolevigor986
Снимок экрана 2021-03-06 в 19.50.42.png
Oh, I see the line about concatenation in docs, thanks)
But I still don't understand the schema in grammar docs ^
gggg
@novaknole:matrix.org
[m]
Which part ? I am no expert though 😂
sobolevigor986
@sobolevigor986
oh, now I found a place that I looked for! thanks for help)
Снимок экрана 2021-03-06 в 19.55.43.png
ratata
@ratata54796953_twitter
Hello there! I m new to programming, i know only basics, should i learn solidity through or go for better algorithms and data structres?
gggg
@novaknole:matrix.org
[m]

Hi everyone..

I have the following:

static combinedHash(first: Buffer, second: Buffer): Buffer {
    if (!first) {
      return second
    }
    if (!second) {
      return first
    }


    return keccak256(MerkleTree.sortAndConcat(first, second))
  }

keccak256 is imported from ethereumjs-utils

It seems like that keccak256 returns Buffer . I don't know why.

What I am trying to do is I want to change keccak256 from ethereumjs-utils to ethers/lib/utils, but new keccak256 doesn't return buffer. I tried lots of things, but the results are different. any ideas ?