arrayio / array-io-solidity Goto Github PK
View Code? Open in Web Editor NEWDocs for Array.IO Solidity implementation
Docs for Array.IO Solidity implementation
1. Sections of code which does not compile:
Internal function calls
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#internal-function-calls
External function calls
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#external-function-calls
Crating contracts via new
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#creating-contracts-via-new
A: Keyword new
is not supported in Array
Destructuring ssignments and returning multiple values
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#destructuring-assignments-and-returning-multiple-values
-Scoping and Declarations: second set of code
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#scoping-and-declarations
A: most likely because baz
is not implicitly initialized as zero.
2. Questions:
Do we support .value()
?
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#creating-contracts-via-new
In Complications for Arrays and Structs:
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#complications-for-arrays-and-structs
...assigning to a local variable creates an independent copy only for elementary types, i.e. static types that fit into 32 bytes
A second assignment to the local variable does not modify the state but only changes the reference. Assignments to members (or elements) of the local variable do change the state.
Internally, Solidity performs a revert operation (instruction 0xfd) for a require-style exception and executes an invalid operation (instruction 0xfe) to throw an assert-style exception. In both cases, this causes the EVM to revert all changes made to the state. The reason for reverting is that there is no safe way to continue execution, because an expected effect did not occur. Because we want to retain the atomicity of transactions, the safest thing to do is to revert all changes and make the whole transaction (or at least call) without effect. Note that assert-style exceptions consume all gas available to the call, while require-style exceptions will not consume any gas starting from the Metropolis release.
3. Errors:
a) Scoping and Declarations: second set of code
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#scoping-and-declarations
contract C {
function foo() public pure returns (uint) {
// baz is implicitly initialized as 0
uint bar = 5;
if (true) {
bar += baz;
} else {
uint baz = 10;// never executes
}
return bar;// returns 5
}
}
A: ERROR: IfStatement_id(17): cannot get oparg1
b) Error handling assert require revert and exceptions
https://github.com/arrayio/array-io-solidity/blob/master/control-structures.rst#error-handling-assert-require-revert-and-exceptions
The throw keyword can also be used as an alternative to revert().
A: Throw doesn't work but it's depricated ERROR: Block_id(11): unknown "Throw
assert
and require
do work, but this.balance
is not supported
An assert-style exception is generated in the following situations:
If you access an array at a too large or negative index (i.e. x[i] where i >= x.length or i < 0).
If you access a fixed-length bytesN at a too large or negative index.
If you divide or modulo by zero (e.g. 5 / 0 or 23 % 0).
If you shift by a negative amount.
If you convert a value too big or negative into an enum type.
If you call a zero-initialized variable of internal function type.
If you call assert with an argument that evaluates to false.
A require-style exception is generated in the following situations:Calling throw.
Calling require with an argument that evaluates to false.
If you call a function via a message call but it does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself), except when a low level operation call, send, delegatecall or callcode is used. The low level operations never throw exceptions but indicate failures by returning false.
If you create a contract using the new keyword but the contract creation does not finish properly (see above for the definition of "not finish properly").
If you perform an external function call targeting a contract that contains no code.
If your contract receives Ether via a public function without payable modifier (including the constructor and the fallback function).
If your contract receives Ether via a public getter function.
If a .transfer() fails.
Version Pragma
(https://github.com/arrayio/array-io-solidity/blob/master/layout-of-source-files.rst#version-pragma)
1.(don't support 0.5.0)
A: But actually there is proved support only of the 0.4.21 version
Importing other Source Files
(https://github.com/arrayio/array-io-solidity/blob/master/layout-of-source-files.rst#importing-other-source-files
)
2. (all sections in the Importing other Source Files)
A: We do not support it.
In Units and Globally Available Variables, all bellow is not supported in Array:
Ether Units
https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#ether-units
Time Units
https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#time-units
In Block and Transaction Properties, following code:
https://github.com/arrayio/array-io-solidity/blob/master/units-and-global-variables.rst#block-and-transaction-properties
block.coinbase (address): current block miner’s address
block.difficulty (uint)
: current block difficultygasleft()
returns (uint256
): remaining gasmsg.data (bytes):
complete calldatamsg.gas (uint)
: remaining gas - deprecated in version 0.4.21 and to be replaced bygasleft()
msg.sig (bytes4)
: first four bytes of the calldata (i.e. function identifier)now (uint)
: current block timestamptx.gasprice (uint)
: gas price of the transactiontx.origin (address)
: sender of the transaction (full call chain)keccak256(...)
until the next subsection):keccak256(...)
returns (bytes32):
compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
sha256(...)
returns (bytes32):
compute the SHA-256 hash of the (tightly packed) arguments
sha3(...)
returns (bytes32):
alias to keccak256
ripemd160(...)
returns (bytes20):
compute RIPEMD-160 hash of the (tightly packed) arguments
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s)
returns (address):
recover the address associated with the public key from elliptic curve signature or return zero on error (example usage)
In the above, “tightly packed” means that the arguments are concatenated without padding. This means that the following are all identical:
keccak256("ab", "c")
keccak256("abc")
keccak256(0x616263)
keccak256(6382179)
keccak256(97, 98, 99)
If padding is needed, explicit type conversions can be used: keccak256("\x00\x12")
is the same as keccak256(uint16(0x12))
.
Note that constants will be packed using the minimum number of bytes required to store them. This means that, for example, keccak256(0) == keccak256(uint8(0)) andkeccak256(0x12345678) == keccak256(uint32(0x12345678)).
It might be that you run into Out-of-Gas for sha256, ripemd160 or ecrecover on a private blockchain. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net.
<address>.call(...)
returns (bool):
issue low-level CALL, returns false on failure, forwards all available gas, adjustable
<address>.callcode(...)
returns (bool):
issue low-level CALLCODE, returns false on failure, forwards all available gas, adjustable
<address>.delegatecall(...)
returns (bool):
issue low-level DELEGATECALL, returns false on failure, forwards all available gas, adjustable
Installing the Solidity Compiler
https://github.com/arrayio/array-io-solidity/blob/master/installing-solidity.rst#installing-the-solidity-compiler
A: Whole section needs to be rewritten
Events
https://github.com/arrayio/array-io-solidity/blob/master/structure-of-a-contract.rst#events
(everything in the section events should be out)
A: we don't have events function
Enum Types
https://github.com/arrayio/array-io-solidity/blob/master/structure-of-a-contract.rst#enum-types
(everything in the section events should be out)
A: we don't have events function
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;
}
Getter Functions:
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#getter-functions
A: First set of code does not compile because of this line:
C c = new C()
- keyword new
doesn't work. (from previous section)
A: Second set of code does not compile because: this.data()
A: Third set of code does not compile:
ERROR: StructDefinition_id(10): us_prop.fullname == "Complex.Data" : #2 child : type == "mapping(uint256 => uint256)" : can not get type properties
Function Modifiers
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#function-modifiers
A: ERROR: FunctionCall_MemberAccess_of_address: children->size() == 1
A: A: Function Modifiers do work -
This does compile:
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 {
//
}
}
Constant State Variables
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#constant-state-variables
A: ERROR: VarDec_id(4): type == "string memory" is not supported yet
A: Initializing with arithmetic like this uint constant x = 8**3
; doesn't seem to work
View functions
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#view-functions
A: Doesn't compile because now
doesn't work. Without it, it compiles.
Reading from state variables.
Accessingthis.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?
Arguments for base constructors
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#arguments-for-base-constructors
A: ERROR: FuncDef_id(28): ModifierInvocation has too many children (2)
Multiple Inheritance and Linearization
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#multiple-inheritance-and-linearization
Inheriting Different Kinds of Members of the Same Name
https://github.com/arrayio/array-io-solidity/blob/master/contracts.rst#inheriting-different-kinds-of-members-of-the-same-name
-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
orpure
.
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
TokenCreator creator;
A: ERROR: VarDec_id(3): unknown type "contract TokenCreator"
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
ortransfer
) 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
Storage
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#storage
(up to, but not including, version 0.5.0).
A: The source code is written for Solidity version 0.4.21 and lower - for ArrayIO
It is possible to store UTF-8 encoded data in string variables.
A:
**Subcurrency Example ** https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#subcurrency-example
event Sent(address from, address to, uint amount);
A:
The address type is a 160-bit value that does not allow any arithmetic operations.
The keyword public automatically generates a function that allows you to access the current value of the state variable from outside of the contract.
The line event Sent(address from, address to, uint amount); declares a so-called “event” which is emitted in the last line of the function send. User interfaces (as well as server applications of course) can listen for those events being emitted on the blockchain without much cost. As soon as it is emitted, the listener will also receive the arguments from, to and amount, which makes it easy to track transactions. In order to listen for this event, you would use
Coin.Sent().watch({}, '', function(error, result) {
if (!error) {
console.log("Coin transfer: " + result.args.amount +
" coins were sent from " + result.args.from +
" to " + result.args.to + ".");
console.log("Balances now:\n" +
"Sender: " + Coin.balances.call(result.args.from) +
"Receiver: " + Coin.balances.call(result.args.to));
}
})
Note how the automatically generated function balances is called from the user interface.
A: We have no 'events'.
Regardless of whether or not the account stores code, the two types are treated equally by the EVM.
A:
Furthermore, every account has a balance in Ether (in “Wei” to be exact) which can be modified by sending transactions that include Ether.
A:
Transactions
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#transactions-1
Storage, Memory and the Stack
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#storage-memory-and-the-stack
(Memory) .... can be addressed at byte level,
A:
Memory is more costly the larger it grows (it scales quadratically).
A:
It has a maximum size of 1024 elements and contains words of 256 bits. Access to the stack is limited to the top end in the following way: It is possible to copy one of the topmost 16 elements to the top of the stack or swap the topmost element with one of the 16 elements below it.
A:
Instruction Set
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#instruction-set
The instruction set of the EVM is kept minimal in order to avoid incorrect implementations which could cause consensus problems. All instructions operate on the basic data type, 256-bit words.
A:
Calls are limited to a depth of 1024,
A:
Delegatecall / Callcode and Libraries
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#delegatecall--callcode-and-libraries
A: We don't have it
Logs
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#logs
It is possible to store data in a specially indexed data structure that maps all the way up to the block level. This feature called logs is used by Solidity in order to implement events.
A:
Since some part of the log data is stored in bloom filters,
A:
Self-destruct
https://github.com/arrayio/array-io-solidity/blob/master/introduction-to-smart-contracts.rst#self-destruct
A: Don't have this operation
Types
(https://github.com/arrayio/array-io-solidity/blob/master/types.rst#types)
A: we don't support all bellow (1-10)
Fixed Point Numbers (fixed point numbers until 'Address' section)
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#fixed-point-numbers
Members of addresses (first Warning and a second Note in the section)
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#members-of-addresses
Fixed-sized byte arrays
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#fixed-size-byte-arrays
Dynamically-sized byte array
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#dynamically-sized-byte-array
Address literals
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#address-literals
String literals
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#string-literals
Hexadecimal literals
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#hexadecimal-literals
Enums
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#enums
In Function types:
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#function-types
Sentence: If external function types are used outside of the context of Solidity, they are treated as the function type, which encodes the address followed by the function identifier together in a single bytes24 type.
code:
event NewRequest(uint);
and
emit NewRequest(requests.length - 1)
Data location
https://github.com/arrayio/array-io-solidity/blob/master/types.rst#data-location
calldata
is ROMMembers
(https://github.com/arrayio/array-io-solidity/blob/master/types.rst#members)
m_pairsOfFlags;
delete m_aLotOfIntegers;
bytes memory b = new bytes(200);
Do we have an ABI?
What should be done with this section?
Dima recommends rewriting this part to fit our VM specs
Virtual Machine parts to test:
A: Now it is not like that for Array
b) Whole Warning segment in this section should be out.
Tips and Tricks
https://github.com/arrayio/array-io-solidity/blob/master/miscellaneous.rst#tips-and-tricks
Use
delete
on arrays to delete all its elements.
A: delete
doesn't work
Cheatsheet
https://github.com/arrayio/array-io-solidity/blob/master/miscellaneous.rst#cheatsheet
Doesn't work for Array:
New expression:
new <typename>
Unary operations:
delete
Exponentiation:
**
from the row 4 to 16 - remains to be tested...
Global Variables:
https://github.com/arrayio/array-io-solidity/blob/master/miscellaneous.rst#global-variables
Global vars which do not work for Array:
block.blockhash(uint blockNumber) returns (bytes32)
block.coinbase (address)
block.difficulty (uint)
block.gaslimit (uint)
block.number (uint)
gasleft() returns (uint256)
msg.data (bytes)
msg.gas (uint)
now (uint)
tx.gasprice (uint)
tx.origin (address)
revert()
keccak256(...) returns (bytes32)
sha3(...) returns (bytes32)
sha256(...) returns (bytes32):
ripemd160(...) returns (bytes20)
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)
addmod(uint x, uint y, uint k) returns (uint)
mulmod(uint x, uint y, uint k) returns (uint)
this
super
selfdestruct(address recipient)
suicide(address recipient)
<address>.send(uint256 amount) returns (bool)
Modifiers
https://github.com/arrayio/array-io-solidity/blob/master/miscellaneous.rst#modifiers
don't work:
anonymous
for events: Does not store event signature as topic.
indexed
for event parameters: Stores the parameter as topic.
.callcode()
and .delegatecall()
A: These don't work for us.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.