by

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
Luis Schliesske
@gitpusha
Hi. Does anyone know if etherscan.io Verify & Publish source code feature generates this error Deployed Contract ByteCode (err_code_2) does NOT match the Compiled Code for Address due to the new // "SPDX-License-Identifier: UNLICENSED" requirement (for example) ?
I can't verify and publish due to this error and I am pretty sure all the files I upload are correct and all my configs too
I am using the 0.6.10 compiler setting
Sreesankar G Warrier
@Sreesankar-G-Warrier

Hi, anyone knows how to fix this error. I go through this website "https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration", But I didn't understand what to do. truffle(develop)> compile

Compiling your contracts...

Compiling ./contracts/StarNotary.sol

/mnt/d/Blockchain/Project2Test/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721.sol:3:1: ParserError: Source file requires different compiler version (current compiler is 0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.6.0;
^---------------------^

Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity ^0.6.0".
Please update your truffle config or pragma statement(s).
(See https://truffleframework.com/docs/truffle/reference/configuration#compiler-configuration for information on
configuring Truffle to use a specific solc compiler version.)

Compilation failed. See above.

Truffle v5.1.32 (core: 5.1.32)
Node v12.18.1
Jared Flatow
@jflatow
so it seems we can now use memory in external functions, I'm wondering if anyone knows if there are any practical side effects of doing this?
Jared Flatow
@jflatow
also is the 0.6.10 release missing the commit_hash.txt?
Daniel Kirchner
@ekpyron

also is the 0.6.10 release missing the commit_hash.txt?

What makes you say that? (i.e. it shouldn't be missing it)

Daniel Kirchner
@ekpyron

so it seems we can now use memory in external functions, I'm wondering if anyone knows if there are any practical side effects of doing this?

This was mostly a side-effect of relaxing the restrictions of data locations based on function visibility when allowing calldata arguments to public and internal functions. I'm not sure there really are situations in which using memory arguments to external functions makes that much sense - it'll always be end up being a calldata->memory copy, so I guess it can be convenient, if you only want to use a memory copy of the argument anyways and don't want to write the (equivalent) function f(SomeType calldata x) external { SomeType memory x2 = x; ... }. At least I don't see much use of it beyond that.

chriseth
@chriseth
@ekpyron some people suggested they mainly use external to avoid the function being called internally - the idea is that msg.sender is also the "direct caller" in an external function. So I guess it makes a lot of sense to decouple the data location from the "visibility"
Jared Flatow
@jflatow
@ekpyron re: 0.6.10, bc I just downloaded that release and it wasn't there
thanks for the insights
it also didn't have the empty prerelease.txt (which if I had known about would not have needed to dl the release ;))
Daniel Kirchner
@ekpyron
@jflatow Ok, but what exactly did you download? The github generated source archives https://github.com/ethereum/solidity/archive/v0.6.10.tar.gz and https://github.com/ethereum/solidity/archive/v0.6.10.zip never contain the commit_hash and prerelease files - that's why the release notes say "If you want to perform a source build, please only use solidity_0.6.10.tar.gz and not the zip provided by github directly." in the end... and https://github.com/ethereum/solidity/releases/download/v0.6.10/solidity_0.6.10.tar.gz seems to contain both files - or do you get the sources elsewhere?

@ekpyron some people suggested they mainly use external to avoid the function being called internally - the idea is that msg.sender is also the "direct caller" in an external function. So I guess it makes a lot of sense to decouple the data location from the "visibility"

Yep, decoupling makes sense - I just don't think the particular combination external + memory will be used that often (or at least it will rarely really have an advantage over external + calldata).

Jared Flatow
@jflatow
ah @ekpyron I must have downloaded the wrong one
Daniel Kirchner
@ekpyron
Ah, alright then :-)!
Jared Flatow
@jflatow
glad I discovered prerelease.txt though ;)
André Alçada Padez
@andrepadez

Hi. Can anybody help me understand this scheduling mechanism?

contract Lottery {
    address alarm; // set by some other mechanism.

    function beginLottery() public {
        ... // Do whatever setup needs to take place.

        // Now we schedule the picking of the winner.

        bytes4 sig = bytes4(sha3("pickWinner()"));
        // approximately 24 hours from now
        uint targetBlock = block.number + 5760;
        // 0x1991313 is the ABI signature computed from `bytes4(sha3("scheduleCall(...)"))`.
        alarm.call(0x1991313, address(this), sig, targetBlock)
    }

    function pickWinner() public {
        ...
    }
}

from https://ethereum-alarm-clock-service.readthedocs.io/en/v0.6.0/scheduling.html#contract-scheduling-its-own-call

i don't understand the 'ABI signature computed from... part

