Giter Site home page Giter Site logo

neo-go's Introduction

NeoGo logo

Go Node and SDK for the Neo blockchain.


codecov GithubWorkflows Tests Report GoDoc GitHub release (latest SemVer) License

Overview

NeoGo is a complete platform for distributed application development built on top of and compatible with the Neo project. This includes, but not limited to (see documentation for more details):

The protocol implemented here is Neo N3-compatible, however you can also find an implementation of the Neo Legacy protocol in the master-2.x branch and releases before 0.80.0 (0.7X.Y track).

Getting started

Installation

NeoGo is distributed as a single binary that includes all the functionality provided (but smart contract compiler requires Go compiler to operate). You can grab it from releases page, use a Docker image (see Docker Hub for various releases of NeoGo, :latest points to the latest release) or build yourself.

Building

Building NeoGo requires Go 1.20+ and make:

make

The resulting binary is bin/neo-go. Notice that using some random revision from the master branch is not recommended (it can have any number of incompatibilities and bugs depending on the development stage), please use tagged released versions.

Building on Windows

To build NeoGo on Windows platform we recommend you to install make from MinGW package. Then, you can build NeoGo with:

make

The resulting binary is bin/neo-go.exe.

Running a node

A node needs to connect to some network, either local one (usually referred to as privnet) or public (like mainnet or testnet). Network configuration is stored in a file and NeoGo allows you to store multiple files in one directory (./config by default) and easily switch between them using network flags.

To start Neo node on a private network, use:

./bin/neo-go node

Or specify a different network with an appropriate flag like this:

./bin/neo-go node --mainnet

Available network flags:

  • --mainnet, -m
  • --privnet, -p
  • --testnet, -t

To run a consensus/committee node, refer to consensus documentation.

If you're running a node on Windows, please turn off or configure Windows Firewall appropriately (allowing inbound connections to the P2P port).

Docker

By default, the CMD is set to run a node on privnet. So, to do this, simply run:

docker run -d --name neo-go -p 20332:20332 -p 20331:20331 nspccdev/neo-go

Which will start a node on privnet and expose node's ports 20332 (P2P protocol) and 20331 (JSON-RPC server).

Importing mainnet/testnet dump files

If you want to jump-start your mainnet or testnet node with chain archives provided by NGD, follow these instructions:

$ wget .../chain.acc.zip # chain dump file
$ unzip chain.acc.zip
$ ./bin/neo-go db restore -m -i chain.acc # for testnet use '-t' flag instead of '-m'

The process differs from the C# node in that block importing is a separate mode. After it ends, the node can be started normally.

Running a private network

Refer to consensus node documentation.

Smart contract development

Please refer to NeoGo smart contract development workshop that shows some simple contracts that can be compiled/deployed/run using NeoGo compiler, SDK and a private network. For details on how Go code is translated to Neo VM bytecode and what you can and can not do in a smart contract, please refer to the compiler documentation.

Refer to examples for more Neo smart contract examples written in Go.

Wallets

NeoGo wallet is just a NEP-6 file that is used by CLI commands to sign various things. CLI commands are not a direct part of the node, but rather a part of the NeoGo binary, their implementations use RPC to query data from the blockchain and perform any required actions. It's not required to open a wallet on an RPC node (unless your node provides some service for the network like consensus or oracle nodes do).

Monitoring

NeoGo provides Prometheus and Pprof services that can be enabled in the node in order to provide additional monitoring and debugging data.

Configuring any of the two services is easy, add the following section (Pprof instead of Prometheus if you need that) to the respective config/protocol.*.yml:

  Prometheus:
    Enabled: true
    Addresses:
      - ":2112"

where you can switch on/off and define port. Prometheus is enabled and Pprof is disabled by default.

Contributing

Feel free to contribute to this project after reading the contributing guidelines.

Before starting to work on a certain topic, create a new issue first describing the feature/topic you are going to implement.

Contact

License

  • Open-source MIT

neo-go's People

Contributors

alexvanin avatar aliceinhunterland avatar anikeev-yadro avatar annashaleva avatar aprasolova avatar carpawell avatar cthulhu-rider avatar dautt avatar dependabot[bot] avatar edgedlt avatar fabwa avatar furetur avatar fyfyrchik avatar fyrchik avatar hal0x2328 avatar im-kulikov avatar ixje avatar jeroenptrs avatar kevaundray avatar omahs avatar pmdcosta avatar roman-khimov avatar stepanovdmitrii avatar stevenjack avatar stevvns avatar suzumi1056 avatar tatiana-nspcc avatar volekerb avatar xiaoxianboy avatar zhangtao1596 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neo-go's Issues

Compiler cannot resolve third party packages.

Problem

The compiler cannot resolve third-party packages (github.com, ..). Some of the compilers internal tests refer to some packages of itself, which are considered "third-party" as the imported path prefix is also "github.com. Hence all those tests that have those dependencies are not passing.

schermafbeelding 2018-02-24 om 09 21 45

*update with the solution

After reading through this [awesome document] (https://github.com/golang/example/tree/master/gotypes) it was clear to use the go/loader package for building and type checking the source files, instead of the default tools the AST package gives us.

note: currently refactoring the build process to solve this problem.

Problems with parameters marshalling for invoke/invokefunction/invokescript

I'm trying to use neo-go's functions from RPC package to send requests to my privnet rpc port. I observe a problem that parameters for smart contract don't marshal correctly. Say, I'd like to perform the request with the body like:

{
    "jsonrpc": "2.0",
    "id": "2",
    "method": "invoke",
    "params": [
        "0x64743d938ee52fa63eb97b101a5e203679213e3b",
        "get",
        [
            {
                "type": "Array",
                "value": [
                	{"type": "Integer", "value": "1"}
                ]
            }
        ]
    ]
}

and to do it programmaticaly I write the code like:

    intParam := []smartcontract.Parameter{
        {
            Type: smartcontract.IntegerType,
            Value: "1",}}

    pparams := []smartcontract.Parameter {
        {
            Type: smartcontract.ArrayType,
            Value: intParam, }}

    response, _ = client.InvokeFunction(scHash, "get", pparams) 

The issue is, when JSON marshalling runs, the constants of type smartcontract.Parameter are turned into the numbers, while it should be strings like "Integer" or "Array" (according the docs at least!).

What I get instead of my expectations is

{
    "jsonrpc": "2.0",
    "method": "invokefunction",
    "params":
        [
            "0x64743d938ee52fa63eb97b101a5e203679213e3b",
            "get",
            [
                {
                    "type": 8,
                    "value":
                     [
                            {
                                "type": 2,
                                 "value": "1"}]}]],
    "id": 1
}

Am I doing something wrong or it really is a problem?
If so, I forked the repo and implemented a MarshalJSON function for smartcontract.Parameter type. I also added wrapper for Invoke RPC function. If you're interested you may look at it here.

improve error message

As requested by @kim, the error message must follow this convention:

{"jsonrpc":"2.0","error":{"code":-2146233033,"message":"One of the identified items was in an invalid format."},"id":1}

To find more about the context of this issue read here

TODO: refactor the errors methods in the errors.go file accordingly and amends all tests.

Any command to display Compiler (or neo-go) version?

Hi all! It would be nice to have a command to display neo-go version (or compiler version).
I'm trying to put that on neocompiler.io, to give a better feedback on which compiler version is being used.

Congratulations for the amazing work!

rewrite RPC package

I plan to rewrite RPC-package almost from scratch in the near future. This will make it easier to use and give a small boost to the development of the project.

[fixed by #131] Wrong answer for RPC method getaccountstate

https://docs.neo.org/en-us/node/cli/2.9.4/api/getaccountstate.html

our response is

{
    "jsonrpc": "2.0",
    "result": {
        "version": 0,
        "address": "AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y",
        "script_hash": "0xe9eed8dc39332032dc22e5d6e86332c50327ba23",
        "frozen": false,
        "votes": [],
        "balances": {
            "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7": "72099.99960000",
            "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b": "99989900"
        }
    },
    "id": 1
}

in documentation:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "version": 0,
        "script_hash": "0x1179716da2e9523d153a35fb3ad10c561b1e5b1a",
        "frozen": false,
        "votes": [],
        "balances": [{
            "asset": "0xc56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b",
            "value": "94"
        }]
    }
}
  1. In our response Balance is json.Object (map[string]string), but in documentation it's slice of objects
  2. Address not need in the answer

