Skip to content

Commit

Permalink
Merge branch 'main' into const_contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp committed Sep 22, 2024
2 parents a0c8f11 + bba2b79 commit 0906986
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Prepare environment
continue-on-error: true
run: sudo apt-get update && sudo apt-get install -y git netcat
run: sudo apt-get update && sudo apt-get install -y git netcat wget

- name: Checkout repository
uses: actions/checkout@v4
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/taiko-client--hive_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
if: github.event.pull_request.draft == false && contains(github.event.pull_request.labels.*.name, 'option.hive-test')
name: hive tests
runs-on: [arc-runner-set]
timeout-minutes: 20
timeout-minutes: 30

steps:
- name: Cancel Previous Runs
Expand All @@ -32,22 +32,9 @@ jobs:
go-version: 1.21
cache: true

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install pnpm dependencies
uses: ./.github/actions/install-pnpm-dependencies

- name: Clone taikoxyz/hive
run: git clone https://github.com/taikoxyz/hive.git /tmp/hive

- name: Update taiko contract tx list
working-directory: .
run: |
export TAIKO_MONO_DIR=$PWD
cd /tmp/hive/simulators/taiko
sh scripts/deploy_l1_contract.sh
- name: Hive tests
working-directory: packages/taiko-client
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/taiko-client--test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ jobs:
lint:
if: github.event.pull_request.draft == false
name: Lint
runs-on: [arc-runner-set]
runs-on: [ubuntu-latest]
steps:
- name: Install Git
run: sudo apt-get update && sudo apt-get install -y git make

- uses: actions/checkout@v4

- name: Set up Go
Expand All @@ -25,9 +22,12 @@ jobs:
go-version: 1.21
cache: true

- name: Install golangci-lint
run: go install -v github.com/golangci/golangci-lint/cmd/[email protected]

- name: Lint
working-directory: packages/taiko-client
run: make lint
run: golangci-lint run --path-prefix=./ --config=.golangci.yml

integration_tests:
if: github.event.pull_request.draft == false
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

