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

Handle null blocks from Lotus #5294

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Handle null blocks from Lotus #5294

wants to merge 16 commits into from

Conversation

incrypto32
Copy link
Contributor

No description provided.

README.md Outdated Show resolved Hide resolved
chain/ethereum/src/adapter.rs Outdated Show resolved Hide resolved
chain/ethereum/src/adapter.rs Outdated Show resolved Hide resolved
chain/ethereum/src/ethereum_adapter.rs Outdated Show resolved Hide resolved
chain/ethereum/src/ethereum_adapter.rs Outdated Show resolved Hide resolved
chain/ethereum/src/ethereum_adapter.rs Show resolved Hide resolved
chain/ethereum/src/ethereum_adapter.rs Outdated Show resolved Hide resolved
graph/src/blockchain/polling_block_stream.rs Outdated Show resolved Hide resolved
graph/src/components/store/traits.rs Show resolved Hide resolved
store/postgres/src/chain_store.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@lutter lutter left a comment

Choose a reason for hiding this comment

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

I would like to see changes made to make sure we don't introduce additional overhead for existing chains.

chain/arweave/src/chain.rs Outdated Show resolved Hide resolved
chain/ethereum/src/adapter.rs Outdated Show resolved Hide resolved
chain/ethereum/src/adapter.rs Show resolved Hide resolved
chain/ethereum/src/chain.rs Show resolved Hide resolved
chain/ethereum/src/ethereum_adapter.rs Outdated Show resolved Hide resolved
block_hash
.ok_or_else(|| anyhow!("Ethereum node is missing block #{}", block_ptr.number))
.map(|block_hash| block_hash == block_ptr.hash_as_h256())
Ok(canonical_block == block_ptr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check will always be true for chains that are not Lotus, right? And this check requires that we make an RPC call, i.e., introduces overhead for chains that don't need it. I would much prefer an approach where Lotus gets its own EthereumAdapter, something like

struct LotusAdapter {
  inner: chain::ethereum::EthereumAdapter
}

where the impl of trait EthereumAdapter just forwards calls to inner when that's appropriate and has its own Lotus-specific impl like for this method when needed. That way, existing chains don't pay a price for the additional checks that Lotus requires.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check will always be true for chains that are not Lotus, right?

I dont understand this, this check can be false on other chains as well i believe, and even before the PR it still needed an RPC call the difference now is that for Lotus it might need more than one call, but for other chains it will still need the one call which was present even before this PR.

Am i missing something?

/// missing blocks in the chain store.
/// `block_hash` and offset=1 means its parent. If `root` is passed, short-circuit upon finding
/// a child of `root`. Returns None if unable to complete due to missing blocks in the chain
/// store.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand what 'short-circuiting' here means. Does that mean that when root is passed that the search stops if we either get to the offset-th ancestor of block_ptr or find a block whose parent is root?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is right

Copy link
Collaborator

Choose a reason for hiding this comment

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

I looked at it again, and I think I misread the changes the first time around. You are right, it's not adding an RPC call, just changed how a call is handled. So looks good to me.

One minor nit is that the method name nearest_block_hash_to_number sounds like it's translating a hash to a number when it is doing the reverse, maybe calling it nearest_block_hash_for_number would be clearer.

from ancestors a
where a.block_offset = $2;";
inner join ethereum_blocks b on a.block_hash = b.hash
Copy link
Collaborator

Choose a reason for hiding this comment

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

This join is probably not a big deal, but couldn't it be avoided if the recursive CTE also selected the block number, i.e. became with recursive ancestors (block_hash, block_number, block_offset) .. ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

recursive CTE also selected the block number

Not sure if im understanding this right., but we cannot do this because we have null block right?
We cannot simply do the below because there can be null blocks?
select b.parent_hash, b.block_number - 1, a.block_offset + 1

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, you are right.

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.

None yet

3 participants