I'll fix it in a few days

Using --out automatically appends .avm

If you use the --out arg when compiling, it will automatically append .avm to the file path you enter

For example:
./bin/neo-go contract compile -i mycontract.go --out /Users/foo/bar/contract.avm
will make a file called contract.avm.avm and
./bin/neo-go contract compile -i mycontract.go --out /Users/foo/bar/contract
will make a file called contract.avm

VM : Add unifying Documentation

To my knowledge implementing a VM in another language will require one to read other languages implementation.

Creating a readme with the specifications of the VM will make ti easier to implement in newer languages and it will also allow all languages to have one point of reference.

The documentation should ideally be split into two parts; the stack and it's types and then the neo-vm.

The section on the stack and it's types would include all possible types of stack items, what type of stack it is and the rules around integers such as when they can overflow, what is the max neg/positive integer allowed, what happens if the integer is "-0", how to convert from an integer to a byte slice (with endian)...

The section on the vm would include the opcodes available and a step by step instruction on how to implement them, this should also include the effect that the opcodes have on the stack. The type of structure that the vm is(eval stack/invocation stack...), the possible vm states...

The section on the stack and it's types should come first.

It would be best to split this into two tasks; the stack and it's types, which is the foundation.Then the VM.

The stack and it's types can also be broken down into separate PRs, starting with the types.

Please also include a Table of contents and be concise with your definitions.

Compiler: Converting strings to byte slice panics

Problem

When I want to convert my string to a byte slice:

b := []byte("foo")

The compiler throws a runtime error.

This issue is caused by Go resolving []byte() as a function call that is not handled by the neo-go compiler.

Potential solution

Make []byte() a builtin neo-go compiler function and manually convert the string to bytes if the AST does not do it for us.

VM : Add Map and Struct Types

For map I believe it is:
Map[StackItem] -> StackItem

For struct:

-- I believe a struct is the same as an array, but with different behavioural qualities.

Issues in signing data with the private key Sign function

I have been trying to sign a message both in golang and python. But they are coming out to be different.

Is there something which I am missing here ? Any hint would be great. I am attaching both the snippets here.

  • This is the python example which works and I can use the signature for further usage.
from neocore.Cryptography.Crypto import Crypto
msg = "010001f0907b22616d6f756e74223a22313030303030303030222c2261737365745f6964223a2253575448222c22626c6f636b636861696e223a226e656f222c22636f6e74726163745f68617368223a2261313935633135343965376461363162386461333135373635613739306163376537363333623832222c2274696d657374616d70223a313533343039333534333031327d0000"

pk = "d1c109c40976b1bf570e744e4d51df5224e3932b99dfd8bbdc2dac89fe4f6bd8"
print( Crypto.Sign(msg.encode(), pk).hex())
# final signature = "2be46cb14ebb4102f816f2e33489e2fa1a8d7ad8212a689efedfdb09aa621a725b926a426d8fe9575c5fb29eaef120da63a22b37d9c54e2e8662e96e23c42c4f"
  • Here is the go-example for which I am using the wallet api: This signature is different from the python version ( I am not able to use it further as well )
package main

import (
        "encoding/hex"
        "fmt"
        
        // Change this to neo-go wallet 
        "neo-go/wallet"

)