also, sha3 is deprecated so i wonder if this documentation is outdated.
I want to learn how to schedule calls inside a contract and also unschedule if possible
Simon Shine
@sshine

@andrepadez: https://ethereum.stackexchange.com/questions/234/what-is-an-abi-and-why-is-it-needed-to-interact-with-contracts -- so, it's a binary identifier of the contract method you're calling. This is used to locate the actual method in the binary code. So, as the comment says, very much the same as the sig that is sent along as a callback.

The alarm part: By starting a lottery, some alarm contract is notified that the lottery is about to start. After that point, this contract doesn't do much but wait until pickWinner() is called by some other contract like alarm (or anyone else). Presumably pickWinner() starts by checking that the right amount of blocks have passed.

André Alçada Padez
@andrepadez
@sshine thanks for your answer, but i'm not sure i understand completely:
  • I know what an ABI is, i work with web3 also
  • this documentation is explicitly to schedule calls within the same contract
    1 - how do i get the specific value (0x1991313) or both params are the result of the hashing?
    so it would be: alarm.call(sig, address(this), sig, targetBlock)
    2 - if i use keccak256 instead of sha3, will it work the same?
    3 - doesn't this operation cost gas? where is it coming from?
Simon Shine
@sshine
@andrepadez:
  1. You get the specific value just as the comment suggests, bytes4(sha3("scheduleCall(...)")) with ... being replaced with whatever the actual signature is. Since you know what an ABI is, you'll know how to specify ..., but in case you need it refreshed, a good place to read is: https://solidity.readthedocs.io/en/latest/abi-spec.html -- I presume they're just hardcoding it to save compute time because Solidity does not have this as a compile-time macro.
  2. SHA-3 is a family of algorithms that is a subset of Keccak, so Keccak256 is (in) SHA-3. So sha3() means Keccak-256. See instruction set at the bottom of page 29 in Ethereum Yellow Paper (https://ethereum.github.io/yellowpaper/paper.pdf): "SHA3: Compute Keccak-256 hash."
  3. Operations cost gas, yes. This gas is given by the caller of a method. Could you clarify?
André Alçada Padez
@andrepadez
1 and 3 - so my goal is to set a schedule in my contract that triggers a call inside the same contract, with no outside interference... so for 1) i assume the values of the first (0x1991313) and third (sig) arguments will have the same value and be derived from the call to the hashing, am i incorrect?; and 3) if it's the contract calling itself, the gas is going to be paid by the wallet that created the contract?
@sshine ^^^
Simon Shine
@sshine

@andrepadez: I could be wrong, but I don't see a way for a contract to call itself without interference. You can do something like a request-response model where a contract tells another contract to get back to it at some point in time, and when that time comes, and that contract calls itself, continue the response part.

Yes, sig and 0x1991313 will be constant. They represent method interfaces that don't change in the lifetime of the contract.

Regarding gas cost: The cost of executing a call is paid by the caller of the method. If you want, you can make the contract refund the caller, but initially, it is the caller who pays.

André Alçada Padez
@andrepadez
i understand
more or less
i understand that i need to read a lot more about it
thank you so much for your time and help
Simon Shine
@sshine
Hehe. You could always implement a simpler model.
A lottery is a good contract to play around with. I don't think you need callbacks in the simplest imaginable lottery.
Especially if alarm is the Lottery contract, this seems a bit over-complicated (leaving room for unused modularity).
André Alçada Padez
@andrepadez
let's say i'm building something like a lottery
not really though
every user can make "deposits"
every time a deposit is made, the clock resets
after 1 hour since the last deposit, the process finishes
^^^ @sshine
how would i go to start conceptualizing it?
Simon Shine
@sshine
@andrepadez: You keep a block count of the most recent deposit and make a deposit(...) method that resets this and a finishProcess() method that checks if enough blocks have passed since the last reset, and if this is the case, proceeds with the lottery logic.
André Alçada Padez
@andrepadez
hmm, ok
but how is that finishProcess method is called?
@sshine ^^
Simon Shine
@sshine
It's called by whoever stands to benefit from calling it.
André Alçada Padez
@andrepadez
:)
Simon Shine
@sshine
Hmm, gitter cancelled my post. The short version: Either you can argue that the lottery winner is incentivized to call finishProcess(), or you can reward the caller just for calling and argue that any caller is incentivized.
Simon Shine
@sshine

Just to say, it is perfectly reasonable to think in terms of spawning a thread with a countdown timer, but this isn't a part of the computation model. :)

Maybe other blockchains will feature parts that activate themselves without this external incentivization.

matrixbot
@matrixbot
KaiRo there is no delayed execution in Ethereum, and even though it would have helped me at times, I actually think it would be a bad idea
André Alçada Padez
@andrepadez
@sshine thank you very much, i had to leave yesterday