Pythonic Smart Contract Language for the EVM

Overview

Build Status Documentation Status Discord

PyPI Docker

Coverage Status Language grade: Python

Getting Started

See Installing Vyper to install vyper. See Tools and Resources for an additional list of framework and tools with vyper support. See Documentation for the documentation and overall design goals of the Vyper language.

See Vyper.fun for learning Vyper by building a Pokémon game.

Note: Vyper is beta software, use with care

Installation

See the Vyper documentation for build instructions.

Compiling a contract

To compile a contract, use:

vyper your_file_name.vy

Alternative for GitHub syntax highlighting: Add a .gitattributes file with the line *.vy linguist-language=Python

There is also an online compiler available you can use to experiment with the language and compile to bytecode and/or LLL.

Note: While the vyper version of the online compiler is updated on a regular basis it might be a bit behind the latest version found in the master branch of this repository.

Testing (using pytest)

(Complete installation steps first.)

python setup.py test

Contributing

  • See Issues tab, and feel free to submit your own issues
  • Add PRs if you discover a solution to an existing issue
  • For further discussions and questions, post in Discussions or talk to us on Discord
  • For more information, see Contributing
Comments
  • Create voting example

    Create voting example

    This is a voting example written in Viper (based on Solidity docs example). I've added it to the docs locally but would love to get some eyes on the code to make sure it's right before making a PR for the docs. @pdaian I used the same style for testing that you did, it definitely sped things up. Thanks a lot! @fubuloubu Could you take a look?

    opened by DavidKnott 59
  • VIP: Cost and usability Improvements to internal function calls

    VIP: Cost and usability Improvements to internal function calls

    Preamble

    VIP: <to be assigned>
    Title: reduce the cost and difficulty of code reuse in common situations
    Author: maurelian
    Status: Draft
    Created: 2018-06-16
    Requires (*optional): <VIP number(s)>
    Replaces (*optional): <VIP number(s)>
    

    Simple Summary

    1. I shouldn't need to copy and paste the same code snippets into 5 functions to valid authorization.
    2. I shouldn't feel like copying and pasting code is more efficient or cheaper.

    Abstract

    In order to call a within the same contract function, Vyper uses the CALL opcode, which send a new message to call functions within the same contract. This has some nice safety benefits.

    Unfortunately it will result in developers using anti-patterns to save on gas, or access msg.sender in a function call.

    Motivation

    The benefit of using CALL to access code in the same contract is to create a new execution context, with no risk of side effects from memory access. I admit that I find this to be quite an elegant use of the EVM for safety.

    Problems with using CALL

    Unfortunately, there are two major issues with the use of the CALL opcode for calling functions within the contract:

    1. Environment values change unexpectedly

    At least two important environment opcodes will return different values: CALLER (ie. msg.sender) and CALLVALUE (ie. msg.value). This complicates the use of functions for permission checking. The following is a naive vyper translation of the common "ownable" pattern for a simple storage solidity contract.

    owner: address
    value: public(int128)
    
    @public
    def __init__():
        self.owner = msg.sender
    
    @private
    def checkOwner():
      assert msg.sender == self.owner # this will REVERT every time
    
    @public
    def writeValue(_value: int128):
        self.checkOwner()
        self.value = _value
    

    2. Gas costs disincentivizes code reuse

    The CALL opcode costs 700 gas (+ input data costs + function dispatching again). By contrast Solidity uses JUMP (2 gas) to call a function.

    This imposes a large penalty on code reuse. Regardless Vyper's design philosophy favoring safety over gas efficiency, developers will respond to this incentive by simply copying and pasting boilerplate code. This is dangerous, and difficult to audit.

    Specification:

    I'm sorry, I don't have one specification. Below are some options I see for mitigating these issues.

    From the Motivation section above, we have 3 parameters along which to analyze approaches to calling a function in the EVM.

    1. Gas cost
    2. Preservation of env variables
    3. Safety benefits

    1. Use DELEGATECALL instead of CALL

    1. Gas cost: NEUTRAL (same as using CALL)
    2. Env variables: GOOD (gives us back CALLER and CALLVALUE)
    3. Memory Safety: GOOD. It does indeed reset memory.

    Seems like a decent solution!

    ~3. Memory Safety: BAD (executes the code in the same memory context, nullifying reasons for using CALL in the first place)~ ~I proposed this earlier, but I don't think this is a good solution. ~

    2. Just use JUMP like Solidity

    1. Gas cost: GOOD (Much lower gas cost)
    2. Env variables: GOOD (Preserves CALLER and CALLVALUE)
    3. Memory Safety: BAD (Greater risk of compiler bugs)

    This is worth considering. See also #330.

    3. Implement a safer analog to Solidity's modifiers

    These could have significant restrictions on them, like no access to MSTORE or SSTORE, and not accepting arguments. I assume this would be done by with JUMP, or just inlining the same code each time it's needed.

    1. Gas cost: GOOD (Lower execution cost, but might increase size of contract if inlining is used)
    2. Env variables: GOOD (Preserves CALLER and CALLVALUE)
    3. Memory Safety: Depends on implementation

    4. Create special variables which persist across message calls

    Built-in vars like caller and callvalue can be created, which are magically passed to a function in a message call.

    My code above would thus be:

    @private
    def checkOwner():
      assert _sender == self.owner # <- replaced msg.sender with a magical global variable `sender`
    
    @public
    def writeValue(_value: int128):
        self.checkOwner)
        self.value = _value
    

    This feels a bit funky to me. Probably would be hard to implement safely, and obscures the true functioning of the EVM.

    5. Status Quo

    My problem in the code sample above can be addressed by passing the values I need as arguments:

    @private
    def checkOwner(_sender: address):
      assert _sender == self.owner # <- replaced msg.sender with _sender
    
    @public
    def writeValue(_value: int128):
        self.checkOwner(msg.sender) # <- pass msg.sender as an argument 
        self.value = _value
    

    Maybe that's OK? But it requires a deeper understanding of how both the EVM and Vyper work.

    Backwards Compatibility

    Dependent on approach.

    Copyright

    Copyright and related rights waived via CC0

    VIP: Discussion VIP: Approved 
    opened by maurelian 52
  • We need a logo! (now closed)

    We need a logo! (now closed)

    Challenge

    Who has some design chops and wants to make us a cool logo?

    Solidity has a logo, but we're cooler so we should have a better one!

    P.S. we :hearts: you Solidity


    Rules

    If you have a submission, post it to this issue as an embedded image (hosted from wherever you animals host things) and whomever has the most :+1:'s wins the bounty! Anyone can vote on submissions !

    Challenge ends with our beta release (currently June 1st), where the winning submission will be added as a PR to our README/docs.

    Closing Date: 1st June 2018

    NOTE: Please do not submit a PR yet! Add your submission as a comment below!

    NOTE: Please nothing offensive. Keep it clean, Vyperinos!

    NOTE: Keep it original. As pointed out in the comments existing Vyper logos do already exist. Please refrain from making them look too similar, we don't want to get involved in any copy infrigement battles :stuck_out_tongue_closed_eyes:

    NOTE: Please also see Ethereum Branding Guidelines


    Sponsors

    SNT bounty sponsored by Status (https://openbounty.status.im). ETH Bounty sponsored by @jacqueswww and myself Feel free to add more bounties if you desire! ETH/ERC20/ERC223 accepted


    Brainstorming and Comments

    Feel free to add notes with your concepts of what Vyper is and brainstorm concepts.

    My design keywords (just for brainstorming):

    • Snek (obvs)
    • Sharp
    • Secure
    • Emerald
    • Friendly

    And some additional insperation: https://docs.google.com/document/d/1TSqVXVXVjiVxH5COXgIu90_dSJTQv3_Ka-aI6MYqeIo

    NOTE: Anyone can add a comment here just chatting about the designs or whatnot. Official entries should just contain the picture (optionally some comment about it) and are voted on ONLY using :+1:

    bounty 
    opened by fubuloubu 51
  • refactor: front-end type system

    refactor: front-end type system

    What I did

    refactor type system. redo the type hierarchy - instead of distinction between "Primitives" and "Definitions", have single type system + ExprInfo

    • simplify type hierarchy
    • ~merge old and new type systems~ will do this in a follow up PR
    • refactor builtins dir structure. merge builtin_functions/ and builtin_interfaces/ to builtins/.

    How I did it

    rethinking of the approach; don't need two classes for each type, factor into VyperType + ExprInfo + VarInfo. handling of types in the regular namespace is generally by dispatching into special constructor (for structs and interfaces) or attributes (for enums) mode.

    How to verify it

    Commit message

    This commit refactors the front-end type system.
    
    Currently, there are essentially two classes types for each vyper type.
    "Primitives" represented raw types, and "Definitions" represent
    the instantiation of types attached to each expression in a program.
    "Definitions" additionally carry around annotation information related
    to the expressions they tag, such as mutability and location info. This
    system also handled dispatching into the correct routines for cases
    where a raw type (e.g. "MyStruct") is used in expr land (vs an instance
    of a type, e.g.  "my_struct"). This is important because certain types
    are callable or attributable - specifically, constructors and enum
    members (ex. `MyStruct()` and `MyEnum.FOO`).
    
    This commit reworks the system by factoring the annotation info into
    VyperType and ExprInfo. "Primitives" in the old system can be thought of
    as VyperTypes, and "Definitions" in the old system are most similar to
    the new ExprInfo. To handle cases where types can live in expr land,
    this commit also clarifies that usage by promoting raw types into the
    special, internal TYPE_T type (which can be thought of as "the type of
    a type"). This commit also simplifies the inheritance structure of vyper
    types.
    
    Some other miscellaneous things in this commit:
    - AST class hierarchy gets more refined - addition of ExprNode
    - rename of `vyper/semantics/validation/` -> `vyper/semantics/analysis/`
    - type system directory structure simplified
    - merge of `builtin_functions/` and `builtin_interfaces/` to `builtins/`
    
    Co-authored-by: z80 <[email protected]>
    

    Description for the changelog

    Cute Animal Picture

    image

    opened by charles-cooper 42
  • VIP: Enable Dynamic Analysis/Symbolic Execution Checks

    VIP: Enable Dynamic Analysis/Symbolic Execution Checks

    Preamble

    VIP: <to be assigned>
    Title: assertions that should never-ever fail
    Author: Yoichi Hirai <[email protected]>
    Type: Standard Track
    Status: Draft
    Created: 2018-03-21
    

    Simple Summary

    Add a special type of assertion that should never ever fail. When a static analyzer can fire it, the program surely has a bug.

    Abstract

    Static analyzers can detect bugs, but only when the desired properties are specified. The easiest way is to insert a "never-to-fail" assertions in the program.

    Motivation

    Mythril has a feature to detect when 0xfe is somehow reachable. KEVM can soon do that.

    assert in vyper is expected to fail sometimes, and it is compiled to REVERT. REVERT might indicate a mistake of the caller, a mistake of the programmer, or a mistake of the compiler. So, static analyzers cannot shout "this is a bug".

    Instead, if Vyper has a never-to-fail assertion that translates to INVALID (0xfe), static analyzers can confidently shout "this is a bug. See, this execution reaches INVALID".

    Alternatives are specially formatted comments like ACSL or JML, but they are hard to learn.

    Specification

    Add a additional custom constant to the assert statement:

        assert amount != 0, UNREACHABLE
    

    as well as

        raise UNREACHABLE
    

    Backwards Compatibility

    A program containing a name assure will cause compillation errors.

    Copyright

    Copyright and related rights waived via CC0

    VIP: Discussion VIP: Approved 
    opened by pirapira 42
  • VIP: Square root function

    VIP: Square root function

    What's your issue about?

    We don't have sqrt function, this is useful to have for bonding curves.

    How can it be fixed?

    Embed this code:

    
    def test_sqrt(get_contract):
    
        code = """
    @public
    def sqrt256(x: uint256) -> uint256:
        z: uint256 = (x + 1) / 2
        y: uint256 = x
    
        for i in range(256):
            if (z > y):
                break
            y = z
            z = (x / z + z) / 2
        return y
    
    
    @public
    def sqrt_decimal(x: decimal) -> decimal:
        assert x >= 0.0
        if x == 0.0:
            return 0.0
        z: decimal = (x + 1.0) / 2.0
        y: decimal = x
    
        for i in range(256):
            if (z == y):
                break
            y = z
            z = (x / z + z) / 2.0
        return y
    
        """
    
        c = get_contract(code)
    
        assert c.sqrt256(2) == 1
        # math.sqrt(2000) == 44.721359549995796
        assert c.sqrt_decimal(2000) == Decimal('44.7213595499')
    
    enhancement VIP: Approved 
    opened by jacqueswww 36
  • Cannot post events after create an uninitialized local variable

    Cannot post events after create an uninitialized local variable

    When working with the Eth2 deposit contract I noticed a strange behaviour which I presume is a compiler bug.

    Notice that the tests pass in https://github.com/ethereum/eth2.0-specs/pull/1152/commits/abe48cc98857c3350d45656d3d4a6f2e6af2784d (the command to run the tests is make compile_deposit_contract; make test_deposit_contract) but fail if you move line 92 (the Deposit log) to line 80 the tests fail when nothing has really changed. I haven't had time to debug it but my guess would be that that it has something to do with zero_bytes32: bytes32, possibly that junk is being written to it.

    bug 
    opened by JustinDrake 34
  • What should the syntax for (i) ABI-formatted logs, and (ii) calls to external contracts be?

    What should the syntax for (i) ABI-formatted logs, and (ii) calls to external contracts be?

    For ABI-formatted logs, we'd need to have syntax for both event type declaration and making the actual logs. For event type declaration, one option is for the parser to expect a list of declarations between storage variable declarations and function declarations that look like this:

    MyLog: __log__(arg_1: num, arg2: indexed(bytes32), arg3: timestamp, arg4: bytes <= 100)
    

    For the actual logging, I personally highly disagree with Solidity's syntax of making event logs and function calls syntactically the same; it goes against Viper's goals of making it hard to write misleading code.

    One option is to copy Serpent syntax:

    log(type=MyLog, 5, sha3("cow"), block.timestamp, "moose")
    

    Another is:

    log.MyLog(5, sha3("cow"), block.timestamp, "moose")
    

    For external contract calls, we already have raw_call, but it would be good to have something ABI-formatted. We have the ABI formatting call in place already for self-calls, but to extend that to external calls we need a syntax for declaring external contract types.

    One option is for the parser to expect another list of declarations, like:

    class Foo():
        def bar(arg1: num, arg2: bytes32): pass
        @constant
        def baz(arg1: bytes <= 100, arg2: num256): pass
    

    Another is to just directly pass in JSON ABI:

    Foo = extern([{"constant": false, "type": "function", "name": "bar(int128,bytes32)", "outputs": [], "inputs": [{"type": "int128", "name": "arg1"}, {"type": "bytes32", "name": "arg2"}]}, {"constant": true, "type": "function", "name": "baz(bytes,uint256)", "outputs": [], "inputs": [{"type": "bytes", "name": "arg1"}, {"type": "uint256", "name": "arg2"}]}])
    

    Then, one could declare anything from then on as having type Foo (we'd require contract types to start with a capitalized letter).

    Any other ideas?

    opened by vbuterin 34
  • Meta Issue: Tracker for codebase cleanup

    Meta Issue: Tracker for codebase cleanup

    This is a tracking issue that I'm using to dump my thoughts on things that can be cleaned up in this codebase.

    General

    • [x] convert to circle-ci
    • [x] make codebase pep8 compliant
    • [x] add mypy
    • [x] use tox
    • [ ] use enum instead of strings for typ values.
    • [ ] use docstrings instead of comments for class definitions in vyper.types.types
    • [x] Use functools.wraps for decorators
    • [ ] Use proper semantically meaningful exception classes instead of the base Exception
    • [ ] Create Opcodes Enum for easier referencing opcodes.
    • [ ] Use of floating point values seems like a foot gun. Maybe use decimal.Decimal?
    • [ ] Use f-strings
    • [ ] Use of magic string in location == "memory" should be an Enum.
    • [ ] Rename sha3 to keccak across codebase.

    Specifics

    • [ ] vyper.type.types.NodeType.__eq__

    change NodeType.__eq__ to require subclasses to implement and remove eq hook.

    • [ ] vyper.types.types.parse_type

    Takes multiple arguments like sigs, custom_units, custom_structs and constants. Current read of the code suggests there are data structures which have been defined in the code and thus, this gives the parser the ability to properly parse the AST into these types. If so, I believe this should be formalized into something akin to the WASM Store to wrap these data structures up into a single wrapper for easier and less error prone portability.

    • [ ] vyper.types.types.StructType

    Takes a mapping of field_name -> field_type for members argument. This relies on dictionary ordering (which is admittedly now reliable) but also is a more difficuult data structure to reliably type hint. Consider using an iterable of 2-tuples: (('field_a', TypeA), ('field_b', TypeB)). Benefits are easier type safety through type hinting. Cons are additional validation step to ensure field uniqueness.

    • [ ] vyper.types.types.get_size_of_type

    Relies on prior knowledge about types. This should probably be an API of the type classes.

    • [ ] vyper.types.types.has_dynamic_data

    Relies on prior knowledge about types to determine. This should probably just be an API of the type classes.

    • [ ] vyper.functions.signature.signature

    Uses non-canonical argz and kwargz with z suffixes. Convert to normal *args, **kwargs

    Inner decorator function isn't using functools.wraps.

    More usage of magic strings where an Enum is probably better.

    • [ ] vyper.opcodes

    Replace use of list with NamedTuple.

    • [ ] vyper.compiler.gas_estimate

    Uses runtime assert statement which is easily disabled. Change to explicit exception raising.

    • [x] vyper.compiler.mk_full_signature

    Loop uses enumerate to generate indices idx used to modify abi at that indices. Instead, use zip to pair functions with their abi definitions.

    • [ ] vyper.compiler.get_source_map

    Builds dict using mutation. Vendor a version of to_dict decorator to remove mutation pattern.

    • [x] vyper.compiler.compile_codes

    Uses mutable data structure as default for argument

    Use of magic strings for output_type should be constrained to enums.

    • [x] vyper.compiler.compile_code

    Uses mutable data structure as default for argument

    • [ ] vyper.compiler.get_asm

    constant string mutation (which actual ends up as full object copies) adds overhead. Converting to a wrapped generator pattern that joins all of the produced strings at the end should be more performant and remove mutation.

    • [ ] vyper.compile_lll

    Use of next_symbol global counter appears to be used to create a unique marker in the code such as _sym_0, _sym_1. Replace with itertools.count(). Replace with uuid.uuid4(). Replace with generator function that wraps an itertools.count() style counter. Embed within an object with a defined lifecycle that gets passed around during compilation.

    • [ ] vyper.compile_lll.is_symbol

    Replace use of magic string with something more concrete like a custom class. Potentially the custom class could handle the mechanism for generating unique symbols.

    • [ ] vyper.compile_lll.instruction

    instruction is a class and thus should be named using common convention Instruction.

    • [x] vyper.compile_lll.apply_line_numbers

    Needs to use functools.wraps for inner function.

    • [ ] vyper.compile_lll.compile_to_assembly

    Convert runtime assert statements to raise proper exceptions.

    • [ ] vyper.compile_lll.compile_to_assembly

    Detection of whether something is or is not an opcode is done via isinstance(value, str) and value in opcodes. If we had an Opcodes Enum this could be as simple as checking if Opcodes(value) raised an exception or not.

    • [ ] vyper.compile_lll.compile_to_assembly

    Use of inlined opcode string values like "PUSH" would be better as Enum or constant values.

    • [ ] vyper.compile_lll.compile_to_assembly

    Individual blocks in the if/elif/.../else block could be partitioned off into smaller standalone functions.

    • [ ] vyper.compile_lll.compile_to_assembly

    The section that handles clamping values has an if/elif which is missing a final else clause allowing for undefined behavior if none of the conditions evaluates truthy

    • [ ] vyper.compile_lll.assembly_to_evm

    Use formal data structure for line_number_map instead of dictionary.

    • [ ] vyper.compile_lll.assembly_to_evm

    Inside of the if isinstance(item, list), the local value line_number_map is overwritten which appears to be a potentially destructive mistake as it will destroy any state that was previously built up locally.

    • [ ] vyper.optimizer.get_int_at

    Uses inline logic for converting a value to a signed integer. Should be extracted into utility that is tested.

    • [ ] vyper.util.is_instances

    Confusingly named. Very visually similar to isinstance. Maybe rename to a all_is_instances

    • [ ] vyper.parser.constants.Constants.unroll_constant

    Use of fail flag is antipattern. Restructure to allow inlined exception raising.

    • [x] vyper.parser.context.Context.start_blockscope and others

    The various function pairs like start_blockscope/end_blockscope, set_in_assertion, set_in_for_loop/remove_in_for_loop should be converted to use context manager pattern so that exiting the scope cannot be accidentally forgotten.

    • [ ] vyper.parser.global_ctx.GlobalContext.get_item_name_and_attributes

    Returns None for item name in final block which suggests there is either a case where something does not have a name or that there is return value checking occuring somewhere.

    • [ ] vyper.parser.stmt.Statements._check_valid_assign

    Does not have a final else block allowing function to exit if none of the conditions evaluate truthy.

    • [ ] vyper.parser.stmt.Statements.parse_for

    Uses implicit else for final clause type. Should be converted to explicitely check that the statement is formed as expected and add a final else block that raises an invariant exception.

    opened by pipermerriam 32
  • VIP: Custom Parser

    VIP: Custom Parser

    Preamble

    VIP: 563 Title: Custom Parser Author: @fubuloubu @DavidKnott @jacqueswww Type: Standard Status: Draft Created: 2017-12-08

    Simple Summary

    Implement a custom parser for Viper that doesn't directly tie us to Python-only syntax, enabling a more focused grammer for our langauge

    Abstract

    We've been discussing this for a while. A custom parser would allow us to define our syntax more precisely rather than leveraging Python syntax and being tied to only what Python's syntax can provide. We will continue to use Python as a template due to it's clarity and ease of reading, but we need to make decisions that diverge from Python and a custom Parse will enable that.

    Motivation

    There are specific things that have been discussed where this is necessary:

    • Clarifying the external contract type
    • Changing the mapping type for greater clarity
    • Custom Types
    • etc...

    Specification

    We may be able to leverage a Python-compatible lex/yacc library like ply. We should also leverage some of the work the k-framework guys are doing in order to infer a grammar that is consistent and free of formalized conflicts

    Backwards Compatibility

    Try to maintain backwards compatibility initially, however some of the VIPs this one will enable will be breaking changes in the syntax.

    Copyright

    Copyright and related rights waived via CC0

    VIP: Discussion 
    opened by fubuloubu 27
  • feat: implement dynamic arrays

    feat: implement dynamic arrays

    What I did

    This commit implements Solidity-ABI-compatible dynamic arrays in vyper.

    Dynamic arrays have the type DynArray[<type>, <maxlen>]. They are implemented similarly to bytestrings, with a single length word followed by the data, <len> <data...>.

    How I did it

    Threaded through typechecker, added abi encoder/decoder and added the relevant functionality in codegen

    How to verify it

    See tests

    Description for the changelog

    add dynamic arrays to vyper

    Cute Animal Picture

    Put a link to a cute animal picture inside the parenthesis-->

    opened by charles-cooper 26
  • Raise clearer exception when using a yet undeclared variable in a type annotation

    Raise clearer exception when using a yet undeclared variable in a type annotation

    What I did

    As per #3214, trying to reference a yet undeclared constant variable in the type annotation of another variable's declaration results in a fairly unhelpful error message: vyper.exceptions.UndeclaredDefinition: 'self' has not been declared. This fix ensures that a more detailed exception is raised.

    How I did it

    The exception is raised when trying to check whether the variable is a storage variable by checking if its name is in self.namespace["self"].typ.members. However this check can happen before self is added to the namespace. When the constant variable is referenced in a type annotation, the check will happen during folding and before validation, so there will be no self key in namespace, leading to the previous exception being raised. A simple check on whether the key is present suffices to prevent this exception from being raised and to instead raise another detailed UndeclaredDefinition exception containing the undeclared variable's name and line number of the error.

    How to verify it

    Compiling the following contract:

    PRECISIONS: constant(uint256[N_COINS]) = [
        1000000000000,
        10000000000,
        1,
    ]
    N_COINS: constant(int128) = 3
    

    Now raises the following exception:

    vyper.exceptions.UndeclaredDefinition: 'N_COINS' has not been declared. 
      contract "***.vy:1", line 1:29 
      ---> 1 PRECISIONS: constant(uint256[N_COINS]) = [
      ------------------------------------^
           2     1000000000000,
    
    

    Commit message

    Raise clearer exception when using a yet undeclared variable in a type annotation

    Description for the changelog

    Cute Animal Picture

    image

    opened by benber86 0
  • Vague exception message when accessing a storage variable before declaration in a subscript

    Vague exception message when accessing a storage variable before declaration in a subscript

    Version Information

    • vyper Version (output of vyper --version): 0.3.7
    • OS: linux
    • Python Version (output of python --version): 3.10

    What's your issue about?

    Referencing a constant variable in a subscript in a type annotation before it is declared when declaring another state variable gives the following unclear error message: vyper.exceptions.UndeclaredDefinition: 'self' has not been declared.

    Can be reproduced with the following example:

    PRECISIONS: constant(uint256[N_COINS]) = [
        1000000000000,
        10000000000,
        1,
    ]
    
    N_COINS: constant(int128) = 3
    
    opened by benber86 0
  • fix: constant type propagation to avoid type shadowing

    fix: constant type propagation to avoid type shadowing

    normally, type checking is idempotent, but in the case of for loop type checking, correct typechecking depends on the "type" field being fresh. this moves the type annotation to a different field which does not shadow "type".

    fixes #3212

    What I did

    How I did it

    How to verify it

    Commit message

    Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

    Description for the changelog

    Cute Animal Picture

    Put a link to a cute animal picture inside the parenthesis-->

    opened by charles-cooper 1
  • incorrect type checking of loop variables

    incorrect type checking of loop variables

    Version Information

    • vyper Version (output of vyper --version): 0.3.7

    the type of a loop variable can take multiple values in a loop. minimal repro:

    @external
    def main():
        for j in range(3):
            x: uint256 = j
            y: uint16 = j
    

    thanks to @trocher for reporting

    bug - typechecker 
    opened by charles-cooper 0
  • fix: restrict STATICCALL to @view

    fix: restrict STATICCALL to @view

    What I did

    fix #3093. Restricted mutability of raw_call to @view when STATICCALL is used

    How I did it

    How to verify it

    Commit message

    restricted mutability of raw_call to @view when STATICCALL is used

    Functions that make use of the STATICCALL opcode must be declared as view.

    Description for the changelog

    Cute Animal Picture

    Put a link to a cute animal picture inside the parenthesis-->

    opened by emc415 1
  • Option to add an upper bound check on returndatasize with raw_call

    Option to add an upper bound check on returndatasize with raw_call

    What I did

    Added an optional argument to raw_call to allow for a safety check on the size of the return data. When revert_on_excess is set to True, the call will revert if the receiving variable is smaller than the returned data. (This is the default behavior already on external calls, but I set the default value to False here).

    How I did it

    Added an assert comparing returndatasize and max_outsize when revert_on_excess is set to True.

    How to verify it

    Run the updated tests in test_raw_call.py

    Commit message

    Option to add an upper bound check on returndatasize with raw_call

    Description for the changelog

    Cute Animal Picture

    image

    opened by benber86 1
Releases(v0.3.7)
Owner
Vyper
Vyper
This is a simple Bitcoin non-deterministic wallet address generator coded in Python 3.

This is a simple Bitcoin non-deterministic wallet address generator coded in Python 3. It generates a Private Key in different formats (hex, wif and compressed wif) and corresponding Public Addresses

7 Dec 22, 2022
RSI Algorithmic Trading with Python

In this repository you can see my first algorithhmic trading script. I use 5 cryptocurrencies: Bitcoin (BTC), Ethereum (ETH), Bitcoin Cash (BCH), Litecoin (LTC) and Chainlink (LINK).

Jon Aldekoa 4 Mar 16, 2022
Audits Python environments and dependency trees for known vulnerabilities

pip-audit pip-audit is a prototype tool for scanning Python environments for packages with known vulnerabilities. It uses the Python Packaging Advisor

Trail of Bits 701 Dec 28, 2022
C0mptCrypt - An object-oriented, minamalistic, simple encryption library in Python

C0mptCrypt allows you to encrypt strings of text. It can only be decrypted using C0mptCrypt and not by random online tools. You can use this for a variety of things from creating passwords, to encryp

c0mpt0 4 Aug 22, 2022
Cryptocurrency Exchange Websocket Data Feed Handler

Cryptocurrency Exchange Websocket Data Feed Handler

Bryant Moscon 1.6k Dec 31, 2022
Mina is a new cryptocurrency with a constant size blockchain, improving scaling while maintaining decentralization and security.

Mina Mina is the first cryptocurrency with a lightweight, constant-sized blockchain. This is the main source code repository for the Mina project. It

1.6k Jan 07, 2023
Persian caesar and rot16 encryptor and decryptor

persian caesar and rot16 encrypt and decrypt how to install if you use windows python -m venv .venv .\.venv\Script\activate python -m pip install -r r

Mehdi Radfar 5 Oct 28, 2022
Run with one command grafana, prometheus, and a python script to collect and display cryptocurrency prices and track your wallet balance.

CryptoWatch Track your favorite crypto coin price and your wallet balance. Install Create .env: ADMIN_USER=admin ADMIN_PASSWORD=admin Configure you

Rafael Zimmermann 13 Dec 13, 2022
Crypto Stats and Tweets Data Pipeline using Airflow

Crypto Stats and Tweets Data Pipeline using Airflow Introduction Project Overview This project was brought upon through Udacity's nanodegree program.

Matthew Greene 1 Nov 24, 2021
Enchpyter, is able to encrypt and decrypt words as you determine, of course, according to the alphabet.

Enchpyter Enchpyter is a program do encrypt and decrypt any word you want (just letters). You enter how many letters jumps and write the word, so, the

João Assalim 2 Oct 10, 2022
The (Python-based) mining software required for the Game Boy mining project.

The (Python-based) mining software required for the Game Boy mining project.

Ghidra Ninja 31 Nov 04, 2022
Active github repos of all cryptocurrencies

This repo is to maintain the list of active repositories for all cryptocurrencies that https://codemask.org uses. The active list will be automaticall

CodeMask 5 May 20, 2022
Decrypting winrm traffic using password/ntlm hash

Decrypting winrm traffic using password/ntlm hash

Haoxi Tan 9 Jan 05, 2022
A curated list of resources dedicated to reinforcement learning applied to cyber security.

Awesome Reinforcement Learning for Cyber Security A curated list of resources dedicated to reinforcement learning applied to cyber security. Note that

Kim Hammar 212 Jan 02, 2023
This is a simple application to generate HD wallet addresses for cryptocurrency coins.

HD-Wallet-Address This is a mini service to generate addresses in the master HD-Wallet. It will use py_crypto_hd_wallet package as a base. Prerequisit

Amin Abbasi 1 Dec 16, 2021
zhash is a simple Python tool which allows to create/crack hashes

zhash zhash is a simple python tool which allows you to crack/create hashes. Below are the list of supported algorithms that zhash can crack Supported

3 May 27, 2022
GreenDoge is a modern community-centric green cryptocurrency based on a proof-of-space-and-time consensus algorithm.

GreenDoge Blockchain Download GreenDoge blockchain GreenDoge is a modern community-centric green cryptocurrency based on a proof-of-space-and-time con

40 Sep 11, 2022
A simple web application with tools of cryptography, made with Flask and Cryptography.

Crypto Tools A web application made with Flask that allows the use of some cryptography tools like message digest, RSA key pair generation and a decip

Felipe Valentin 0 Jan 20, 2022
Simple bitcoin ticker for the Pimorono Inky pHAT Red.

bitcoin-ticker Simple bitcoin ticker for the Pimorono Inky pHAT Red. Equipment Raspberry Pi Zero W v1.1 or Pi 2 model b v1.1 Pimorono Inky pHAT Red (S

2 Mar 15, 2022
Simple python program to encrypt files with AES-256 encryption

simple-enc Simple python program to encrypt files with AES-256 encryption Setup First install "pyAesCrypt" using pip. Thats it! Optionally you can add

Hashm 2 Jan 19, 2022