func main() {
        msg := []byte("010001f0907b22616d6f756e74223a22313030303030303030222c2261737365745f6964223a2253575448222c22626c6f636b636861696e223a226e656f222c22636f6e74726163745f68617368223a2261313935633135343965376461363162386461333135373635613739306163376537363333623832222c2274696d657374616d70223a313533343039333534333031327d0000")
        primaryKey := "d1c109c40976b1bf570e744e4d51df5224e3932b99dfd8bbdc2dac89fe4f6bd8"

        pk, err := wallet.NewPrivateKeyFromHex(primaryKey)
        if err != nil {
                panic(err)
        }
        signature, err := pk.Sign(msg)
        if err != nil {
                panic(err)
        }
        fmt.Println(hex.EncodeToString(signature))
}
// output is this following: 7c47632798b6377992027f5602d7681f6548c16cf060f835c3638dfb034e018f09269bbe6b68786d4afd7936f3244c1e894b8a24bcefa795c123a07449201a81

VM: Add Conversion Methods for stack types Byte Array and BigInteger

If the type of the item cannot be determined by the opcode, we will store it on the stack as a ByteArrayItem until we need to use it.

This means that Byte Array, will need to override the default methods on abstractItem.

For example:

On the Stack there are two byte arrays b1 and b2. We see OpAdd. So we Pop both b1 and b2, then called b1.Integer() and b2.Integer() to convert them both to Integers, then we can add them.

We would do this for most of struct types, except for stack types like Map because for example there is an explicit NEWMAP opcode

Compiler: optimize generated bytecode

There are 3 main things that can be optimized:

Removing nops right before function calls.

This can make contracts not compatible with other compilers that rely on that opcode.

Removing the JMP 0x00 0x03 right before return statements.

This seems useless to me and van safe us 3 instructions before each return statement.

replacing Ofromaltstack and Odup with Odupfromaltstack

We could save some significant space by optimizing this.

can not run smart contract script, the vm throw FAULT message.

First i start local neo node by run this command: make run, then i try to run smart contract script token_sale.go:

NEO-GO-VM > loadgo token_sale.go
READY: loaded 2996 instructions
NEO-GO-VM > run
NEO-GO-VM > error encountered at instruction 9 (Oroll)
NEO-GO-VM > runtime error: invalid memory address or nil pointer dereference
FAULT
NEO-GO-VM > error encountered at instruction 10 (Osetitem)
NEO-GO-VM > interface conversion: interface {} is []vm.StackItem, not []uint8
FAULT
NEO-GO-VM 10 >

Data race in pkg/peer/stall (dev-branch)

==================
WARNING: DATA RACE
Read at 0x00c00007b050 by goroutine 7:
  runtime.mapiterinit()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/runtime/map.go:734 +0x0
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).loop()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:54 +0x31b
Previous write at 0x00c00007b050 by goroutine 6:
  runtime.mapdelete_faststr()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/runtime/map_faststr.go:281 +0x0
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).RemoveMessage()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:100 +0x148
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestAddRemoveMessage()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:24 +0x26f
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 7 (running) created at:
  github.com/CityOfZion/neo-go/pkg/peer/stall.NewDetector()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:42 +0x16c
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestAddRemoveMessage()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:17 +0x55
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 6 (finished) created at:
  testing.(*T).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:878 +0x659
  testing.runTests.func1()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1119 +0xa8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
  testing.runTests()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1117 +0x4ee
  testing.(*M).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1034 +0x2ee
  main.main()
      _testmain.go:94 +0x332
