Smart contracts won't deploy to a goQuorum blockchain - javascript

I installed goQuorum with quorum-wizard with 4 quorum nodes and 4 tessera nodes on IBFT. When I start the network with "./start.sh" I get
Starting Quorum network...
Waiting until all Tessera nodes are running...
Waiting until all Tessera nodes are running...
All Tessera nodes started
Starting Quorum nodes
Successfully started Quorum network.
--------------------------------------------------------------------------------
Tessera Node 1 public key:
BULeR8JyUWhiuuCMU/HLA0Q5pzkYT+cHII3ZKBey3Bo=
Tessera Node 2 public key:
QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=
Tessera Node 3 public key:
1iTZde/ndBHvzhcl7V68x44Vx7pl8nwx9LqnM/AfJUg=
Tessera Node 4 public key:
oNspPPgszVUFw0qmGFfWwh1uxVUXgvBxleXORHj07g8=
--------------------------------------------------------------------------------
when I run "nmap -p 21000-21100" I get
21000/tcp open irtrans
21001/tcp open unknown
21002/tcp open unknown
21003/tcp open unknown
This is my truffle-config.js
const HDWalletProvider = require("#truffle/hdwallet-provider");
const mnemonic = "not my real mn mon ic num phrase dum get l gg";
module.exports = {
networks: {
rinkeby: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/"+mnemonic);
},
network_id: '*',
timeoutBlocks: 100000,
networkCheckTimeout:2000000
},
quorum: {
provider: function() {
return new HDWalletProvider(mnemonic, "http://127.0.0.1:21000/", chainId=10);
},
network_id: '*',
type: 'quorum',
timeoutBlocks: 100000,
networkCheckTimeout:2000000
},
compilers: {
solc: {
version: "0.5.0",
settings: {
optimizer: {
enabled: true, // Default: false
runs: 1000 // Default: 200
},
evmVersion: "homestead" // Default: "byzantium"
}
}
}
};
When I cd in to the directory with the truffle-config.js and I run truffle deploy --reset --network quorum to compile my smart contracts I get the following error.
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
/root/dapp1/Dapp/node_modules/web3-core-helpers/src/errors.js:42
return new Error(message);
^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/root/dapp1/Dapp/node_modules/web3-core-helpers/src/errors.js:42:16)
at XMLHttpRequest.request.onreadystatechange (/root/dapp1/Dapp/node_modules/web3-providers-http/src/index.js:92:32)
at XMLHttpRequestEventTarget.dispatchEvent (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request-event-target.ts:44:13)
at XMLHttpRequest._setReadyState (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:219:8)
at XMLHttpRequest._onHttpRequestError (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:379:8)
at ClientRequest.<anonymous> (/root/dapp1/Dapp/node_modules/xhr2-cookies/xml-http-request.ts:266:37)
at ClientRequest.emit (events.js:315:20)
at Socket.socketOnEnd (_http_client.js:493:9)
at Socket.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at PollingBlockTracker._performSync (/root/dapp1/Dapp/node_modules/eth-block-tracker/src/polling.js:51:24)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
I can deploy the smart contracts to rinkeby test net within this environment but I can't get smart contracts to deploy to quorum
I am using
Node v14.16.1
Ubuntu 18.04 (64 Bit)
Quorum 21.1.0
Web3.js v1.3.5
Truffle v5.3.4 (core: 5.3.4)
solidity v0.5.0

I've not used truffle with HDWalletProvider, which I believe is from an older version of Truffle. I'm not certain that will set up the node connection.
We would normally set up the configuration like the following in the quorum: {} section:
host: "localhost",
port: 22001,
type: "quorum"
I would suggest using that and see if it works.
Take a look at the truffle docs for working with quorum: https://www.trufflesuite.com/docs/truffle/distributed-ledger-support/working-with-quorum

Did you change from the default ports in the quorum-wizard?
The default for the node 1 RPC is 22000, the 21000 range is for p2p networking.
I would set the host and port per Satpal's answer above, as in the hdwallet documentation here.

Related

Problems while deploying smart contract on Polygon mainnet

I'm trying to deploy a Smart Contract on Polygon mainnet but this happens when I run the migrate command using truffle
> Network name: 'matic'
> Network id: 137
> Block gas limit: 30176202 (0x1cc73ca)
1_initial_migration.js
======================
Deploying 'Animals'
-------------------
*** Deployment Failed ***
"Animals" -- transaction underpriced.
Exiting: Review successful transactions manually by checking the transaction hashes above on Etherscan.
Error: *** Deployment Failed ***
"Animals" -- transaction underpriced.
at /Users/nick/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:379:1
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration._deploy (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
at Migration._load (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:54:1)
at Migration.run (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1)
at Object.runMigrations (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/index.js:152:1)
at Object.runFrom (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/index.js:117:1)
at Object.runAll (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/index.js:121:1)
at Object.run (/Users/nick/node_modules/truffle/build/webpack:/packages/migrate/index.js:86:1)
at runMigrations (/Users/nick/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:78:1)
at Object.module.exports [as run] (/Users/nick/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
at Command.run (/Users/nick/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.5.1 (core: 5.5.1)
This is my truffle-config.js
matic: {
provider: () => new HDWalletProvider(mnemonic, `https://polygon-mainnet.g.alchemy.com/v2/key`),
network_id: 137,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
Does anyone know why is this happening?

Nodejs sequelize RangeError using mysql

I'm using sequelize in nodejs along with mysql. I'm trying to run the command npx sequelize db:create but it giving me this error. Not sure what to do here. Any help is appreciated. Thank you.
Sequelize CLI [Node: 14.17.4, CLI: 6.2.0, ORM: 6.6.2]
Loaded configuration file "src/config.js".
Using environment "development".
internal/buffer.js:83
throw new ERR_OUT_OF_RANGE(type || 'offset', RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range.
It must be >= 0 and <= 5. Received 9 at boundsError (internal/buffer.js:83:9)
at Buffer.readUInt32LE (internal/buffer.js:217:5)
at Packet.readInt32 (/root/sequelize-test/node_modules/mysql2/lib/packets/packet.js:103:24)
at Function.fromPacket (/root/sequelize-> > test/node_modules/mysql2/lib/packets/handshake.js:63:32)
at ClientHandshake.handshakeInit (/root/sequelize-test/node_modules/mysql2/lib/commands/client_handshake.js:93:40)
at ClientHandshake.execute (/root/sequelize-test/node_modules/mysql2/lib/commands/command.js:39:22)
at Connection.handlePacket (/root/sequelize-test/node_modules/mysql2/lib/connection.js:425:32)
at PacketParser.onPacket (/root/sequelize-test/node_modules/mysql2/lib/connection.js:75:12)
at PacketParser.executeStart (/root/sequelize-test/node_modules/mysql2/lib/packet_parser.js:75:16) at Socket. (/root/sequelize-test/node_modules/mysql2/lib/connection.js:82:25)
at Socket.emit (events.js:400:28) at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:265:9)
at Socket.Readable.push (internal/streams/readable.js:204:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) { code: 'ERR_OUT_OF_RANGE' }
my config of database
module.exports = {
development: {
username: 'root',
password: 'root123456',
database: 'test_run',
host: 'localhost',
port: 33060,
dialect: 'mysql',
timezone: '+06:00',
// dialectOptions: {
// bigNumberStrings: true,
// },
},
};
Make sure that you have globally installed MySQL2 using this command:
npm i -g mysql2
If the problem persists, try downgrading node version to 10.
Regards

error: MongoError: Authentication failed. I am using docker and mongoose

I try to connect to mongoDB through docker-compose but i get the same error over and over again although i tried all the solutions from the net. Thank you.
I have my docker-compose.yml as
# Use root/example as user/password credentials
version: '3.1'
services:
mongo:
image: mongo
restart: always
container_name: mongo
ports:
- 27017:27017
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
MONGO_INITDB_DATABASE: test
MONGO_USERNAME: admin
MONGO_PASSWORD: example
volumes:
- ./data:/data/db
- ./mongo-entrypoint.sh:/docker-entrypoint-initdb.d/mongo-init.sh:ro
command: mongod
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
And I have such a shell script
mongo -- "$MONGO_INITDB_DATABASE" <<EOF
db.createUser({
user: "$MONGO_USERNAME",
pwd: "$MONGO_PASSWORD",
roles: [
{ role: 'readWrite', db: "$MONGO_INITDB_DATABASE" }
]
})
EOF
And I try to connect to database by:
mongoose
.connect("mongodb://admin:example#localhost:27017/test")
.then(() => console.log("connected"))
.catch((e) => console.log("error:", e));
In Linux my friend can connect with the same code pieces but I am getting this error :
running on 3000
error: MongoError: Authentication failed.
at MessageStream.messageHandler (C:\Users\kamad\Desktop\3-2\cs308\proje\backend\node_modules\mongodb\lib\cmap\connection.js:268:20)
at MessageStream.emit (events.js:315:20)
at processIncomingData (C:\Users\kamad\Desktop\3-2\cs308\proje\backend\node_modules\mongodb\lib\cmap\message_stream.js:144:12)
at MessageStream._write (C:\Users\kamad\Desktop\3-2\cs308\proje\backend\node_modules\mongodb\lib\cmap\message_stream.js:42:5)
at writeOrBuffer (internal/streams/writable.js:358:12)
at MessageStream.Writable.write (internal/streams/writable.js:303:10)
at Socket.ondata (internal/streams/readable.js:719:22)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
ok: 0,
code: 18,
codeName: 'AuthenticationFailed'
}
I solved this just by changing the port from 27017 to 27018. Unfortunately, another app of mine was using that port.
There is my solved used :
docker-compose -f stack.yml up --build --force-recreate --renew-anon-volumes -d
stack.yml :
version: "3.5"
services:
mongo:
image: mongo:latest
container_name: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports:
- "0.0.0.0:27017:27017"
networks:
- MONGO
volumes:
- MONGO_DATA:/Users/lirui/docker/data/mongo/db
- MONGO_CONFIG:/Users/lirui/docker/data/mongo/configdb
mongo-express:
image: mongo-express:latest
container_name: mongo-express
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: admin
ME_CONFIG_MONGODB_SERVER: mongo
ME_CONFIG_MONGODB_PORT: "27017"
ports:
- "0.0.0.0:8088:8081"
networks:
- MONGO
depends_on:
- mongo
networks:
MONGO:
name: MONGO
volumes:
MONGO_DATA:
name: MONGO_DATA
MONGO_CONFIG:
name: MONGO_CONFIG
Replace path with your compute absolute path.
And DO NOT use 'root' to authentication.
use mongosh
shell script can use:
mongosh --port 27017 --authenticationDatabase -u "$MONGO_INITDB_ROOT_USERNAME" -p "$MONGO_INITDB_ROOT_PASSWORD" <<EOF
use admin
db.createUser({
user: process.env.MONGO_USERNAME ,
pwd: process.env.MONGO_PASSWORD ,
roles: [{
role: 'readWrite',
db: process.env.MONGO_INITDB_DATABASE }]
})
EOF

TypeError: Cannot read property '_alreadyWrapped' of undefined

I created a project that integrates the truffle and react frameworks,Then I configured rinkeby test network of Ethereum in truffle-config.js.But, when I migrate the contract to rinkeby network, something went wrong.
truffle compile
truffle migrate --network rinkeby
Then came some mistakes
TypeError: Cannot read property '_alreadyWrapped' of undefined
at Object.wrap (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\wrapper.js:13:1)
at Object.wrap (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\index.js:9:1)
at Object.create (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\provider\index.js:14:1)
at TruffleConfig.get [as provider] (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\configDefa
ults.js:189:1)
at Object.detect (C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\environment\environment.js:19:1)
at C:\Users\Lsy\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:192:1
Truffle v5.1.1 (core: 5.1.1)
Node v12.13.0
The Project directory is shown below:
truffle-config.js
const path = require("path");
const HDWalletProvider = require('#truffle/hdwallet-provider');
const fs = require('fs')
let secrets;
console.log(path.join(__dirname, "secrets.json"));
if (fs.existsSync(path.join(__dirname, "secrets.json"))){
secrets = JSON.parse(fs.readFileSync(path.join(__dirname, "secrets.json"),'utf8'));
}else{
console.log("secrets.json doesn't exist!")
}
module.exports = {
contracts_build_directory: path.join(__dirname, "client/src/contracts"),
networks: {
ganache:{
host:"127.0.0.1",
port:7545,
network_id:"*"
},
develop: {
port: 8545
},
rinkeby:{
provider:()=>{
new HDWalletProvider(secrets.mnemonic,"https://rinkeby.infura.io/v3/"+secrets.infuraProjectId);
},
network_id: '4'
}
}
};
This problem has been bothering me for a long time, who can help me! Really Thanks!
You forgot the return statement:
rinkeby: {
provider: () => {
return new HDWalletProvider(secrets.mnemonic,"https://rinkeby.infura.io/v3/"+secrets.infuraProjectId);
},
network_id: 4
}

Not able to lift sails in production mode.(sails lift --prod --verbose not working)

I wanted to lift my sails aap in production mode.when i run sails lift --prod --verbose, i am getting bunch of errors.
My local.js file looks like this.
/**
* Local environment settings
*
* While you're developing your app, this config file should include
* any settings specifically for your development computer (db passwords, etc.)
* When you're ready to deploy your app in production, you can use this file
* for configuration options on the server where it will be deployed.
*
*
* PLEASE NOTE:
* This file is included in your .gitignore, so if you're using git
* as a version control solution for your Sails app, keep in mind that
* this file won't be committed to your repository!
*
* Good news is, that means you can specify configuration for your local
* machine in this file without inadvertently committing personal information
* (like database passwords) to the repo. Plus, this prevents other members
* of your team from commiting their local configuration changes on top of yours.
*
*
* For more information, check out:
* http://sailsjs.org/#documentation
*/
var config={
development:{
connections: {
mongo: {
adapter: 'sails-mongo',
host: 'localhost',
user: '',
password: '',
database: 'mydata',
schema: true
}
},
mailer:{
hostUrl:'http://localhost:1337/',
emailConfirm:'confirm/',
inviteMoreFriends:'myspace'
},
geoSpatial:{
radiusOfEarth:6375,
radius:3,
maxRecords:20
},
facebook:{
clientID: "CLIENT ID",
clientSecret: "SECRET",
callbackURL: "http://www.EXAMPLE.com:1337/auth/facebook/callback"
}
}
}
module.exports = {
// The `port` setting determines which TCP port your app will be deployed on
// Ports are a transport-layer concept designed to allow many different
// networking applications run at the same time on a single computer.
// More about ports: http://en.wikipedia.org/wiki/Port_(computer_networking)
//
// By default, if it's set, Sails uses the `PORT` environment variable.
// Otherwise it falls back to port 1337.
//
// In production, you'll probably want to change this setting
// to 80 (http://) or 443 (https://) if you have an SSL certificate
port: process.env.PORT || 1337,
// The runtime "environment" of your Sails app is either 'development' or 'production'.
//
// In development, your Sails app will go out of its way to help you
// (for instance you will receive more descriptive error and debugging output)
//
// In production, Sails configures itself (and its dependencies) to optimize performance.
// You should always put your app in production mode before you deploy it to a server-
// This helps ensure that your Sails app remains stable, performant, and scalable.
//
// By default, Sails sets its environment using the `NODE_ENV` environment variable.
// If NODE_ENV is not set, Sails will run in the 'development' environment.
environment: process.env.NODE_ENV || 'development',
development: {
//config is placed as the attributes needed by aws config node module
aws: {
region: 'REGION',
accessKeyId: 'KEY ID',
secretAccessKey: 'SECRET',
cloudFrontCDN: 'EXAMPLE.cloudfront.net'
},
s3: {
Bucket: 'MY_BUCKET',
endpoint: 'ENDPOINT',
imageUrl: 'URL'
},
uploads: {
thumbnails: __dirname + '/../uploads/thumbnails/'
}
},
likeprod: {
//config is placed as the attributes needed by aws config node module
aws: {
region: 'REGION',
accessKeyId: 'KEY ID',
secretAccessKey: 'SECRET',
cloudFrontCDN: 'EXAMPLE.cloudfront.net'
},
s3: {
Bucket: 'MY_BUCKET',
endpoint: 'ENDPOINT',
imageUrl: 'URL'
},
uploads: {
thumbnails: __dirname + '/../uploads/thumbnails/'
}
},
mandrillApiKey:"API_KEY",
twilio:{
accountSid:'SECRET',
authToken:'TOKEN'
},
metaPublic:{
groupBookNumber:'+0123456789'
},
connections:config[process.env.NODE_ENV].connections,
mailer:config[process.env.NODE_ENV].mailer,
geoSpatial:config[process.env.NODE_ENV].geoSpatial,
facebook:config[process.env.NODE_ENV].facebook,
//TODO: refactor the config[environment] as for connections
current: function () {
return sails.config[sails.config.environment]
}
};
when i run sails lift --prod. I am getting this error.
$ sails lift --prod --verbose
info: Starting app...
verbose: Please run `npm install coffee-script` to use coffescript (skipping for now)
verbose: Setting Node environment...
verbose: moduleloader hook loaded successfully.
verbose: Loading app config...
/home/vgulp/Desktop/config/local.js:136
connections:config[process.env.NODE_ENV].connections,
^
TypeError: Cannot read property 'connections' of undefined
at Object.<anonymous> (/home/Desktop/vka/config/local.js:136:45)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /home/Desktop/vka/node_modules/sails/node_modules/include-all/index.js:129:29
at Array.forEach (native)
at requireAll (/home/Desktop/vka/node_modules/sails/node_modules/include-all/index.js:44:9)
at buildDictionary (/home/Desktop/vka/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14)
at Function.module.exports.aggregate (/home/Desktop/vka/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles [as 0] (/home/Desktop/vka/node_modules/sails/lib/hooks/moduleloader/index.js:102:22)
at /home/Desktop/vka/node_modules/sails/node_modules/async/lib/async.js:459:38
at Array.forEach (native)
at _each (/home/Desktop/vka/node_modules/sails/node_modules/async/lib/async.js:32:24)
at Object.async.auto (/home/Desktop/vka/node_modules/sails/node_modules/async/lib/async.js:430:9)
Can anyone suggest a solution.
[ Edited: the following answer was based on the original question which was completely changed by the author ]
Your sails app need to lift in production mode or you need to specify the port to be used in your config files.
Production mode runs your express server on port 80.
Is your AWS instance setup to lift the app in production mode?
http://sailsjs.org/documentation/anatomy/my-app/config/env/production-js
You don 't have connection specified for production in local.js (As you are running from your Desktop)
As the error rightly says,
connections:config[process.env.NODE_ENV].connections,
^
TypeError: Cannot read property 'connections' of undefined
process.env.NODE_ENV is production when running in --prod
var config = {
development: {
connections: {
mongo: {
adapter: 'sails-mongo',
host: 'localhost',
user: '',
password: '',
database: 'mydata',
schema: true
}
},
mailer: {
hostUrl: 'http://localhost:1337/',
emailConfirm: 'confirm/',
inviteMoreFriends: 'myspace'
},
geoSpatial: {
radiusOfEarth: 6375,
radius: 3,
maxRecords: 20
},
facebook: {
clientID: "CLIENT ID",
clientSecret: "SECRET",
callbackURL: "http://www.EXAMPLE.com:1337/auth/facebook/callback"
}
},
production: {
connections: {
mongo: {
adapter: 'sails-mongo',
host: 'localhost',
user: '',
password: '',
database: 'mydata',
schema: true
}
},
mailer: {
hostUrl: 'http://localhost:1337/',
emailConfirm: 'confirm/',
inviteMoreFriends: 'myspace'
},
geoSpatial: {
radiusOfEarth: 6375,
radius: 3,
maxRecords: 20
},
facebook: {
clientID: "CLIENT ID",
clientSecret: "SECRET",
callbackURL: "http://www.EXAMPLE.com:1337/auth/facebook/callback"
}
}
}

Categories