Giter Site home page Giter Site logo

pouladzade / seriality Goto Github PK

View Code? Open in Web Editor NEW
154.0 9.0 19.0 44 KB

Seriality is a library for serializing and de-serializing all the Solidity types in a very efficient way which mostly written in solidity-assembly

License: Apache License 2.0

Solidity 100.00%
serialization-library solidity solidity-contracts deserialization smart-contracts assembly ethereum-contract ethereum-dapp ethereum-blockchain serializer

seriality's People

Contributors

mhpaler avatar pouladzade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

seriality's Issues

Seriality as an Solidity Library!

Hi!
first of all: Great work! this functions are real useful to make my contracts much more efficient!
But I suggest to implement Seriality as am solidity Library. So you don't have to copy the code while deployment!
( I think solidity inheritance works that way: "When a contract inherits from other contracts, only a single contract is created on the blockchain, and the code from all the base contracts is compiled into the created contract." docs.

Thanks for share your Work!

Request for support solidity 0.5.0 release

Could you please update this for solidity 0.5.0 release?

I have faced a lot of compilation error. I fixed few which don't involve with assembly. But for assembly like this below I think its better to ask for you help here.

/Users/hasnaeenferdous/startbahn/dev/github/artcontract/app/contracts/src/BytesToTypes.sol:59:13: SyntaxError: The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
            loop:
            ^--^
,/Users/hasnaeenferdous/startbahn/dev/github/artcontract/app/contracts/src/BytesToTypes.sol:59:13: SyntaxError: Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
            loop:
            ^--^
,/Users/hasnaeenferdous/startbahn/dev/github/artcontract/app/contracts/src/BytesToTypes.sol:64:13: SyntaxError: Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
            jumpi(loop , lt(loop_index , chunk_count))
            ^----------------------------------------^
,/Users/hasnaeenferdous/startbahn/dev/github/artcontract/app/contracts/src/TypesToBytes.sol:45:9: SyntaxError: The use of labels is disallowed. Please use "if", "switch", "for" or function calls instead.
        loop:
        ^--^
,/Users/hasnaeenferdous/startbahn/dev/github/artcontract/app/contracts/src/TypesToBytes.sol:45:9: SyntaxError: Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
        loop:
        ^--^
,/Users/hasnaeenferdous/startbahn/dev/github/artcontract/app/contracts/src/TypesToBytes.sol:50:13: SyntaxError: Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
            jumpi(loop , lt(index,stack_size))

Necessary buffer padding details should be documented

This statement in the docs could be much improved:

The buffer size must be chosen very carefully, if you are not sure about that choose your biggest guess.

I'd like to save everyone hours of debugging insanity.

Minimum buffer size is the summation of sizes of all serialized values and enough padding such that this size value is a multiple of 32. Or in other words, up to 31 bytes of padding is needed.

Don't allocate a buffer like this based solely on the summation of sizeOf results for each variable:

uint size = sizeOfBool()*3 + sizeOfUnit(32)*2 + sizeofAddress()*2;
bytes memory data = new bytes(size);

The above will lead to undefined behavior after serializing values into it, incorrect program behavior, and Truffle/Ganache will do even weirder stuff (freeze/crash).

Compute the size of the buffer to account for needed padding:

uint size = sizeOfBool()*3 + sizeOfUnit(32)*2 + sizeofAddress()*2;
if ((size % 32)  > 0) {
    size += 32 - (size % 32);
}
bytes memory data = new bytes(size);

Add CI

Contributing to this project will be easier if there is one command which can run the test suite.

Demonstrating that the commands exists and works can be done with CI or GitHub Action, Travis, or another CI provider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.