==================
==================
WARNING: DATA RACE
Read at 0x00c00007b0e0 by goroutine 10:
  runtime.mapiterinit()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/runtime/map.go:734 +0x0
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).loop()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:54 +0x31b
Previous write at 0x00c00007b0e0 by goroutine 8:
  runtime.mapassign_faststr()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/runtime/map_faststr.go:190 +0x0
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).AddMessage()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:88 +0x1f4
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:57 +0xd8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 10 (running) created at:
  github.com/CityOfZion/neo-go/pkg/peer/stall.NewDetector()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:42 +0x16c
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:53 +0x44
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 8 (running) created at:
  testing.(*T).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:878 +0x659
  testing.runTests.func1()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1119 +0xa8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
  testing.runTests()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1117 +0x4ee
  testing.(*M).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1034 +0x2ee
  main.main()
      _testmain.go:94 +0x332
==================
==================
WARNING: DATA RACE
Read at 0x00c0000e4a28 by goroutine 10:
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).loop()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:54 +0xd3
Previous write at 0x00c0000e4a28 by goroutine 8:
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).AddMessage()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:88 +0x212
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:57 +0xd8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 10 (running) created at:
  github.com/CityOfZion/neo-go/pkg/peer/stall.NewDetector()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:42 +0x16c
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:53 +0x44
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Goroutine 8 (running) created at:
  testing.(*T).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:878 +0x659
  testing.runTests.func1()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1119 +0xa8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
  testing.runTests()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1117 +0x4ee
  testing.(*M).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1034 +0x2ee
  main.main()
      _testmain.go:94 +0x332
==================
Deadline passed
==================
WARNING: DATA RACE
Read at 0x00c00007b0c8 by goroutine 8:
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:61 +0x108
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Previous write at 0x00c00007b0c8 by goroutine 10:
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).DeleteAll()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:109 +0x84
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*Detector).loop()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:65 +0x20e
Goroutine 8 (running) created at:
  testing.(*T).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:878 +0x659
  testing.runTests.func1()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1119 +0xa8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
  testing.runTests()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1117 +0x4ee
  testing.(*M).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1034 +0x2ee
  main.main()
      _testmain.go:94 +0x332
Goroutine 10 (finished) created at:
  github.com/CityOfZion/neo-go/pkg/peer/stall.NewDetector()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall.go:42 +0x16c
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:53 +0x44
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
==================
==================
WARNING: DATA RACE
Read at 0x00c00002ce40 by goroutine 8:
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:62 +0x16a
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
Previous write at 0x00c00002ce40 by goroutine 11:
  github.com/CityOfZion/neo-go/pkg/peer/stall.(*mockPeer).loop()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:46 +0x8d
Goroutine 8 (running) created at:
  testing.(*T).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:878 +0x659
  testing.runTests.func1()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1119 +0xa8
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162
  testing.runTests()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1117 +0x4ee
  testing.(*M).Run()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:1034 +0x2ee
  main.main()
      _testmain.go:94 +0x332
Goroutine 11 (finished) created at:
  github.com/CityOfZion/neo-go/pkg/peer/stall.TestDeadlineWorks()
      /home/travis/gopath/src/github.com/im-kulikov/neo-go/pkg/peer/stall/stall_test.go:55 +0xb5
  testing.tRunner()
      /home/travis/.gimme/versions/go1.11.5.linux.amd64/src/testing/testing.go:827 +0x162

NEO-GO version 2

Let's start a discussion on how to approach the fresh and optimized version of neo-go.

I know that @decentralisedkev has done some amazing job on some parts of the v2 yet. I will start factoring out the wire package into the master branch.

Neo testnet coins are suddenly gone 0 from 1000 , but we haven't transfered to any address

Hi,
As I applied for neo testnet coins on 18 Aug, and I got the assets from your side on 23 Aug.

From that day we have started the required integration.

On 5 Sept I have restarted the neo syncing by using this command

dotnet neo-cli.dll --rpc --log
On 7 Sept all testnet coins from my wallet are transferred to an external wallet address, but the issue is that we have not initiated any transaction from our side

I want to know the reason what is actually the problem with neo assets, can you please explain in details.

We are at the last stage of our exchange project.

RPC: Implement missing API endpoints

The basic setup for this is done. There's 1 method implemented (getconnectioncount). More could be implemented once the network and core package has more functionality.

