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

feat: bootnode mode #97

Merged
merged 5 commits into from
Jan 17, 2024
Merged

Conversation

LinXJ1204
Copy link
Contributor

@LinXJ1204 LinXJ1204 commented Jan 10, 2024

PULL REQUEST

Before

說明 (Description)

相關問題 (Linked Issues)

貢獻種類 (Type of change)

  • Bug fix (除錯 non-breaking change which fixes an issue)
  • New feature (增加新功能 non-breaking change which adds functionality)
  • Breaking change (可能導致相容性問題 fix or feature that would cause existing functionality to not work as expected)
  • Doc change (需要更新文件 this change requires a documentation update)

測試環境 (Test Configuration):

  • OS: macOS 13.2.1
  • NodeJS Version: 9.8.1
  • NPM Version: 18.18.2
  • Docker Version: 24.0.6

檢查清單 (Checklist):

  • 我的程式碼遵從此專案的規範 (My code follows the style guidelines of this project)
  • 我有對於自己的程式碼進行測試檢查 (I have performed a self-review of my own code)
  • 我有在程式碼中提供必要的註解 (I have commented my code, particularly in hard-to-understand areas)
  • 我有在文件中進行必要的更動 (I have made corresponding changes to the documentation)
  • 我的程式碼更動沒有顯著增加錯誤數量 (My changes generate no new warnings)
  • 我有新增必要的單元測試 (I have added tests that prove my fix is effective or that my feature works)
  • 我有檢查並更正程式碼錯誤的拼字 (I have checked my code and corrected any misspellings)

我已完成以上清單,並且同意遵守 Code of Conduct

I have completed the checklist and agree to abide by the code of conduct.

  • 同意 (I consent)

@kidneyweakx kidneyweakx changed the title Feat/bootnode mode feat: bootnode mode Jan 10, 2024
@LinXJ1204 LinXJ1204 closed this Jan 10, 2024
@LinXJ1204 LinXJ1204 reopened this Jan 10, 2024
@kidneyweakx
Copy link
Collaborator

List Test Configuration like this:

* OS: macOS 14.2.1
* NodeJS Version: 9.8.1
* NPM Version: 18.18.2
* Docker Version: 24.0.6

@@ -20,7 +20,7 @@ class ValidatorDockerComposeYaml extends DockerComposeYaml {
volumes: [`${bdkPath}/validator${validatorNum}/data/:/data`],
entrypoint: [
'/bin/sh', '-c',
`geth init --datadir /data /data/genesis.json; geth --datadir /data --networkid ${chainId} --nodiscover --verbosity 3 --syncmode full --nousb --mine --miner.threads 1 --miner.gasprice 0 --emitcheckpoints --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --http.vhosts "*" --ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.origins "*" --http.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul,qbft --ws.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul,qbft --port ${peerPort} `,
`geth init --datadir /data /data/genesis.json; geth --datadir /data --networkid ${chainId} --verbosity 3 --syncmode full --nousb --mine --miner.threads 1 --miner.gasprice 0 --emitcheckpoints --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" ${(bootnode) ? '--bootnodes '.concat(nodeEncode) : ''} --http.vhosts "*" --ws --ws.addr 0.0.0.0 --ws.port 8546 --ws.origins "*" --http.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul,qbft --ws.api admin,trace,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,istanbul,qbft --port ${peerPort} `,
Copy link
Collaborator

Choose a reason for hiding this comment

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

after delete nodiscover, is it still comply with static node standard?

and we should make this entrypoint more beautiful

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

@kidneyweakx kidneyweakx Jan 12, 2024

Choose a reason for hiding this comment

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

${(bootnode) ? '--bootnodes '.concat(nodeEncode) : '--nodiscover'}

Comment on lines 123 to 125
Object.values(isbootNodeList).forEach((item: any) => {
item.forEach((node: any) => {
bootNodeList[node] = true
Copy link
Collaborator

@kidneyweakx kidneyweakx Jan 12, 2024

Choose a reason for hiding this comment

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

use flat() to save a foreach loop

Object.values(isbootNodeList).flat().forEach(node => {
  bootNodeList[node] = true
})

Comment on lines 96 to 112
const nodelist = []
for (let i = 0; i < validatorNumber; i += 1) {
nodelist.push(
{
title: `validator${i}`,
value: `${i}`,
},
)
}
for (let i = 0; i < memberNumber; i += 1) {
nodelist.push(
{
title: `member${i}`,
value: `${i + validatorNumber}`,
},
)
}
Copy link
Collaborator

@kidneyweakx kidneyweakx Jan 12, 2024

Choose a reason for hiding this comment

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

I think nodelist use Array.from() can much more prettier?

const createNode = (type: string, index: number, offset = 0) => ({
  title: `${type}${index}`,
  value: `${index + offset}`,
})

const nodelist = [
  ...Array.from({ length: validatorNumber }, (_, i) => createNode('validator', i)),
  ...Array.from({ length: memberNumber }, (_, i) => createNode('member', i, validatorNumber)),
]

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a optional fix

@@ -18,6 +18,8 @@ export interface NetworkCreateType {
validatorNumber: number
memberNumber: number
alloc: AllocType[]
isBootNode: boolean
bootNodeList: any[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

bootNodeList: any[] -> boolean[]

@kidneyweakx kidneyweakx merged commit 3d58125 into cathayddt:2.1.0 Jan 17, 2024
1 check passed
@kidneyweakx kidneyweakx mentioned this pull request Feb 1, 2024
14 tasks
Pianochicken added a commit that referenced this pull request Feb 2, 2024
* refactor: replace all then to promise (#96)

* feat: bootnode mode (#97)

* feat: bootnode mode

* feat: assign specified node to be bootnode

* fix: remove console log

* fix: eslink and test

* fix: adjust for pr comments

* feat: optimize create network process (#100)

* feat:  transform bdk ui to quorum dashboard (#99)

* feat: bdk ui dashboard

* fix: modify reviewed code

* fix(ui): network info json location

---------

Co-authored-by: kidneyweak <[email protected]>

* fix: modify ui to dashboard (#101)

* update: 2.1.0 bdk dashboard

* fix(ca): promise catch test error (#103)

---------

Co-authored-by: Chengwei-Lin <[email protected]>
Co-authored-by: JakeKuo <[email protected]>
Co-authored-by: PianoChicken <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants