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

Update node to v18 #248

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: 'npm'

- name: Generate .env file
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.0
15,969 changes: 8,618 additions & 7,351 deletions package-lock.json

Large diffs are not rendered by default.

39 changes: 18 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,23 @@
"!*/__tests__"
],
"dependencies": {
"@loopback/boot": "^3.1.2",
"@loopback/core": "^2.13.1",
"@loopback/repository": "^3.3.0",
"@loopback/rest": "^9.1.1",
"@loopback/rest-explorer": "^5.0.9",
"@loopback/service-proxy": "^3.0.5",
"@loopback/boot": "^6.1.3",
"@loopback/core": "^5.1.3",
"@loopback/repository": "^6.1.3",
"@loopback/rest": "^13.1.3",
"@loopback/rest-explorer": "^6.1.3",
"@loopback/service-proxy": "^6.1.3",
"@rsksmart/bridge-state-data-parser": "git+https://github.com/rsksmart/bridge-state-data-parser.git#allow-block-argument",
"@rsksmart/rsk-precompiled-abis": "git+https://github.com/rsksmart/precompiled-abis.git#5.0.0-FINGERROOT",
"@types/mongoose": "^5.11.97",
"big.js": "^6.1.1",
"bitcoinjs-lib": "^6.0.1",
"bridge-transaction-parser": "git+https://github.com/rsksmart/bridge-transaction-parser.git#v0.5.0-beta",
"dotenv": "^8.6.0",
"jssha": "^3.2.0",
"log4js": "^6.6.1",
"loopback-connector-kv-redis": "^3.0.3",
"loopback-connector-mongodb": "^5.5.0",
"loopback-connector-redis": "^3.0.0",
"loopback-connector-rest": "^3.7.0",
"mongoose": "^5.13.16",
"loopback-connector-kv-redis": "^4.0.0",
"loopback-connector-rest": "^4.0.3",
"mongoose": "^7.5.3",
"pegin-address-verificator": "https://[email protected]/rsksmart/pegin-address-verifier#0.3.0",
"pegin-cap-evaluator": "https://[email protected]/rsksmart/pegin-cap-evaluator#1.0.0",
"tslib": "^2.0.0",
Expand All @@ -81,20 +78,20 @@
"web3-utils": "^1.3.4"
},
"devDependencies": {
"@loopback/build": "^6.2.8",
"@loopback/eslint-config": "^10.0.4",
"@loopback/testlab": "^3.2.10",
"@loopback/build": "^10.1.3",
"@loopback/eslint-config": "^14.0.4",
"@loopback/testlab": "^6.1.3",
"@types/big.js": "^6.1.2",
"@types/bs58": "^4.0.1",
"@types/node": "^10.17.48",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"eslint": "^8.19.0",
"@types/node": "^16.18.50",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"eslint": "^8.48.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"sinon": "^11.1.2",
"sonarqube-scanner": "^3.0.1",
"source-map-support": "^0.5.19",
"typescript": "~4.1.2"
"source-map-support": "^0.5.21",
"typescript": "~5.2.2"
}
}
2 changes: 1 addition & 1 deletion src/__tests__/unit/services/rsk-chain-sync.service.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ describe('Service: RskChainSyncService', () => {

// RSK is contacted with these blocks (latest and 3 to 5)
sinon.assert.callCount(mockedRskNodeService.getBlock, 4);
sinon.assert.calledWithExactly(mockedRskNodeService.getBlock, 'latest', false);
sinon.assert.calledWithExactly(mockedRskNodeService.getBlock, 'latest');
sinon.assert.calledWithExactly(mockedRskNodeService.getBlock, 3);
sinon.assert.calledWithExactly(mockedRskNodeService.getBlock, 4);
sinon.assert.calledWithExactly(mockedRskNodeService.getBlock, 5);
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/unit/services/rsk-node.services.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const getInitialBlock = () => new RskBlock(2863627, '0xba5e', '0x');
describe('Service: RskNodeService', () => {
it('Searches the block using initial block conf', async () => {
const thisService = new RskNodeService();
const block = await thisService.getBlock(getInitialBlock().height, false);
const block = await thisService.getBlock(getInitialBlock().height);
sinon.assert.match(block.number, getInitialBlock().height);
});
it('Verify ${process.env.RSK_NODE_HOST} configuration', async () => {
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('Service: RskNodeService', () => {
});
it('Searches the block', async () => {
const thisService = new RskNodeService();
const block = await thisService.getBlock(getInitialBlock().height, false);
const block = await thisService.getBlock(getInitialBlock().height);
expect(block).to.not.be.null;
});
it('Searches the block number', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/unit/tx-fee.controller.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe('tx Fee controller', () => {
}))).to.be.true();
});
it('Should ensure the change output has a higher value than dust environment variable ', async () => {
const dustValue = process.env.BURN_DUST_VALUE ?? 2000;
const dustValue = Number(process.env.BURN_DUST_VALUE) || 2000;
const minFastFee = new SatoshiBig(process.env.FEE_PER_KB_FAST_MIN ?? 100, 'satoshi');
const minAverageFee = new SatoshiBig(process.env.FEE_PER_KB_AVERAGE_MIN ?? 100, 'satoshi');
const minSlowFee = new SatoshiBig(process.env.FEE_PER_KB_SLOW_MIN ?? 100, 'satoshi');
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/mongodb.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class MongoDbDataSource {
}

connect(): Promise<void> {
return connectToMongo(this.mongoDbUri, {useUnifiedTopology: true})
return connectToMongo(this.mongoDbUri)
.then(
(connection: Mongoose) => {
this.mongoose = connection;
Expand Down
13 changes: 5 additions & 8 deletions src/services/mongodb-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ export abstract class MongoDbDataService<Type extends SearchableModel, T> implem
const connector = this.getConnector();
const filter: any = {};
filter[data.getIdFieldName()] = data.getId();
connector.findOneAndUpdate(filter, <any>data, {upsert: true}, (err: any) => {
metricLogger();
if (err) {
connector.findOneAndUpdate(filter, <any>data, {upsert: true})
.then(() => resolve(true))
.catch((err) => {
this.logger.debug('There was an error trying to save data', err);
reject(err);
} else {
resolve(true);
}
})
})
.finally(metricLogger);
});
}

Expand All @@ -92,5 +90,4 @@ export abstract class MongoDbDataService<Type extends SearchableModel, T> implem
this.logger.debug('Service stopped');
return Promise.resolve();
}

}
2 changes: 1 addition & 1 deletion src/services/rsk-chain-sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class RskChainSyncService {

public async sync(): Promise<void> {
let dbBestBlock = await this.getSyncStatus();
const rskBestBlock = RskBlock.fromWeb3Block(await this.rskNodeService.getBlock('latest', false));
const rskBestBlock = RskBlock.fromWeb3Block(await this.rskNodeService.getBlock('latest'));
// In case the db is synced with a forked chain and that forked chain is longer than the main chain,
// remove all extra forked blocks from the db + 1 as an offset so the following logic handles it appropriately.
if(rskBestBlock.height < dbBestBlock.rskBlockHeight) {
Expand Down
4 changes: 2 additions & 2 deletions src/services/rsk-node.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export class RskNodeService {
constructor() {
this.web3 = new Web3(`${process.env.RSK_NODE_HOST}`);
}
getBlock(block: string | number, withTransactions = true): Promise<BlockTransactionObject> {
return this.web3.eth.getBlock(block, withTransactions);
getBlock(block: string | number): Promise<BlockTransactionObject> {
return this.web3.eth.getBlock(block, true);
}
getTransactionReceipt(txHash: string): Promise<any> {
return this.web3.eth.getTransactionReceipt(txHash);
Expand Down