Notes on Block decoding

Some observations on the block decoding process.

After copying the leveldb file from neo-python and using the block.go file to deserialise the raw file, I was immediately met with a attribute usage encoding error.

When done with the chain.acc file, the error appeared around block 1842913.

I have crosschecked the neo-python leveldb file and the raw format returned from an rpc call and neo-python returns a different result for the same block. In particular, the first 4/8 bytes have to be cut, and the ending bytes do not match, maybe around 32.

InvocationTX: DecodeBinary bug (Master branch)

The implementaion of the DecodeBinary method is not correct:
https://github.com/CityOfZion/neo-go/blob/master/pkg/core/transaction/invocation.go#L36

// DecodeBinary implements the Payload interface.
func (tx *InvocationTX) DecodeBinary(r io.Reader) error {
	lenScript := util.ReadVarUint(r)
	tx.Script = make([]byte, lenScript)
	if err := binary.Read(r, binary.LittleEndian, tx.Script); err != nil {
		return err
	}
	return binary.Read(r, binary.LittleEndian, &tx.Gas)
}

the equivalent C# looks as follow:
https://github.com/neo-project/neo/blob/master/neo/Network/P2P/Payloads/InvocationTransaction.cs#L24

protected override void DeserializeExclusiveData(BinaryReader reader)
        {
            if (Version > 1) throw new FormatException();
            Script = reader.ReadVarBytes(65536);
            if (Script.Length == 0) throw new FormatException();
            if (Version >= 1)
            {
                Gas = reader.ReadSerializable<Fixed8>();
                if (Gas < Fixed8.Zero) throw new FormatException();
            }
            else
            {
                Gas = Fixed8.Zero;
            }
        }

as we can see the golang implementation fails to include the Version logic.

For this raw transaction

raw_tx:= "d1001b00046e616d6567d3d8602814a429a91afdbaa3914884a1c90c733101201cc9c05cefffe6cdd7b182816a9152ec218d2ec000000141403387ef7940a5764259621e655b3c621a6aafd869a611ad64adcc364d8dd1edf84e00a7f8b11b630a377eaef02791d1c289d711c08b7ad04ff0d6c9caca22cfe6232103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac"
byteTx, err := hex.DecodeString(param); err != nil {
			err = errors.Wrapf(err, "unable to decode %s to []byte", param.StringVal)
			resultsErr = NewInvalidParamsError(err.Error(), err)
		} else {
			r := bytes.NewReader(byteTx)
			tx := &transaction.Transaction{}
			err = tx.DecodeBinary(r)
}

we expect tx to be:

{'txid': '0x1672df78b7dd21f3516fb0759518dfab29cbe106715504a59a3e12a359850397', 'size': 157, 'type': 'InvocationTransaction', 'version': 0, 'attributes': [{'usage': 32, 'data': '1cc9c05cefffe6cdd7b182816a9152ec218d2ec0'}], 'vout': [], 'vin': [], 'sys_fee': '0', 'net_fee': '0', 'scripts': [{'invocation': '403387ef7940a5764259621e655b3c621a6aafd869a611ad64adcc364d8dd1edf84e00a7f8b11b630a377eaef02791d1c289d711c08b7ad04ff0d6c9caca22cfe6', 'verification': '2103cbb45da6072c14761c9da545749d9cfd863f860c351066d16df480602a2024c6ac'}], 'script': '00046e616d6567d3d8602814a429a91afdbaa3914884a1c90c7331', 'gas': 0}

in particular gas = 0

Encrypt privkey bug in wallet.NEP2Encrypt?

When call wallet.NEP2Decrypt(key, passphrase string), return "password mismatch";
Is the reason:
encrypted, err := crypto.AESEncrypt(derivedKey2, xr) -> encrypted, err := crypto.AESEncrypt(xr, derivedKey2); because xr is the source, derivedKey2 is key?
Sorry for poor English.

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.