These are chat archives for ethereum/solidity

11th
Sep 2016
slothbag
@slothbag
Sep 11 2016 06:01 UTC
:+1: for the latest windows solc build. Now I don't have to transfer to mac and then back again :)
slothbag
@slothbag
Sep 11 2016 06:26 UTC
is there any cost/performance penalty for nesting all contract storage variables into one root variable? I want to do this to simplify passing ALL the state into a library
btravel
@btravel
Sep 11 2016 12:07 UTC

Hi, all! I'm trying to understand the EVM memory addresing. As I understand 0x40 is reserved and stores a word that points to the next available memory slot. So, at the begining of a function execution it stores 0x60 (0x40 + 0x20 (32 bytes) ). So, I can start writing:

function foo() {
        uint p;
        assembly {
            p := mload(0x40);
            mstore(p, 123); /* 123 saved at 0x60 */
        }
}

If I invoke another function and I don't want to remember the current free memory pointer I should update the 0x40 slot after all mstore invocations.

My question is for what purpose 0x40 was reserved? I've checked the first two words (0x0 and 0x20) - they store zeros. So, why I need to start from 0x60 and not from 0x0?

Yoichi Hirai
@pirapira
Sep 11 2016 12:15 UTC
0x00 and 0x20 are used to store arguments before using the EVM SHA3 instruction.
Some EVM instrucitons require the inputs to be on the memory.
(I guess 0x40, too)
Nick Johnson
@Arachnid
Sep 11 2016 12:44 UTC
0x40 is where Solidity stores the current end-of-memory pointer
Alex Beregszaszi
@axic
Sep 11 2016 13:10 UTC
The reason 0x40 is used because you can reserve memory, without actually using it. As memory is charged at the first use (be it MLOAD or MSTORE).
Otherwise you could use MSIZE to get the end of the memory.
jimeejones
@jimeejones
Sep 11 2016 13:25 UTC

hi guys, sorry for the non solidity question, i am syncing morden via --fast and I got to 1.1m blocks now I get

I0911 23:18:40.041539 eth/downloader/downloader.go:299] Synchronisation failed:
no peers to keep download active

Should i just wait and hope it kicks in again? Or do i have to clean exit and restart? ( i don't want to do that, because I will lost my --fast)

basically, will it kick in again if it finds peers automatically?
@rfikki couple of weeks ago you answered a question re 'potential rewrite attack message on geth - thanks
Nick Johnson
@Arachnid
Sep 11 2016 14:23 UTC
@jambtt Better to ask in go-ethereum
jimeejones
@jimeejones
Sep 11 2016 14:33 UTC
@Arachnid thanks.
This message was deleted
This message was deleted
This message was deleted
This message was deleted
btravel
@btravel
Sep 11 2016 16:00 UTC
@pirapira Hmm Seems it was changed cause sha3 function in the latest solidity version uses two arguments from stack. Thanks anyway.
@Arachnid Yeah, I just decided to understand why 0x40 was choosen - I don't find any information about 0x0 and 0x20 in the yellow paper and official docs. Seems that range 0x0-0x20 is unused currently and reserved for special purpose. I will check the source code of EVM.
btravel
@btravel
Sep 11 2016 16:08 UTC
@axic Thanks!
Nick Johnson
@Arachnid
Sep 11 2016 17:02 UTC
@btravel No, it's not anything at the EVM layer; they're not reserved
Solidity just uses 0x00 and 0x20 as scratch space for SHA3 operations, and 0x40 to store the end-of-memory pointer.
Yoichi Hirai
@pirapira
Sep 11 2016 18:50 UTC
Now we know why bytecodes start with 0x60606040....
Christian Seberino
@cseberino
Sep 11 2016 20:09 UTC
Can I ask how people make a profit if "regular" companies get replaced with DAOs?
Chevdor
@chevdor
Sep 11 2016 21:19 UTC
You can surely ask but I doubt the Solidity Gitter is the place for that.
Alex Beregszaszi
@axic
Sep 11 2016 21:20 UTC
@pirapira the deployment bytecode (called "bytecode") actually copies the "data" section (the second part of the bytecode) to be the return value of the execution and that becomes the bytecode on the state
Yoichi Hirai
@pirapira
Sep 11 2016 21:21 UTC
@axic ah yes, I know. Actually 0x60606040... appears twice. In the beginning of both the deployment bytecode and also the runtime part.
but I was mistaken when I wrote that...
Alex Beregszaszi
@axic
Sep 11 2016 21:23 UTC
the 6060604052 should be setting the memor size at 0x40
Rais Kazi
@meetrais_twitter
Sep 11 2016 21:27 UTC
Hey Guys, I am trying to write Voting Contract from Solidity Documentation. But getting below error. Any help please.
upload contract: Ballot
there was an error: {"errorTags":["Solidity","Solidity"],"message":"function \"Ballot\" arguments must include \"proposalNames\""}