[![Twitter Follow](https://img.shields.io/twitter/follow/taikoxyz?style=social)](https://twitter.com/taikoxyz)
[![Discord](https://img.shields.io/discord/984015101017346058?color=%235865F2&label=Discord&logo=discord&logoColor=%23fff)](https://discord.gg/taikoxyz)
[![YouTube](https://img.shields.io/youtube/channel/subscribers/UCxd_ARE9LtAEdnRQA6g1TaQ)](https://www.youtube.com/@taikoxyz)
<!--[![YouTube](https://img.shields.io/youtube/channel/subscribers/UCxd_ARE9LtAEdnRQA6g1TaQ)](https://www.youtube.com/@taikoxyz)-->

[![GitPOAP Badge](https://public-api.gitpoap.io/v1/repo/taikoxyz/taiko-mono/badge)](https://www.gitpoap.io/gh/taikoxyz/taiko-mono)
[![License](https://img.shields.io/github/license/taikoxyz/taiko-mono)](https://github.com/taikoxyz/taiko-mono/blob/main/LICENSE.md)
Expand Down
51 changes: 51 additions & 0 deletions packages/protocol/contracts/layer1/based/LibUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ library LibUtils {

error L1_BLOCK_MISMATCH();
error L1_INVALID_BLOCK_ID();
error L1_INVALID_PARAMS();
error L1_INVALID_GENESIS_HASH();
error L1_TRANSITION_NOT_FOUND();
error L1_UNEXPECTED_TRANSITION_ID();
Expand Down Expand Up @@ -195,6 +196,31 @@ library LibUtils {
return _state.transitions[slot][_tid];
}

/// @dev Retrieves the transitions with a batch of parentHash.
/// @param _state Current TaikoData.State.
/// @param _config Actual TaikoData.Config.
/// @param _blockIds Id array of the block.
/// @param _tids The transition id array.
/// @return transitions_ The state transition pointer array.
function getTransitions(
TaikoData.State storage _state,
TaikoData.Config memory _config,
uint64[] calldata _blockIds,
uint32[] calldata _tids
)
internal
view
returns (TaikoData.TransitionState[] memory transitions_)
{
if (_blockIds.length == 0 || _blockIds.length != _tids.length) {
revert L1_INVALID_PARAMS();
}
transitions_ = new TaikoData.TransitionState[](_blockIds.length);
for (uint256 i; i < _blockIds.length; ++i) {
transitions_[i] = getTransition(_state, _config, _blockIds[i], _tids[i]);
}
}

/// @notice This function will revert if the transition is not found.
/// @dev Retrieves the transition with a given parentHash.
/// @param _state Current TaikoData.State.
Expand All @@ -220,6 +246,31 @@ library LibUtils {
return _state.transitions[slot][tid];
}

/// @dev Retrieves the transitions with a batch of parentHash.
/// @param _state Current TaikoData.State.
/// @param _config Actual TaikoData.Config.
/// @param _blockIds Id array of the blocks.
/// @param _parentHashes Parent hashes of the blocks.
/// @return transitions_ The state transition pointer array.
function getTransitions(
TaikoData.State storage _state,
TaikoData.Config memory _config,
uint64[] calldata _blockIds,
bytes32[] calldata _parentHashes
)
internal
view
returns (TaikoData.TransitionState[] memory transitions_)
{
if (_blockIds.length == 0 || _blockIds.length != _parentHashes.length) {
revert L1_INVALID_PARAMS();
}
transitions_ = new TaikoData.TransitionState[](_blockIds.length);
for (uint256 i; i < _blockIds.length; ++i) {
transitions_[i] = getTransition(_state, _config, _blockIds[i], _parentHashes[i]);
}
}

/// @dev Retrieves the ID of the transition with a given parentHash.
/// This function will return 0 if the transition is not found.
function getTransitionId(
Expand Down
30 changes: 30 additions & 0 deletions packages/protocol/contracts/layer1/based/TaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
return LibUtils.getTransition(state, getConfig(), _blockId, _parentHash);
}

/// @notice Gets the state transitions for a batch of block.
/// @param _blockIds Index of the blocks.
/// @param _parentHashes Parent hashes of the blocks.
/// @return The state transition array of the blocks.
function getTransitions(
uint64[] calldata _blockIds,
bytes32[] calldata _parentHashes
)
external
view
returns (TaikoData.TransitionState[] memory)
{
return LibUtils.getTransitions(state, getConfig(), _blockIds, _parentHashes);
}

/// @notice Gets the state transition for a specific block.
/// @param _blockId Index of the block.
/// @param _tid The transition id.
Expand All @@ -235,6 +250,21 @@ contract TaikoL1 is EssentialContract, ITaikoL1, TaikoEvents {
return LibUtils.getTransition(state, getConfig(), _blockId, _tid);
}

/// @notice Gets the state transitions for a batch of block.
/// @param _blockIds Index array of the blocks.
/// @param _tids The transition id array of the blocks.
/// @return The state transition array of the blocks.
function getTransitions(
uint64[] calldata _blockIds,
uint32[] calldata _tids
)
external
view
returns (TaikoData.TransitionState[] memory)
{
return LibUtils.getTransitions(state, getConfig(), _blockIds, _tids);
}

/// @notice Returns information about the last verified block.
/// @return blockId_ The last verified block's ID.
/// @return blockHash_ The last verified block's blockHash.
Expand Down
1 change: 0 additions & 1 deletion packages/taiko-client/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ linters:
- sqlclosecheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
- whitespace
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clean:

lint:
@go install golang.org/x/tools/cmd/goimports@latest \
&& go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2 \
&& go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60 \
&& goimports -local "github.com/taikoxyz/taiko-mono/packages/taiko-client" -w ./ \
&& golangci-lint run

Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/integration_test/hive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestHiveHandler(t *testing.T) {
})

// Multi clusters reorg test.
t.Run("taiko-reorg/taiko-reorg/clusters(1)", func(t *testing.T) {
t.Run("taiko-reorg/taiko-reorg", func(t *testing.T) {
testDenebReorg(t, "taiko-reorg/taiko-reorg", [][]string{clientGroups[0]})
})

Expand Down

0 comments on commit 0906986

Please sign in to comment.