Skip to content
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
34 changes: 22 additions & 12 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/bench-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@dashevo/dapi-client": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/dpns-contract": "workspace:*",
"@dashevo/evo-sdk": "workspace:*",
"@dashevo/wallet-lib": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/dapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dependencies": {
"@dashevo/bls": "~1.2.9",
"@dashevo/dapi-grpc": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/dashd-rpc": "^19.1.0",
"@dashevo/grpc-common": "workspace:*",
"@dashevo/wasm-dpp": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/dash-spv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@dashevo/dark-gravity-wave": "^1.1.1",
"@dashevo/dash-util": "^2.0.3",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"levelup": "^4.4.0",
"memdown": "^5.1.0",
"wasm-x11-hash": "~0.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"dependencies": {
"@dashevo/bls": "~1.2.9",
"@dashevo/dapi-client": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/dashd-rpc": "^19.1.0",
"@dashevo/docker-compose": "^0.24.4",
"@dashevo/wallet-lib": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ function createDAPIAddressProviderFromOptions(options) {
if (options.seeds) {
let dapiAddressesWhiteList = options.dapiAddressesWhiteList || [];

// Since we don't have PoSe atm, 3rd party masternodes sometimes provide wrong data
// that breaks test suite and application logic. Temporary solution is to hardcode
// reliable DCG testnet masternodes to connect. Should be removed when PoSe is introduced.
// On testnet, connect only to the evonodes in networkConfigs.testnet.dapiAddressesWhiteList
// unless a whitelist is passed.
const network = networks.get(options.network);
let isRegtest = false;
if (network) {
Expand Down
69 changes: 44 additions & 25 deletions packages/js-dapi-client/lib/networkConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,53 @@ module.exports = {
'seed-1.pshenmic.dev:1443',
],
network: 'testnet',
// Since we don't have PoSe atm, 3rd party masternodes sometimes provide wrong data
// that breaks test suite and application logic. Temporary solution is to hardcode
// reliable DCG testnet masternodes to connect. Should be removed when PoSe is introduced.
// Snapshot of testnet evonodes that were enabled and passed the version check.
// Regenerate it when it goes stale: if none of these is in the masternode list,
// default discovery fails with NoAvailableAddressesError.
// Generate list with:
// curl https://quorums.testnet.networks.dash.org/masternodes | jq 'select(.success) | .data | map(select(.status=="ENABLED" and .versionCheck=="success") | .address | sub(":[0-9]+$"; ":1443")) | sort_by( split(":")[0] | split(".") | map(tonumber) )' // eslint-disable-line max-len
dapiAddressesWhiteList: [
'34.214.48.68:1443',
'35.82.197.197:1443',
'35.85.21.179:1443',
'35.163.144.230:1443',
'35.164.23.245:1443',
'35.167.145.149:1443',
'44.227.137.77:1443',
'44.228.242.181:1443',
'44.239.39.153:1443',
'44.240.98.102:1443',
'52.10.229.11:1443',
'52.12.176.90:1443',
'52.13.132.146:1443',
'52.24.124.162:1443',
'52.33.28.47:1443',
'52.34.144.50:1443',
'52.43.13.92:1443',
'52.43.86.231:1443',
'54.68.235.201:1443',
'54.149.33.167:1443',
'54.187.14.232:1443',
'54.201.32.131:1443',
'68.67.122.1:1443',
'68.67.122.2:1443',
'68.67.122.3:1443',
'68.67.122.4:1443',
'68.67.122.5:1443',
'68.67.122.6:1443',
'68.67.122.7:1443',
'68.67.122.8:1443',
'68.67.122.9:1443',
'68.67.122.10:1443',
'68.67.122.11:1443',
'68.67.122.12:1443',
'68.67.122.13:1443',
'68.67.122.14:1443',
'68.67.122.15:1443',
'68.67.122.16:1443',
'68.67.122.17:1443',
'68.67.122.18:1443',
'68.67.122.19:1443',
'68.67.122.20:1443',
'68.67.122.21:1443',
'68.67.122.22:1443',
'68.67.122.23:1443',
'68.67.122.24:1443',
'68.67.122.25:1443',
'68.67.122.26:1443',
'68.67.122.27:1443',
'68.67.122.28:1443',
'68.67.122.29:1443',
'85.209.243.1:1443',
'85.209.243.2:1443',
'85.209.243.3:1443',
'85.209.243.4:1443',
'85.209.243.5:1443',
'85.209.243.6:1443',
'85.209.243.7:1443',
'85.209.243.8:1443',
'85.209.243.9:1443',
'85.209.243.10:1443',
'87.229.22.126:1443',
'206.245.167.63:1443',
],
},
local: {
Expand Down
2 changes: 1 addition & 1 deletion packages/js-dapi-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@dashevo/dapi-grpc": "workspace:*",
"@dashevo/dash-spv": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/grpc-common": "workspace:*",
"@dashevo/wasm-dpp": "workspace:*",
"cbor": "^8.0.0",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
const EventEmitter = require('events');
const cbor = require('cbor');
const networks = require('@dashevo/dashcore-lib/lib/networks');
const SimplifiedMNList = require('@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNList');

const SimplifiedMasternodeListProvider = require('../../../lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider');
const SimplifiedMasternodeListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider');
const ListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/ListDAPIAddressProvider');

// The full masternode list diff a testnet DAPI node streamed for block 1,582,244, after
// Core V24 activated at block 1,578,000. Its coinbase is a version 4 CbTx, and 12 of its
// 399 entries are version 3 (ExtAddr) entries, which Core hashes with ExtNetInfo.
const coreV24DiffFixture = require('../../fixtures/coreV24TestnetMasternodeListDiff.json');

describe('SimplifiedMasternodeListProvider with a Core V24 masternode list', () => {
let diffBuffer;
let regtestWasEnabled;
let stream;
let createStream;
let smlProvider;

before(async () => {
// Synchronous cbor.encode silently truncates past its stream's buffer limit,
// and the diff is far larger
diffBuffer = await cbor.encodeAsync(coreV24DiffFixture);
});

beforeEach(function beforeEach() {
// dashcore-lib's regtest is its shared testnet object with regtest switched on, and
// looking up the 'local' or 'regtest' network switches it on for the whole process.
// These cases need testnet itself.
regtestWasEnabled = networks.testnet.regtestEnabled;
networks.disableRegtest();

stream = new EventEmitter();
stream.cancel = this.sinon.stub();
// The provider hands a diff it can't parse or apply to retryOnError. Turn that into
// a stream error, so the test fails with the provider's error instead of a timeout
// or an empty list.
stream.retryOnError = this.sinon.stub().callsFake((error) => stream.emit('error', error));

const response = {
getMasternodeListDiff_asU8: () => new Uint8Array(diffBuffer),
};

createStream = this.sinon.stub().callsFake(async () => {
// The provider subscribes to the stream after it resolves
setTimeout(() => stream.emit('data', response), 0);

return stream;
});

smlProvider = new SimplifiedMasternodeListProvider(createStream, {
network: 'testnet',
loggerOptions: {
identifier: 'test',
},
});
});

afterEach(() => {
if (regtestWasEnabled) {
networks.enableRegtest();
}
});

it('should rebuild the masternode list Core committed to in the coinbase', async () => {
const sml = await smlProvider.getSimplifiedMNList();

expect(sml).to.be.an.instanceOf(SimplifiedMNList);
expect(sml.blockHash).to.equal(coreV24DiffFixture.blockHash);
expect(sml.mnList).to.have.lengthOf(coreV24DiffFixture.mnList.length);
expect(sml.mnList.filter((entry) => entry.nVersion === 3)).to.not.be.empty();

const { extraPayload: cbTxPayload } = sml.cbTx;

expect(cbTxPayload.version).to.equal(4);
expect(sml.calculateMerkleRoot()).to.equal(cbTxPayload.merkleRootMNList);
expect(sml.calculateMerkleRootQuorums()).to.equal(cbTxPayload.merkleRootQuorums);
});

it('should offer every valid evonode at the Platform HTTPS address Core reports', async () => {
const listDAPIAddressProvider = new ListDAPIAddressProvider([], { network: 'testnet' });
const dapiAddressProvider = new SimplifiedMasternodeListDAPIAddressProvider(
smlProvider,
listDAPIAddressProvider,
[],
{ network: 'testnet' },
);
Comment on lines +82 to +89

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Make the V24 discovery test cover the whitelist and distinct Platform HTTPS endpoints

This test does not exercise the default discovery path it claims to cover. SimplifiedMasternodeListDAPIAddressProvider accepts only three constructor arguments, so the fourth { network: 'testnet' } argument is ignored, and the explicitly supplied empty whitelist disables filtering entirely. The fixture also gives valid V3 entries the same host for core_p2p and platform_https; the provider currently uses smlEntry.getIp() with platformHTTPPort, so the assertion can pass even if endpoint selection ignores a distinct platform_https host. Test through the factory or explicitly pass the refreshed whitelist, and add a fixture case with different Core P2P and Platform HTTPS hosts. If endpoint selection remains deferred, track that follow-up separately rather than relying on this test as coverage for it.

source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, architecture-layering)


await dapiAddressProvider.getLiveAddress();

const offeredAddresses = listDAPIAddressProvider.getAllAddresses()
.map((address) => `${address.getHost()}:${address.getPort()}`);

const platformHTTPSAddresses = coreV24DiffFixture.mnList
.filter((entry) => entry.nType === 1 && entry.isValid)
.map((entry) => entry.addresses.platform_https[0]);

expect(platformHTTPSAddresses).to.not.be.empty();
expect(offeredAddresses).to.have.members(platformHTTPSAddresses);
});
});
2 changes: 1 addition & 1 deletion packages/js-dash-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@dashevo/bls": "~1.2.9",
"@dashevo/dapi-client": "workspace:*",
"@dashevo/dapi-grpc": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/dashpay-contract": "workspace:*",
"@dashevo/dpns-contract": "workspace:*",
"@dashevo/grpc-common": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/platform-test-suite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"homepage": "https://github.com/dashevo/platform-test-suite#readme",
"dependencies": {
"@dashevo/dapi-client": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/dpns-contract": "workspace:*",
"@dashevo/evo-sdk": "workspace:*",
"@dashevo/grpc-common": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"homepage": "https://github.com/dashevo/wallet-lib#readme",
"dependencies": {
"@dashevo/dapi-client": "workspace:*",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/grpc-common": "workspace:*",
"@dashevo/wasm-dpp": "workspace:*",
"cbor": "^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm-dpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@babel/cli": "^7.26.4",
"@babel/core": "^7.26.10",
"@babel/preset-env": "^7.26.9",
"@dashevo/dashcore-lib": "~0.22.0",
"@dashevo/dashcore-lib": "~0.26.1",
"@dashevo/dpns-contract": "workspace:*",
"@types/bs58": "^4.0.1",
"@types/node": "^20.10.0",
Expand Down
Loading
Loading