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
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
David Portabella
@dportabella

Reading the documentation about security issues, why would a failing transaction stuck a contract forever?

Documentation:
https://solidity.readthedocs.io/en/v0.6.10/common-patterns.html
"That way, whenever transfer is called to deliver funds to the “poisoned” contract, it will fail and thus also becomeRichest will fail, with the contract being stuck forever."

swkim109
@swkim109
@dportabella richest.transfer(msg.value) can be always failed if richest contract has no fallback(receive) function(or more than 2300 gas stipend). So the last richest becomes forever 'richest'. The contract is stuck and does not work.
David Portabella
@dportabella
@swkim109 , I see, thanks.
Simon Shine
@sshine
Question: Why does dapphub's ds-math feature a O(log n) rpow() when the native EVM EXP costs 10 gas?
matrixbot
@matrixbot
¡Finnwww Back From the Dead! [he/him] Why ethereum over Moreno?

¡Finnwww Back From the Dead! [he/him] > <@finnwww-back-from-the-dead:matrix.org> Why ethereum over Moreno?

Monero

chriseth
@chriseth
@sshine because you cannot easily detect overflow in the exp opcode
Simon Shine
@sshine
@chriseth: I wonder if you can at all, at a lower cost than 10 gas x O(lg n).
chriseth
@chriseth
@sshine me too!
Simon Shine
@sshine
@chriseth: I asked on StackExchange, maybe something will show up. :)
I have a hunch that you can do (uint x, uint y) => require(y == 0 || (z = (x ** y)) >= x && ...) with ... being something that compensates for the possible overflow. One guy proposed a solution without false positives, but with false negatives. But the solution itself appears more expensive than simply doing O(log n) multiplications to begin with.
David Portabella
@dportabella
what is the difference between oz deploy vs oz create?
Simon Shine
@sshine
When using Lib for int256; can I choose freely between foo.f(bar) and Lib.f(foo, bar)?
Simon Shine
@sshine

@dportabella: That's a good question. They seem pretty similar. :)

https://docs.openzeppelin.com/cli/2.8/commands#create
https://docs.openzeppelin.com/cli/2.8/commands#deploy

The docs could benefit from making the distinction.

@dportabella: It seems that oz deploy wasn't available in 2.7, so it should be possible to track why it was added.
chriseth
@chriseth
@sshine yes, you can choose
Igor Sobolev
@sobolev-igor

Hi, everyone! I have a question about external functions' arguments.

