Skip to content

Commit

Permalink
feat(contracts): apply audit results (#373)
Browse files Browse the repository at this point in the history
* feat(contracts): remove the comment that implies bond amount change

* feat(contracts): save deleted output and enhance check when dismiss challenge

* feat(contracts): restrict contract address cannot call `registerValidator`

* feat(contracts): remove meaningless unchecked block

* feat(contracts): add sanity checks for `BalancedWeightTree`

* chore(contracts): update bindings and snapshots

* feat: apply contract interface changes to client code

* feat(contracts): apply PR review
  • Loading branch information
seolaoh authored Aug 22, 2024
1 parent 96aec79 commit 4f5570d
Show file tree
Hide file tree
Showing 19 changed files with 665 additions and 429 deletions.
138 changes: 81 additions & 57 deletions kroma-bindings/bindings/colosseum.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions kroma-bindings/bindings/colosseum_more.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kroma-bindings/bindings/validatormanager.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kroma-bindings/bindings/validatormanager_more.go

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions kroma-chain-ops/genesis/testdata/allocs-l1.json

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions kroma-validator/challenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,26 @@ func (c *Challenger) IsOutputFinalized(ctx context.Context, outputIndex *big.Int
func (c *Challenger) GetChallenge(ctx context.Context, outputIndex *big.Int, challenger common.Address) (bindings.TypesChallenge, error) {
cCtx, cCancel := context.WithTimeout(ctx, c.cfg.NetworkTimeout)
defer cCancel()
return c.colosseumContract.GetChallenge(optsutils.NewSimpleCallOpts(cCtx), outputIndex, challenger)

challenge, err := c.colosseumContract.Challenges(optsutils.NewSimpleCallOpts(cCtx), outputIndex, challenger)
if err != nil {
return bindings.TypesChallenge{}, fmt.Errorf("failed to fetch challenge data: %w", err)
}

segments, err := c.colosseumContract.GetSegments(optsutils.NewSimpleCallOpts(cCtx), outputIndex, challenger)
if err != nil {
return bindings.TypesChallenge{}, fmt.Errorf("failed to fetch challenge segments data: %w", err)
}

return bindings.TypesChallenge{
Turn: challenge.Turn,
TimeoutAt: challenge.TimeoutAt,
Asserter: challenge.Asserter,
Challenger: challenge.Challenger,
Segments: segments,
SegSize: challenge.SegSize,
SegStart: challenge.SegStart,
}, nil
}

func (c *Challenger) OutputAtBlockSafe(ctx context.Context, blockNumber uint64) (*eth.OutputResponse, error) {
Expand Down Expand Up @@ -863,7 +882,8 @@ func (c *Challenger) GetChallengeStatus(ctx context.Context, outputIndex *big.In
func (c *Challenger) BuildSegments(ctx context.Context, turn uint8, segStart, segSize uint64) (*chal.Segments, error) {
cCtx, cCancel := context.WithTimeout(ctx, c.cfg.NetworkTimeout)
defer cCancel()
sections, err := c.colosseumContract.GetSegmentsLength(optsutils.NewSimpleCallOpts(cCtx), turn)

sections, err := c.colosseumContract.SegmentsLengths(optsutils.NewSimpleCallOpts(cCtx), big.NewInt(int64(turn-1)))
if err != nil {
return nil, fmt.Errorf("unable to get segments length of turn %d: %w", turn, err)
}
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/actions/l2_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (rt *Runtime) setupChallenge(challenger *L2Validator, version uint8) {
require.Equal(rt.t, types.ReceiptStatusSuccessful, rt.receipt.Status, "failed to create challenge")

// check challenge created
challenge, err := rt.colosseumContract.GetChallenge(nil, rt.outputIndex, challenger.address)
challenge, err := rt.colosseumContract.Challenges(nil, rt.outputIndex, challenger.address)
require.NoError(rt.t, err)
require.NotNil(rt.t, challenge, "challenge not found")

Expand Down
1 change: 0 additions & 1 deletion op-e2e/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,6 @@ func TestChallenge(t *testing.T) {
return
}
}

}
}

Expand Down
271 changes: 138 additions & 133 deletions packages/contracts/.gas-snapshot

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/contracts/.storage-layout
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| segmentsLengths | mapping(uint256 => uint256) | 1 | 0 | 32 | contracts/L1/Colosseum.sol:Colosseum |
| challenges | mapping(uint256 => mapping(address => struct Types.Challenge)) | 2 | 0 | 32 | contracts/L1/Colosseum.sol:Colosseum |
| verifiedPublicInputs | mapping(bytes32 => bool) | 3 | 0 | 32 | contracts/L1/Colosseum.sol:Colosseum |
| deletedOutputs | mapping(uint256 => struct Types.CheckpointOutput) | 4 | 0 | 32 | contracts/L1/Colosseum.sol:Colosseum |

=======================
➡ contracts/L1/SecurityCouncil.sol:SecurityCouncil
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/contracts/L1/AssetManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ contract AssetManager is ISemver, IERC721Receiver, IAssetManager {
uint128 public immutable MIN_DELEGATION_PERIOD;

/**
* @notice The amount to bond. Can be updated via upgrade.
* @notice The amount to bond.
*/
uint128 public immutable BOND_AMOUNT;

Expand Down
Loading

0 comments on commit 4f5570d

Please sign in to comment.