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

add initial block pool #139

Merged
merged 1 commit into from
Feb 28, 2019
Merged

add initial block pool #139

merged 1 commit into from
Feb 28, 2019

Conversation

arnetheduck
Copy link
Member

  • implement in-memory block graph
  • store tail block in database
  • resolve unknown parents by syncing them from peers
  • introduce concept of resolved blocks and attestations - those that
    follow minimal protocol rules
  • update state head lazily
  • log more stuff
  • shortHash -> shortLog
  • start 9/10 beacon nodes by default, last can be started manually
  • see also Pending attestation & block pool #134

@arnetheduck arnetheduck changed the title [WIP] add initial block pool add initial block pool Feb 27, 2019
@@ -0,0 +1,89 @@
# beacon_chain
# Copyright (c) 2018 Status Research & Development GmbH
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and elsewhere, what's the best thing to do with copyright years?

Copy link
Contributor

Choose a reason for hiding this comment

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

Omit or say "Copyright (c) 21st century, Status..."

I'm only half kidding, literally no one takes that in any way seriously, not even copyright lawyers (verified by two).

Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright 2018-Present

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, let's fix this on the whole repo after merging this, in a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this PR isn't the place to fix that.

@@ -269,6 +269,7 @@ func get_beacon_proposer_index*(state: BeaconState, slot: Slot): ValidatorIndex
# TODO this index is invalid outside of the block state transition function
# because presently, `state.slot += 1` happens before this function
# is called - see also testutil.getNextBeaconProposerIndex
# TODO is the above still true? the shuffling has changed since it was written
Copy link
Contributor

Choose a reason for hiding this comment

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

The shuffling is still a function of seed, which is a function of epoch, so one would have to check beginning/end of epoch boundary conditions.

Copy link
Member Author

Choose a reason for hiding this comment

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

think what would be useful here is a unit test that shows what's safe to do in terms of state-slot vs passed-in slot

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@mratsim mratsim left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,89 @@
# beacon_chain
# Copyright (c) 2018 Status Research & Development GmbH
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright 2018-Present

info "Attestation resolved",
slot = humaneSlotNum(attestation.data.slot),
shard = attestation.data.shard,
beaconBlockRoot = shortLog(attestation.data.beacon_block_root),
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose shortLog is a truncated print from chronicles?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, the idea being that we can define a function with one name for all types instead of a different name for ever type

beacon_chain/attestation_pool.nim Outdated Show resolved Hide resolved
beacon_chain/attestation_pool.nim Show resolved Hide resolved
@@ -31,6 +31,9 @@ type
Eth2Digest* = MDigest[32 * 8] ## `hash32` from spec
Eth2Hash* = blake2_512 ## Context for hash function

func shortLog*(x: Eth2Digest): string =
Copy link
Contributor

Choose a reason for hiding this comment

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

shortHash?

Copy link
Member Author

Choose a reason for hiding this comment

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

one name for all


func shortHash(x: auto): string =
($x)[0..7]
topicfetchBlocks = "ethereum/2.1/beacon_chain/fetch"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the intention here that this is a temporary solution?

In Brussels, we discussed that there will be a RequestManager instance that will be responsible for querying a number of randomly selected peers for blocks and other data through the SyncProtocol (which doesn't operate in broadcast fashion and sends the requests to specific peers).

The RequestManager may have some configurable policy for trading latency for bandwidth (i.e. it will control how many redundant requests are send in parallel in case some of the peers don't respond in time). It will also keep reputation scores for the peers.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, just an example to see if it works

beacon_chain/block_pool.nim Outdated Show resolved Hide resolved
@@ -59,35 +53,19 @@ USE_MULTITAIL="${USE_MULTITAIL:-no}" # make it an opt-in
type "$MULTITAIL" &>/dev/null || USE_MULTITAIL="no"
COMMANDS=()

for i in $(seq 0 9); do
for i in $(seq 0 8); do
Copy link
Contributor

Choose a reason for hiding this comment

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

You explained this on the call, but the audio interrupted briefly for me. Why are we skipping the last node?

Copy link
Member Author

Choose a reason for hiding this comment

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

the idea is to have one node to start easily separately (using ./run_node.sh 9)

* implement in-memory block graph
* store tail block in database
* resolve unknown parents by syncing them from peers
* introduce concept of resolved blocks and attestations - those that
follow minimal protocol rules
* update state head lazily
* log more stuff
* shortHash -> shortLog
* start 9/10 beacon nodes by default, last can be started manually
* see also #134
* fix start.sh epoch length
@arnetheduck arnetheduck merged commit 125231d into master Feb 28, 2019
@delete-merged-branch delete-merged-branch bot deleted the block-pool branch February 28, 2019 21:21
etan-status pushed a commit that referenced this pull request May 12, 2022
Add tests for read() and write() deadlocks.
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.

5 participants