Skip to content

Commit

Permalink
preparing mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
harpagon210 committed Jan 13, 2020
1 parent 6ccdcb6 commit 4f5a101
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 42 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contracts/bootstrap/*.js
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const blockchain = require('./plugins/Blockchain');
const jsonRPCServer = require('./plugins/JsonRPCServer');
const streamer = require('./plugins/Streamer');
const replay = require('./plugins/Replay');
const p2p = require('./plugins/P2P');
// const p2p = require('./plugins/P2P');

const conf = require('./config');

Expand Down Expand Up @@ -134,7 +134,7 @@ const start = async () => {
if (res && res.payload === null) {
res = await loadPlugin(streamer);
if (res && res.payload === null) {
res = await loadPlugin(p2p);
// res = await loadPlugin(p2p);
if (res && res.payload === null) {
res = await loadPlugin(jsonRPCServer);
}
Expand All @@ -144,7 +144,7 @@ const start = async () => {

const stop = async () => {
await unloadPlugin(jsonRPCServer);
await unloadPlugin(p2p);
// await unloadPlugin(p2p);
// get the last Steem block parsed
let res = null;
const streamerPlugin = getPlugin(streamer);
Expand Down
8 changes: 4 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"chainId": "testnet1",
"chainId": "mainnet1",
"rpcNodePort": 5000,
"p2pPort": 5001,
"databaseURL": "mongodb://localhost:27017",
"databaseName": "ssctestnet1",
"databaseName": "ssc",
"blocksLogFilePath": "./blocks.log",
"javascriptVMTimeout": 10000,
"streamNodes": [
Expand All @@ -12,7 +12,7 @@
],
"steemAddressPrefix": "STM",
"steemChainId": "0000000000000000000000000000000000000000000000000000000000000000",
"startSteemBlock": 38287457,
"startSteemBlock": 29862600,
"genesisSteemBlock": 29862600,
"witnessEnabled": true
"witnessEnabled": false
}
2 changes: 0 additions & 2 deletions contracts/bootstrap/dice.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

/* eslint-disable */
const STEEM_PEGGED_SYMBOL = 'STEEMP';
const CONTRACT_NAME = 'dice';

Expand Down
1 change: 0 additions & 1 deletion contracts/bootstrap/market.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
const STEEM_PEGGED_SYMBOL = 'STEEMP';
const CONTRACT_NAME = 'market';

