Giter Club home page Giter Club logo

clvm's Issues

brun returns invalid argument exception. Different results on 2 machines.

Given the following file: passwordprotect.clsp:

(mod (
        password_hash
        password
        receive_puzzlehash
        transaction_amount
    )
    (defconstant CREATE_COIN 51)
    (if (= (sha256 password) password_hash)
        ; true - password was correct
        (list
            (list CREATE_COIN receive_puzzlehash transaction_amount)
        )
        ; false - password was incorrect
        (x "Bad password")
    )
)

brun throws an error on my machine (windows 10, powershell:

brun '(a (q 2 (i (= (sha256 11) 5) (q 4 (c 2 (c 23 (c 47 ()))) ()) (q 8 (q . "Bad password"))) 1) (c (q . 51) 1))' "(0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 test 0xa11ce 1000)"

image

same brun command works on another machine (in the video tutorial and for another community member) :
paste

Is this indentional?

int_to_bytes at casts.py seems adding extra byte.

def int_to_bytes(v):
    byte_count = (v.bit_length() + 8) >> 3 # Should be (v.bit_length() + 7) >> 3
    if v == 0:
        return b""
    r = v.to_bytes(byte_count, "big", signed=True)
    # make sure the string returned is minimal
    # ie. no leading 00 or ff bytes that are unnecessary
    while len(r) > 1 and r[0] == (0xFF if r[1] & 0x80 else 0):
        r = r[1:]
    return r

Because of the above implementation, str(SExp.to(131)) returns 820083 as a serialized value, where 8183 is more byte-efficient.
(integer 131 is represented 83 as a hex string. Cleary this is 1-byte value.)
More directly, int_to_bytes(131) == b'\x00\x83' where b'\x83' is more byte-efficient

verision needed in setup() inside setup.py

Please add a version number in the setup() block in the setup.py file. This fixed issues when installed showing site-packages with -0.0.0- instead of -0.9.6- for the version.

setup(
name="clvm",
+ version="0.9.6",
packages=["clvm",],
author="Chia Network, Inc.",

`op_not` on `list` returns `SExp.false`. Is this expected?

Currently in clvm/more_ops.py,

def op_not(args: SExp):
    (i0,) = args_as_bool_list("not", args, 1)
    if i0.as_atom() == b"":
        r = args.true
    else:
        r = args.false
    cost = BOOL_BASE_COST
    return cost, args.to(r)

It seems if args is not an atom, not_op returns false and never raises EvalError.
Is this correct behaviour?

Missing tarball on Pypi

I am trying to build an RPM from this but see no tar.gz file on pypi. Can you please upload the source tarball to pypi ?

warning: Downloading https://pypi.io/packages/source/c/clvm/clvm-0.9.6.tar.gz
curl: (22) The requested URL returned error: 404
error: Couldn't download https://pypi.io/packages/source/c/clvm/clvm-0.9.6.tar.gz

https://pypi.org/project/clvm/#files only shows a .whl file.

$python3 setup.py --help-commands | grep sdist
sdist create a source distribution (tarball, zip file, etc.)

so if you can first generate this sdist tar ball then upload it

Parenthesis inside of a string isn't ignored

I noticed that if you have a parenthesis inside a quote in causes undefined behavior and the parenthesis is treated as if it is not inside a quote.

Example:
(if (> 10 5) ")" "(")

Causes output 41 when it should be ")"

`python3 setup.py test` fails

File "/usr/local/lib/python3.8/unittest/loader.py", line 205, in loadTestsFromName
test = obj()
TypeError: run_program() missing 3 required positional arguments: 'program', 'args', and 'operator_lookup'

Are tests not wired/written for setup.py yet?

Sdist isn't getting published

In our workflow, we are using pep517.build (which is deprecated) to build the wheel:

- name: Install pep517
run: >-
python -m
pip install
pep517
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
pep517.build
--binary
--out-dir dist/
.

We aren't building the sdist.
If we were to use pip install build, and then
python -m build --outdir dist/ ., this should provide the sdist and the wheel to publish to pypi.

Split divmod into `/` and `mod`

kiss@oasis ~ % python -m timeit 'A = 74738383914845; B = 83717484' "A//B"       
10000000 loops, best of 3: 0.0522 usec per loop
kiss@oasis ~ % python -m timeit 'A = 74738383914845; B = 83717484' "A%B" 
10000000 loops, best of 3: 0.0512 usec per loop
kiss@oasis ~ % python -m timeit 'A = 74738383914845; B = 83717484' "(A//B, A%B)"
10000000 loops, best of 3: 0.117 usec per loop
kiss@oasis ~ % python -m timeit 'A = 74738383914845; B = 83717484' "divmod(A,B)"
10000000 loops, best of 3: 0.166 usec per loop
kiss@oasis ~ % python -m timeit 'A = 74738383914845; B = 83717484' "Q = A//B; (Q, A - B * Q)"
10000000 loops, best of 3: 0.104 usec per loop

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.