Solidity dosc (https://solidity.readthedocs.io/en/v0.6.11/types.html?highlight=calldata#data-location) says that

Calldata is a non-modifiable, non-persistent area where function arguments are stored

However, I can modify non-reference-type external functions' arguments.

And the latests changelog (0.6.11) says

Type Checker: Do not disallow assigning to calldata variables.

So, I cannot really understand if there is a way to have an immutable memory in Solidity?
Actially, my function has an argument, makes some delegatecalls and I want to make sure that this function argument cannot be modified during these delegatecalls. I was thinking that marking function as external is enough, but now I'm not actually sure, and my examples show that external functions' arguments are not actually immutable.

Igor Sobolev
@sobolev-igor

So, actually, I wonder how to make sure that x here cannot be changed during addr.delegatecall(data);

contract Contract {
    function foo(uint256 x, address addr, bytes calldata data) external returns (uint256) {
        addr.delegatecall(data);
        return x;
    }
}

Will it be non-modifiable if I turn it into uint256[] calldata x? And was it affected by the latest updates of Solidity?

Simon Shine
@sshine

@sobolev-igor: I'm not really skilled with Solidity, but I have knowledge of EVM: The call parameters that are loaded with CALLDATALOAD (load onto stack) or CALLDATACOPY (copy into memory) are immutable, but the destination isn't, which technically allows you to modify the copy. Which is why the Solidity linter warns (and doesn't error) about changing the value of a function parameter.

I don't think adding the calldata keyword anywhere will ensure immutability.

I would also assume that marking function as external is enough.

But someone more knowledgeable can correct me.

chriseth
@chriseth
@sobolev-igor local stack variables can only be modified locally, so your code is totally fine
Simon Shine
@sshine
OpenZeppelin question: when SignedSafeMath 0.6 depends on Solidity 0.6.0, that seems like it's not because of any Solidity 0.6.0-specific features, but really just because time passed and the library got expanded. Is that right?
Hakeem Orewole
@eltNEG

Web3/Solidity abi.encodePacked Question

Solidity returns a different value from what web3 returns when the arg passed to abi.encodePacked is an address. Please, how can I get the same value?

Solidity code
keccak256(abi.encodePacked(0x0A144d4E1C59640125d1024814d190AD2349587c));
this returns: 0x26d303775d506a2857576a8b15df8ce65c69520d80d367f50c1482064bcc2234

web3code
console.log(web3.utils.keccak256(web3.eth.abi.encodeParameter('address', '0x0A144d4E1C59640125d1024814d190AD2349587c')));
returns: 0x604077134bee57e87d2813621b7339f114bce70e6658fb7f3cf14912cdd6438c
Daniel Kirchner
@ekpyron
keccak256(abi.encode(address(0x0A144d4E1C59640125d1024814d190AD2349587c)))
Hakeem Orewole
@eltNEG
@ekpyron Thanks. It works. Please can you explain why encodePacked gives a different value?
Daniel Kirchner
@ekpyron
abi.encodePacked called like that will give you 20 unpadded bytes - abi.encode(address(...)) will give you 32 bytes with the correct padding.
Hakeem Orewole
@eltNEG
Thanks
Igor Sobolev
@sobolev-igor

@sobolev-igor local stack variables can only be modified locally, so your code is totally fine

thanks!

André Alçada Padez
@andrepadez
Hi. I want to run 4 incognito browsers, each one with a different wallet, so i can test my application. But if i change the wallet in one window, it affects every window. Is there a way to do this? thanks
1 reply
David Portabella
@dportabella

The docs could benefit from making the distinction.

Hi @sshine , I read the docs, but I still don't see the difference. Why I would use deploy instead of create?

1 reply
Nick Mudge
@mudgen
I just published a new article that covers the basics of how Ethereum diamonds work, how to get started making one, and how to use one: https://dev.to/mudgen/understanding-diamonds-on-ethereum-1fb
26 replies
David Portabella
@dportabella
wow, thanks a lot for looking at this issue, @sshine.
the ethereum eco-system is evolving so fast, that many documentation out there is out-dated and sometimes source of frustration. thanks again!
2 replies
Simon Shine
@sshine
If I have a uint foo and I coerce it as int(foo), will that incur a runtime cost or will it be free?
David
@magus237

Hi,

I found something weird. Consider the following piece of code:

contract C {
    function g(int x) public pure returns (int) { return x + 1; }
    function h(int y) public pure returns (int) { return y - 1; }

    function f() public pure returns (int) {
        return ((false ? g : h)({x : 42}));
    }

}

I'm a bit surprised that it is accepted by the typechecker. Since g and h have the same signature, I understand that (false ? g : h) is correct. However in such case, the argument names can no longer be statically determined, so shouldn't the application ({ x : 42 }) be rejected ?

Nick Mudge
@mudgen
@scherrey and @sshine thanks for your comments and questions!
@sshine @scherrey about the diamond standard
I created a Discord server for more discussion of the Diamond Standard. Go here: https://discord.gg/kQewPw2
Nick Mudge
@mudgen
@sshine @sshine I am answering your questions in our thread about the Diamond Standard
Simon Shine
@sshine
@magus237: For this to succeed, the type checker should assert that g and h have the same type in the ternary operator. And your experience is that the type checker just gives up and doesn't report anything, right?
@magus237: But does false ? g : h even work? If so, it seems that this expression doesn't have a type, which is a strange property for a type system.
AceLuodan
@AceLuodan
i use oz compile && mocha --exit --recursive test ,but get error info:Compilation errors:
@openzeppelin/contracts/token/ERC20/ERC20.sol:4:1: ParserError: Source "@openzeppelin/contracts/token/ERC20/IERC20.sol" not found: File import callback not supported
import "./IERC20.sol";
David
@magus237
(false ? g : h) is accepted by the typechecker and has type function (int256,int256) pure returns (int256) (it makes sense, g and h have the same type)
However in this case the argument names are no longer relevant, so it should not accept the argument ({ x : 42 }), but it actually does.
I ran this code using Remix, and it (surprisingly) works.
David
@magus237
(I guess in this case it always uses the argument names of the first function)