Skip to content

Commit

Permalink
Update README badges and add dual-license header
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Apr 6, 2018
1 parent 284a026 commit 5a3202f
Show file tree
Hide file tree
Showing 72 changed files with 556 additions and 55 deletions.
File renamed without changes.
21 changes: 21 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2018 Status Research & Development GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Nimbus

[![Build Status](https://travis-ci.org/status-im/nimbus.svg?branch=master)](https://travis-ci.org/status-im/nimbus)
[![Build Status (Travis)](https://img.shields.io/travis/status-im/nimbus/master.svg?label=Linux%20/%20macOS "Linux/macOS build status (Travis)")](https://travis-ci.org/status-im/nimbus)
[![Windows build status (Appveyor)](https://img.shields.io/appveyor/ci/jarradh/nimbus/master.svg?label=Windows "Windows build status (Appveyor)")](https://ci.appveyor.com/project/jarradh/nimbus)[![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg)

An Ethereum 2.0 Sharding Client for Resource-Restricted Devices

Expand All @@ -12,3 +15,12 @@ Join the Status community chats:
Rationale

https://docs.google.com/document/d/14u65XVNLOd83cq3t7wNC9UPweZ6kPWvmXwRTWWn0diQ/edit#

## License

Licensed under either of

* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.
7 changes: 7 additions & 0 deletions src/account.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
constants, errors, ttmath, rlp

Expand Down
7 changes: 7 additions & 0 deletions src/block_obj.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
logging, constants, utils / header, ttmath

Expand Down
7 changes: 7 additions & 0 deletions src/chain.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
tables, ttmath,
logging, constants, errors, validation, utils / hexadecimal, vm / base, db / db_chain
Expand Down
7 changes: 7 additions & 0 deletions src/computation.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
strformat, strutils, sequtils, tables, macros, ttmath, terminal,
constants, errors, utils/hexadecimal, utils_numeric, validation, vm_state, logging, opcode_values, types,
Expand Down
Binary file removed src/constants
Binary file not shown.
7 changes: 7 additions & 0 deletions src/db/backends/memory_backend.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import tables, ttmath

type
Expand Down
15 changes: 11 additions & 4 deletions src/db/db_chain.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import strformat, tables, ttmath, state_db, backends / memory_backend

type
Expand All @@ -23,7 +30,7 @@ proc `$`*(db: BaseChainDB): string =

# proc getCanonicalBlockHeaderByNumber*(self: BaseChainDB; blockNumber: int): BlockHeader =
# ## Returns the block header with the given number in the canonical chain.
# ##
# ##
# ## Raises BlockNotFound if there's no block header with the given number in the
# ## canonical chain.
# validateUint256(blockNumber)
Expand Down Expand Up @@ -59,7 +66,7 @@ proc `$`*(db: BaseChainDB): string =

# proc getBlockHeaderByHash*(self: BaseChainDB; blockHash: cstring): BlockHeader =
# ## Returns the requested block header as specified by block hash.
# ##
# ##
# ## Raises BlockNotFound if it is not present in the db.
# validateWord(blockHash)
# try:
Expand Down Expand Up @@ -90,7 +97,7 @@ proc `$`*(db: BaseChainDB): string =
# yield rlp.decode(receiptData)
# else:
# break

# iterator getBlockTransactions*(self: BaseChainDB; blockHeader: BlockHeader;
# transactionClass: typedesc): FrontierTransaction =
# var transactionDb = HexaryTrie(self.db)
Expand All @@ -101,7 +108,7 @@ proc `$`*(db: BaseChainDB): string =
# yield rlp.decode(transactionData)
# else:
# break

# proc addBlockNumberToHashLookup*(self: BaseChainDB; header: BlockHeader): void =
# var blockNumberToHashKey = makeBlockNumberToHashLookupKey(header.blockNumber)
# self.db.set(blockNumberToHashKey, rlp.encode(header.hash))
Expand Down
17 changes: 12 additions & 5 deletions src/db/state_db.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
strformat, tables,
../constants, ../errors, ../validation, ../account, ../logging, ../utils_numeric, .. / utils / [padding, bytes, keccak], ttmath, rlp
Expand All @@ -13,7 +20,7 @@ proc newAccountStateDB*(db: Table[string, string], readOnly: bool = false): Acco
proc logger*(db: AccountStateDB): Logger =
logging.getLogger("db.State")

proc getAccount(db: AccountStateDB, address: string): Account =
proc getAccount(db: AccountStateDB, address: string): Account =
# let rlpAccount = db.trie[address]
# if not rlpAccount.isNil:
# account = rlp.decode[Account](rlpAccount)
Expand All @@ -24,7 +31,7 @@ proc getAccount(db: AccountStateDB, address: string): Account =

proc setAccount(db: AccountStateDB, address: string, account: Account) =
# db.trie[address] = rlp.encode[Account](account)
discard # TODO
discard # TODO


proc getCodeHash*(db: AccountStateDB, address: string): string =
Expand All @@ -51,7 +58,7 @@ proc setStorage*(db: var AccountStateDB, address: string, slot: UInt256, value:
#validateGte(value, 0, title="Storage Value")
#validateGte(slot, 0, title="Storage Slot")
validateCanonicalAddress(address, title="Storage Address")

# TODO
# let account = db.getAccount(address)
# var storage = HashTrie(HexaryTrie(self.db, account.storageRoot))
Expand All @@ -71,11 +78,11 @@ proc setStorage*(db: var AccountStateDB, address: string, slot: UInt256, value:
proc getStorage*(db: var AccountStateDB, address: string, slot: UInt256): (UInt256, bool) =
validateCanonicalAddress(address, title="Storage Address")
#validateGte(slot, 0, title="Storage Slot")

# TODO
# make it more correct
# for now, we just use a table

# let account = db.GetAccount(address)
# var storage = HashTrie(HexaryTrie(self.db, account.storageRoot))

Expand Down
9 changes: 8 additions & 1 deletion src/errors.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

type
EVMError* = object of Exception
## Base error class for all evm errors.

VMNotFound* = object of EVMError
## No VM available for the provided block number.

BlockNotFound* = object of EVMError
## The block with the given number/hash does not exist.

Expand Down
7 changes: 7 additions & 0 deletions src/lightchain_shell.nim
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

# not implemented
7 changes: 7 additions & 0 deletions src/logging.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import strformat, terminal

type
Expand Down
13 changes: 10 additions & 3 deletions src/logic/arithmetic.nim
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
../constants, ../utils_numeric, ../computation, ../types,
.. / vm / [gas_meter, stack], ../opcode, ../opcode_values,
helpers, ttmath, strutils

proc add*(computation: var BaseComputation) =
# Addition
var (left, right) = computation.stack.popInt(2)

var res = (left + right) and UINT_256_MAX
pushRes()

Expand Down Expand Up @@ -79,7 +86,7 @@ proc sdiv*(computation: var BaseComputation) =
proc exp*(computation: var BaseComputation) =
# Exponentiation
let (base, exponent) = computation.stack.popInt(2)

var gasCost = GAS_EXP_BYTE.u256
#if exponent != 0:
# gasCost += GAS_EXP_BYTE * (1 + log256(exponent))
Expand Down
7 changes: 7 additions & 0 deletions src/logic/block.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
../constants, ../computation, ../vm/stack, ../vm_state, ttmath

Expand Down
7 changes: 7 additions & 0 deletions src/logic/block_ops.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
../constants, ../errors, ../computation, ../vm_state, ../types, .. / vm / [stack]

Expand Down
Binary file removed src/logic/call
Binary file not shown.
15 changes: 11 additions & 4 deletions src/logic/call.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
strformat,
../constants, ../types, ../errors, ../computation, ../opcode, ../opcode_values, ../logging,
../constants, ../types, ../errors, ../computation, ../opcode, ../opcode_values, ../logging,
.. / vm / [stack, memory, gas_meter, message],
.. / utils / [address, bytes],
ttmath
Expand Down Expand Up @@ -87,7 +94,7 @@ method runLogic*(call: BaseCall, computation) =
# else:
# code = state_db.get_code(to)
let code = ""

let childMsg = computation.prepareChildMessage(
childMsgGas,
to,
Expand All @@ -96,7 +103,7 @@ method runLogic*(call: BaseCall, computation) =
code,
MessageOptions(
shouldTransferValue: shouldTransferValue,
isStatic: isStatic))
isStatic: isStatic))
if not sender.isNil:
childMsg.sender = sender
# let childComputation = computation.applyChildComputation(childMsg)
Expand All @@ -120,7 +127,7 @@ method msgExtraGas(call: Call, computation; gas: UInt256, to: string, value: UIn
# with computation.vm_state.state_db(read_only=True) as state_db:
# let accountExists = db.accountExists(to)
let accountExists = false

let transferGasFee = if value != 0: GAS_CALL_VALUE else: 0.u256
let createGasFee = if not accountExists: GAS_NEW_ACCOUNT else: 0.u256
transferGasFee + createGasFee
Expand Down
9 changes: 8 additions & 1 deletion src/logic/comparison.nim
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
../constants, ../utils_numeric, ../computation, ../vm/stack, ../types,
helpers, ttmath

quasiBoolean(lt, `<`) # Lesser Comparison

quasiBoolean(gt, `>`) # Greater Comparison

quasiBoolean(slt, `<`, signed=true) # Signed Lesser Comparison
Expand Down
13 changes: 10 additions & 3 deletions src/logic/context.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
strformat,
../constants, ../types, ../errors, ../utils_numeric, ../computation, ../vm_state, ../account, ../db/state_db, ../validation,
../constants, ../types, ../errors, ../utils_numeric, ../computation, ../vm_state, ../account, ../db/state_db, ../validation,
.. / vm / [stack, message, gas_meter, memory, code_stream], .. / utils / [address, padding, bytes], ttmath

proc balance*(computation: var BaseComputation) =
Expand Down Expand Up @@ -106,10 +113,10 @@ proc returnDataSize*(computation: var BaseComputation) =
proc returnDataCopy*(computation: var BaseComputation) =
let (memStartPosition, returnDataStartPosition, size) = computation.stack.popInt(3)
if returnDataStartPosition + size > computation.returnData.len:
raise newException(OutOfBoundsRead,
raise newException(OutOfBoundsRead,
"Return data length is not sufficient to satisfy request. Asked \n" &
&"for data from index {returnDataStartPosition} to {returnDataStartPosition + size}. Return data is {computation.returnData.len} in \n" &
"length")
"length")

computation.extendMemory(memStartPosition, size)
let wordCount = ceil32(size) div 32
Expand Down
7 changes: 7 additions & 0 deletions src/logic/duplication.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Nimbus
# Copyright (c) 2018 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import
macros, strformat,
../types, ../computation, ../vm/stack
Expand Down
Loading

0 comments on commit 5a3202f

Please sign in to comment.