[BUG] Contracts calling Chain.create function fail at deployment on local-node
Closed this issue · 1 comments
bogdan-manole commented
Describe the bug
When I try to deploy any contract which includes Chain.create
calls, deployment fails with Internal server error
To Reproduce
Steps to reproduce the behavior:
- initiate a new project
- replace source code from contract/ExampleContract.aes with:
@compiler >= 6
contract Some_Other_Child_Contract =
entrypoint sayHi() =
"hello"
contract Identity =
record state = {name: string, surname: string, idNumber: string}
entrypoint init(name: string, surname: string, idNumber: string) =
{name = name, surname = surname, idNumber = idNumber }
entrypoint getIdentity() = state
main contract IdentityServiceCreate =
type state = list(Identity)
entrypoint init() = []
stateful entrypoint createNewIdentity(name: string, surname: string, idNumber: string) =
let identity = Chain.create(name, surname, idNumber) : Identity
/*let identity = abort("placeholder Chain.create(name, surname, idNumber)") : Identity*/
put(identity :: state)
identity
- go to test/exampleTest.js and let only the deployment test (57-59) and comment the rest of it (61-88). you should remain with only this one
it('Should deploy ExampleContract', async () => {
await contract.deploy([]);
});
- execute
npm test
- you will get Internal Error
- now, in
ExampleContract.aes
if you comment line 20 and uncomment line 21, like this:
/*let identity = Chain.create(name, surname, idNumber) : Identity*/
let identity = abort("placeholder for Chain.create(name, surname, idNumber)") : Identity
- and run again
npm test
we will se the deployment succeeds
Expected behavior
The contract should be deployed successfully
Extra information
the full server error looks like this:
Error: Internal Server Error
at http (/Users/horus/aeternity/dex/node_modules/swagger-client/lib/http.js:98:19)
at processTicksAndRejections (node:internal/process/task_queues:94:5) {
status: 500,
statusCode: 500,
responseError: SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at Object.responseInterceptor (/Users/horus/aeternity/dex/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:181619)
at http (/Users/horus/aeternity/dex/node_modules/swagger-client/lib/http.js:89:28)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
}
node:internal/process/promises:227
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Internal Server Error
at http (/Users/horus/aeternity/dex/node_modules/swagger-client/lib/http.js:98:19)
at processTicksAndRejections (node:internal/process/task_queues:94:5) {
status: 500,
statusCode: 500,
responseError: SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)
at Object.responseInterceptor (/Users/horus/aeternity/dex/node_modules/@aeternity/aepp-sdk/dist/aepp-sdk.js:1:181619)
at http (/Users/horus/aeternity/dex/node_modules/swagger-client/lib/http.js:89:28)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
}
Aeproject information (please complete the following information):
- OS executed at: macos 11.2.3 and Pop!_OS 20.04 (Linux pop-os 5.8.0-7630-generic)
- AEproject Version 3.0.5
marc0olo commented
@bogdan-manole the v6.0.0
of the compiler is responsible for that error as it cannot handle the code. I didn't remember that problem.
as workaround you can start the compiler using aeproject compiler --v v6.0.2
. when using the latest compiler version the contract can be deployed as expected:
marc0olo@DESKTOP-B1QLEDL:~/git/aeternity/test-aeproject$ npm run test
> aeproject-project@1.0.0 test
> mocha ./test/**/*.js --timeout 0 --exit
ExampleContract
Creating filesystem by checking includes for: ./contracts/ExampleContract.aes
✔ Should deploy ExampleContract (158ms)
1 passing (537ms)