Expand Down
1 change: 0 additions & 1 deletion contracts/bootstrap/sscstore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
actions.createSSC = async (payload) => {
await api.db.createTable('params');
const params = {};
Expand Down
1 change: 0 additions & 1 deletion contracts/bootstrap/steempegged.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
actions.createSSC = async (payload) => {
await api.db.createTable('withdrawals');
};
Expand Down
2 changes: 0 additions & 2 deletions contracts/bootstrap/tokens.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable */

//const actions = {}
//const api = {}

Expand Down
23 changes: 16 additions & 7 deletions libs/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class Block {
return SHA256(
this.previousHash
+ this.previousDatabaseHash
+ this.databaseHash
+ this.merkleRoot
+ this.blockNumber.toString()
+ this.refSteemBlockNumber.toString()
+ this.refSteemBlockId
Expand Down Expand Up @@ -101,17 +99,28 @@ class Block {
}

if (this.refSteemBlockNumber >= 37899120) {
virtualTransactions.push(new Transaction(0, '', 'null', 'witnesses', 'scheduleWitnesses', ''));
// virtualTransactions
// .push(new Transaction(0, '', 'null', 'witnesses', 'scheduleWitnesses', ''));
}

if (this.refSteemBlockNumber >= 37899120) {
const nftContract = await database.findContract({ name: 'nft' });

if (nftContract !== null) {
virtualTransactions.push(new Transaction(0, '', 'null', 'nft', 'checkPendingUndelegations', ''));
}
}


/*
if (this.refSteemBlockNumber >= 38145385) {
// issue new utility tokens every time the refSteemBlockNumber % 1200 equals 0
if (this.refSteemBlockNumber % 1200 === 0) {
virtualTransactions.push(new Transaction(0, '', 'null', 'inflation', 'issueNewTokens', '{ "isSignedWithActiveKey": true }'));
virtualTransactions
.push(new Transaction(0, '', 'null', 'inflation', 'issueNewTokens', '{
"isSignedWithActiveKey": true }'));
}

virtualTransactions.push(new Transaction(0, '', 'null', 'nft', 'checkPendingUndelegations', ''));
}
} */

const nbVirtualTransactions = virtualTransactions.length;
for (let i = 0; i < nbVirtualTransactions; i += 1) {
Expand Down
4 changes: 2 additions & 2 deletions libs/Constants.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
const CONSTANTS = {

// mainnet
/*
UTILITY_TOKEN_SYMBOL: 'ENG',
STEEM_PEGGED_ACCOUNT: 'steem-peg',
INITIAL_TOKEN_CREATION_FEE: '100',
SSC_STORE_QTY: '0.001',
*/
// testnet

/*
UTILITY_TOKEN_SYMBOL: 'SSC',
STEEM_PEGGED_ACCOUNT: 'steemsc',
INITIAL_TOKEN_CREATION_FEE: '0',
SSC_STORE_QTY: '1',
*/

UTILITY_TOKEN_PRECISION: 8,
UTILITY_TOKEN_MIN_VALUE: '0.00000001',
Expand Down
8 changes: 4 additions & 4 deletions libs/SmartContracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class SmartContracts {
RegExp.prototype.constructor = function () { };
RegExp.prototype.exec = function () { };
RegExp.prototype.test = function () { };
let actions = {};
###ACTIONS###
const execute = async function () {
try {
if (api.action && typeof api.action === 'string' && typeof actions[api.action] === 'function') {
Expand All @@ -77,7 +77,7 @@ class SmartContracts {
done(error);
}
}
execute();
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "steemsmartcontracts",
"version": "0.1.10",
"version": "0.1.11",
"description": "",
"main": "app.js",
"scripts": {
"start": "node --max-old-space-size=8192 app.js",
"lint": "eslint --ignore-path .gitignore .",
"lint": "eslint .gitignore .",
"test": "./node_modules/mocha/bin/mocha --recursive"
},
"keywords": [],
Expand Down
20 changes: 9 additions & 11 deletions plugins/P2P.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ const errorHandler = async (id, error) => {

if (error.code === 'ECONNREFUSED') {
if (sockets[id]) {
console.log(`closed connection with peer ${sockets[id].witness.account}`);
console.log(`closed connection with peer ${sockets[id].witness.account}/ ${sockets[id]} / ${id}`);
delete sockets[id];
}
}
};

const disconnectHandler = async (id, reason) => {
if (sockets[id]) {
console.log(`closed connection with peer ${sockets[id].witness.account}`, reason);
console.log(`closed connection with peer ${sockets[id].witness.account} / ${sockets[id]} / ${id}`, reason);
delete sockets[id];
}
};
Expand Down Expand Up @@ -255,10 +255,10 @@ const proposeRoundHandler = async (id, data, cb) => {
if (signature && typeof signature === 'string'
&& round && Number.isInteger(round)
&& roundHash && typeof roundHash === 'string' && roundHash.length === 64) {
// check if the witness is the one scheduled for this block
const schedule = await findOne('witnesses', 'schedules', { round, witness: witnessSocket.witness.account });
// get the current round info
const params = await findOne('witnesses', 'params', {});

if (schedule !== null) {
if (params.round === round && params.currentWitness === witnessSocket.witness.account) {
// get witness signing key
const witness = await findOne('witnesses', 'witnesses', { account: witnessSocket.witness.account });

Expand All @@ -267,9 +267,6 @@ const proposeRoundHandler = async (id, data, cb) => {

// check if the signature is valid
if (checkSignature(roundHash, signature, signingKey, true)) {
// get the current round info
const params = await findOne('witnesses', 'params', {});

if (currentRound < params.round) {
// eslint-disable-next-line prefer-destructuring
currentRound = params.round;
Expand Down Expand Up @@ -467,11 +464,9 @@ const connectToWitness = (witness) => {
signingKey,
} = witness;

const socket = ioclient.connect(`http://${IP}:${P2PPort}`);

const id = `${IP}:${P2PPort}`;
sockets[id] = {
socket,
socket: null,
address: IP,
witness: {
account,
Expand All @@ -480,6 +475,9 @@ const connectToWitness = (witness) => {
authenticated: false,
};

const socket = ioclient.connect(`http://${IP}:${P2PPort}`);
sockets[id].socket = socket;

socket.on('disconnect', reason => disconnectHandler(id, reason));
socket.on('error', error => errorHandler(id, error));
socket.on('handshake', (payload, cb) => handshakeHandler(id, payload, cb));
Expand Down
4 changes: 3 additions & 1 deletion test/steemsmartcontracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ describe('Database', function () {
assert.equal(genesisBlock.databaseHash, 'a3daa72622eb02abd0b1614943f45500633dc10789477e8ee538a8398e61f976');
assert.equal(genesisBlock.merkleRoot, '5264617bda99adc846ec4100f0f3ecaf843e3d9122d628a5d096a1230b970e9f');
} else {
assert.equal(true, false);
assert.equal(genesisBlock.hash, 'c1dee96a6b7a0cc9408ccb407ab641f444c26f6859ba33b9c9ba2c0a368d20b2');
assert.equal(genesisBlock.databaseHash, 'a3daa72622eb02abd0b1614943f45500633dc10789477e8ee538a8398e61f976');
assert.equal(genesisBlock.merkleRoot, '7048315fc8861b98fe1b2a82b86a24f80aa6e6dd225223e39771807532f5fb21');
}

resolve();
Expand Down
2 changes: 1 addition & 1 deletion test/witnesses.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ let witnessesContractPayload = {
code: base64ContractCode,
};

describe('witnesses', function () {
describe.skip('witnesses', function () {
this.timeout(60000);

before((done) => {
Expand Down

0 comments on commit 4f5a101

Please sign in to comment.