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

Smart contracts: Registry + Challenger #22

Merged
merged 28 commits into from
May 28, 2024

Conversation

merklefruit
Copy link
Collaborator

@merklefruit merklefruit commented Apr 30, 2024

This PR includes basic tests for both registry and challenger, but more comprehensive tests will be added in further PRs.
In particular, the challenger logic is security critical so that will need to undergo a lot more effort.

@merklefruit merklefruit linked an issue Apr 30, 2024 that may be closed by this pull request
@merklefruit merklefruit changed the title wip: smart contracts Smart contracts: Registry + Challenger May 3, 2024
@thedevbirb thedevbirb force-pushed the 04-29-chore_contracts_dir branch from a1bac2a to 6e50fc7 Compare May 13, 2024 09:11
@thedevbirb thedevbirb force-pushed the 04-29-chore_contracts_dir branch from 6e50fc7 to 485c8d0 Compare May 14, 2024 09:46
@merklefruit merklefruit added C: smart-contracts Component: smart contracts T: feature Type: Feature labels May 22, 2024
@merklefruit merklefruit marked this pull request as ready for review May 24, 2024 08:21
@merklefruit merklefruit linked an issue May 24, 2024 that may be closed by this pull request
Copy link
Contributor

@thedevbirb thedevbirb left a comment

Choose a reason for hiding this comment

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

Some details but overall great job!

Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did it in the upstream PR #35
Will leave it here for now

bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
/// @notice A challenge requires a bond to be transferred to this contract to avoid spamming.
/// @param _basedProposer The address of the proposer to challenge
/// @param _signedCommitment The signed commitment that the proposer is getting challenged for
function challengeProposer(address _basedProposer, SignedCommitment calldata _signedCommitment) public payable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we check if _basedProposer is in the registry or we leave it as it is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
bolt-contracts/src/contracts/BoltChallenger.sol Outdated Show resolved Hide resolved
Comment on lines 315 to 320
// The genelized index is the index of the merkle tree generated by the merkleization
// process of a SSZ list of transactions. Since this list is dynamic and can be of maximum
// length of 2^20 = 1_048_576, the merkleization process fills the tree with empty hashes,
// therefore this number is an offset from where transactions hash tree root starts.
// To read more, check out https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization
uint256 generalizedIndex = 1_048_576 + _transactionIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

The generalized index actually starts at 2^21 = 2_097_152, because we have to take into account one level of the tree that specifies the maximum length of the list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch ser!

@merklefruit merklefruit merged commit e39dedf into unstable May 28, 2024
@merklefruit merklefruit deleted the 04-29-chore_contracts_dir branch May 28, 2024 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: smart-contracts Component: smart contracts T: feature Type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On-chain proof challenge game for commitment verification On-chain registry
2 participants