Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read() not working with cx chains #38

Open
0pcom opened this issue Jun 5, 2021 · 1 comment
Open

read() not working with cx chains #38

0pcom opened this issue Jun 5, 2021 · 1 comment

Comments

@0pcom
Copy link

0pcom commented Jun 5, 2021

modification were made to the bc-counter example as follows:

package bc

var counter i32
var word str

func incCounter() {
	if counter > 1 {
		printf("previous input: %s\n", word)
	}
	printf("type anything:\n")
	word  = read()
	printf("\nyou typed: %s\n", word)
	counter++
	printf("Blockchain counter: %d\n", counter)
}

package main

func main() {

The local cx environment was set up / reset ; the chain was initialized against the modified example; cx-tracker, publisher, and peer were running. In the output, as you can see the first transaction incremented the counter to 1 and prompted for input which should have been read back but wasn't.

The second transaction caused error. When this was tested on the previous (original) implementation of cx-chains I believe the peer node would crash at this point, but it did not during the current test, so that is a step in the right direction. The run, as described above:

export CXCHAIN_GEN_SK=$(cxchain-cli key -in skycoin.genesis_keys.json -field "seckey")
 export CXCHAIN_HASH=$(cxchain-cli genesis -in skycoin.chain_spec.json)
 cxchain-cli run -chain "tracker:$CXCHAIN_HASH" -tracker "http://127.0.0.1:9091" -node "http://127.0.0.1:6422" -inject ./cx/examples/counter-tx.cx
[2021-06-04T18:31:28-05:00] INFO [cxchain-cli]: Memory flags. INIT_HEAP_SIZE=2097152 MAX_HEAP_FREE_RATIO=0.7 MAX_HEAP_SIZE=67108864 MIN_HEAP_FREE_RATIO=0.4 STACK_SIZE=1048576
[2021-06-04T18:31:28-05:00] INFO [cxchain-cli]: Parsing for CX args...
[2021-06-04T18:31:28-05:00] INFO [cxchain-cli]: Obtained CX sources. filenames=[./cx/examples/counter-tx]
[2021-06-04T18:31:28-05:00] INFO determineWorkDir [cxchain-cli]: work_dir="./cx/examples"
[2021-06-04T18:31:28-05:00] INFO [cxchain-cli]: Extracted main expression. len=7832
type anything:
test

you typed: 
Blockchain counter: 1
[2021-06-04T18:31:35-05:00] INFO [cxchain-cli]: CX transaction injected. inject_out="96ea81d320c910ca7de99f2dada606fe3113ba0039b07a78c66984b6ab533ad8"
[user@linux cx-chains]$  cxchain-cli run -chain "tracker:$CXCHAIN_HASH" -tracker "http://127.0.0.1:9091" -node "http://127.0.0.1:6422" -inject ./cx/examples/counter-tx.cx
[2021-06-04T18:31:42-05:00] INFO [cxchain-cli]: Memory flags. INIT_HEAP_SIZE=2097152 MAX_HEAP_FREE_RATIO=0.7 MAX_HEAP_SIZE=67108864 MIN_HEAP_FREE_RATIO=0.4 STACK_SIZE=1048576
[2021-06-04T18:31:42-05:00] INFO [cxchain-cli]: Parsing for CX args...
[2021-06-04T18:31:42-05:00] INFO [cxchain-cli]: Obtained CX sources. filenames=[./cx/examples/counter-tx]
[2021-06-04T18:31:45-05:00] INFO determineWorkDir [cxchain-cli]: work_dir="./cx/examples"
panic: runtime error: index out of range [1048694] with length 1048685

goroutine 1 [running]:
github.com/skycoin/cx/cx.Mark(...)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/pkg/mod/github.com/skycoin/[email protected]/cx/garbage_collector.go:236
github.com/skycoin/cx/cx.MarkObjectsTree(0xc00013a0e0, 0x100004, 0x3, 0xc00002cbb8, 0x0, 0x0)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/pkg/mod/github.com/skycoin/[email protected]/cx/garbage_collector.go:263 +0x332
github.com/skycoin/cx/cx.MarkAndCompact(0xc00013a0e0)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/pkg/mod/github.com/skycoin/[email protected]/cx/garbage_collector.go:25 +0x3be
main.BroadcastMainExp.func1(0xc0004fe000, 0x1e98, 0x1e99, 0xc0001ee060, 0xc00013a0e0, 0xc0000e2210, 0x22, 0xc00042a3f0)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/src/github.com/skycoin/cx-chains/cmd/cxchain-cli/helpers_cx_tx.go:139 +0x4c
main.BroadcastMainExp(0xc0000a2680, 0xed27af5be85078fe, 0x60defa9fa31b1853, 0x4c8a33af75cb58be, 0x46c15bc054cd1f25, 0xc00042a3f0, 0xc0000a2680, 0x82680dae5cca8800)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/src/github.com/skycoin/cx-chains/cmd/cxchain-cli/helpers_cx_tx.go:192 +0xb3
main.cmdRun(0xc0000200c0, 0x8, 0x8)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/src/github.com/skycoin/cx-chains/cmd/cxchain-cli/cmd_run.go:150 +0x4c5
github.com/skycoin/cx-chains/src/cx/cxutil.(*CommandMap).ParseAndRun(0xc000203ce0, 0xc0000200b0, 0x9, 0x9, 0xc000244a70)
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/src/github.com/skycoin/cx-chains/src/cx/cxutil/command.go:62 +0x344
main.main()
	/home/user/GITHUB/the-skycoin-project/AUR/cx-chains/src/go/src/github.com/skycoin/cx-chains/cmd/cxchain-cli/main.go:40 +0x6e6
@skyfleetdiy
Copy link

BUMP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants