Skip to content
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

Contracts-differences #9

Open
ghost opened this issue Oct 10, 2018 · 0 comments
Open

Contracts-differences #9

ghost opened this issue Oct 10, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 10, 2018

1. Does not compile in Array compiler

A: The code in the section does not compile.
A: Following does not compile either:

pragma solidity ^0.4.16;
contract B {
uint a = 3;
}

contract A {
B b;
}
pragma solidity ^0.4.11;
contract owned {
function owned() public { owner = msg.sender; }
address owner;
modifier onlyOwner {
require(msg.sender == owner);
_;
}

function close() public onlyOwner {
//
}
}

A: Doesn't compile because now doesn't work. Without it, it compiles.

Reading from state variables.
Accessing this.balance or <address>.balance.

A: don't support

Accessing any of the members of block, tx, msg (with the exception of msg.sig and msg.data).

A: Do we have these global members?

Calling any function not marked pure.
Using inline assembly that contains certain opcodes.

A: Do we support inline assembly?

-Inheritance
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#inheritance
A: multiple inheritance -not supported
A: Since multiple inheritance is not supported, maybe we can state here something about the single inheritance?

-Abstract contracts
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#abstract-contracts
A: ERROR: FuncDef_id(6): too few children (2) - first code
A: ERROR: FuncDef_id(6): too few children (2)- second set
Q: Why does compiler try to read this as number:
{ return "miaow";}
Error is: ERROR: strtobin: can not recognize num = "miaow" (1)

2. Questions

a) Creating contracts
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#creating-contracts

Contracts can be created “from outside” via Ethereum transactions or from within Solidity contracts.
IDEs, such as Remix, make the creation process seamless using UI elements.
Creating contracts programatically on Ethereum is best done via using the JavaScript API web3.js. As of today it has a method called web3.eth.Contract to facilitate contract creation.

A: Ethereum stuff: we don't have Remix, web3.js. Are we gonna have something like web3.js?

If a contract wants to create another contract, the source code (and the binary) of the created contract has to be known to the creator. This means that cyclic creation dependencies are impossible.

A: Can a contract create another contract?

b) View functions
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#view-functions

Emitting events.

A: events not supported

Creating other contracts.

A: Is this supported?

Using selfdestruct.

A: Is this supported?
When trying to selfdestruct, this is the error:
ERROR: MakeFunctionCallCore_id(14): can not get func visibility

Sending Ether via calls.

A: Doesn't compile
ERROR: dec_id_is_event: can not get "attributes.referencedDeclaration"
LOG: FunctionCall_id(14): TAG1
ERROR: MakeFunctionCallCore_id(13): unknown name: "FunctionCall"

Calling any function not marked view or pure.
Using low-level calls.
Using inline assembly that contains certain opcodes.

A: Do we support these?

c) Note

If invalid explicit type conversions are used, state modifications are possible even though a view function was called. You can switch the compiler to use STATICCALL when calling such functions and thus prevent modifications to the state on the level of the EVM by addingpragma experimental "v0.5.0";

A: Is this true for Array.IO?

d) Interfaces
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#interfaces
A: Do we have it?

e) Libraries - first set of code
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#libraries
A: Do we have it?
A: It doesn't compile because:
struct Data { mapping(uint => bool) flags; }
is not supported, error is:
ERROR: StructDefinition_id(6): us_prop.fullname == "C.Data" : #0 child : type == "mapping(uint256 => bool)" : can not get type properties

f) Libraries - second set of code
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#libraries

A: Is having a mapping inside a struct supported?
A: for:

`pragma solidity ^0.4.16;
contract C {
struct Data { 
mapping(uint => bool) flags; 
}
}`

This is the error: ERROR: StructDefinition_id(6): us_prop.fullname == "C.Data" : #0 child : type == "mapping(uint256 => bool)" : can not get type properties

g) Using For
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#using-for
A: Does call a function from a library work?
Because the following does not compile:

pragma solidity ^0.4.21;
library C {
function a() returns (address) {
return address(this);
}
}

contract A {
function a() constant returns (address) {
return C.a();
}
}

3. Errors

  1. TokenCreator creator;
    A: ERROR: VarDec_id(3): unknown type "contract TokenCreator"

  2. Fallback functions
    https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#fallback-function

In the worst case, the fallback function can only rely on 2300 gas being available (for example when send or transfer is used), leaving not much room to perform other operations except basic logging. The following operations will consume more gas than the 2300 gas stipend:
Writing to storage
Creating a contract
Calling an external function which consumes a large amount of gas
Sending Ether

A: Is this true for Array?

Note
Even though the fallback function cannot have arguments, one can still use msg.data to retrieve any payload supplied with the call.

A: can't use msg.data

Contracts that receive Ether directly (without a function call, i.e. using send or transfer) but do not define a fallback function throw an exception, sending back the Ether (this was different before Solidity v0.4.0). So if you want your contract to receive Ether, you have to implement a fallback function.

A: send does not work:
ERROR: FunctionCall_MemberAccess_of_address: unknown member_name == "send"

A contract without a payable fallback function can receive Ether as a recipient of a coinbase transaction (aka miner block reward) or as a destination of a selfdestruct.
A contract cannot react to such Ether transfers and thus also cannot reject them. This is a design choice of the EVM and Solidity cannot work around it.
It also means that this.balance can be higher than the sum of some manual accounting implemented in a contract (i.e. having a counter updated in the fallback function).

A: does not work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants