Skip to content

Commit

Permalink
Merge branch 'taiko' into moonchain-geneva
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/docker.yml
  • Loading branch information
luanxu-mxc committed Nov 22, 2024
2 parents a2867a6 + fdd905a commit 2f6a17b
Show file tree
Hide file tree
Showing 11 changed files with 168 additions and 66 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ on:

jobs:
test:
runs-on: ubuntu-latest
runs-on: arc-runner-set
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Prepare environment
continue-on-error: true
run: sudo apt-get update && sudo apt-get install -y build-essential

- uses: actions/checkout@v3
with:
repository: taikoxyz/taiko-geth
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/close-inactive-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
close-issues:
runs-on: ubuntu-latest
runs-on: arc-runner-set
permissions:
issues: write
pull-requests: write
Expand Down
110 changes: 95 additions & 15 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
name: "Push docker image to GAR"
name: "Push multi-arch docker image to GAR"

on:
push:
branches: [ moonchain-geneva ]
tags:
- "v*"

env:
REGISTRY_IMAGE: us-docker.pkg.dev/mxczkevm/images/moonchain-geth

jobs:
push-docker-image:
runs-on: ubuntu-latest
build:
name: Build and push docker image
strategy:
matrix:
include:
- runner: arc-runner-set
platform: linux/amd64
- runner: arc-runner-set-arm64
platform: linux/arm64

runs-on: ${{ matrix.runner }}

steps:
- name: Prepare Environment
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
sudo apt-get update && sudo apt-get install -y git
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Login to GAR
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}
password: ${{ secrets.GAR_JSON_KEY }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
us-docker.pkg.dev/mxczkevm/images/moonchain-geth
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
Expand All @@ -57,13 +74,76 @@ jobs:
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build and push
uses: docker/build-push-action@v2
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
platforms: ${{ matrix.platform }}
push: true
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ env.REGISTRY_IMAGE }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true


- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: arc-runner-set
needs:
- build
steps:
- name: Prepare Environment
run: sudo apt-get update && sudo apt-get install -y jq

- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=sha
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: us-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
2 changes: 1 addition & 1 deletion .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
runs-on: arc-runner-set
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:

jobs:
release-please:
runs-on: ubuntu-latest
runs-on: arc-runner-set
steps:
- uses: googleapis/release-please-action@v4
with:
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [1.11.1](https://github.com/taikoxyz/taiko-geth/compare/v1.11.0...v1.11.1) (2024-10-22)


### Bug Fixes

* **taiko-geth:** fix a mempool fetch issue ([#333](https://github.com/taikoxyz/taiko-geth/issues/333)) ([1340ded](https://github.com/taikoxyz/taiko-geth/commit/1340ded3811193b46d18241e5810c5b47083821f))
* **taiko-geth:** revert a `tx.Shift()` change ([#335](https://github.com/taikoxyz/taiko-geth/issues/335)) ([46576d2](https://github.com/taikoxyz/taiko-geth/commit/46576d27209194db9e02ba38b9ab6b919679fcbd))
* **taiko-geth:** stop using `RevertToSnapshot` when fetching mempool ([#336](https://github.com/taikoxyz/taiko-geth/issues/336)) ([1216d8d](https://github.com/taikoxyz/taiko-geth/commit/1216d8d6051ba6f73ee42b395e973dccf1d90cf9))

## [1.11.0](https://github.com/taikoxyz/taiko-geth/compare/v1.10.0...v1.11.0) (2024-10-16)


### Features

* **core:** update `MainnetOntakeBlock` ([#330](https://github.com/taikoxyz/taiko-geth/issues/330)) ([cd72c5b](https://github.com/taikoxyz/taiko-geth/commit/cd72c5bf056cce5870b685226ae70e0d2620dc5e))

## [1.10.0](https://github.com/taikoxyz/taiko-geth/compare/v1.9.0...v1.10.0) (2024-10-03)


Expand Down
5 changes: 0 additions & 5 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,11 +702,6 @@ func (s *StateDB) Copy() *StateDB {
return state
}

// CHANGE(taiko): RevisionId returns the latest snapshot id.
func (s *StateDB) RevisionId() int {
return s.journal.nextRevisionId
}

// Snapshot returns an identifier for the current revision of the state.
func (s *StateDB) Snapshot() int {
return s.journal.snapshot()
Expand Down
5 changes: 2 additions & 3 deletions core/taiko_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
)

var (
InternalDevnetOntakeBlock = new(big.Int).SetUint64(2)
InternalDevnetOntakeBlock = new(big.Int).SetUint64(0)
HeklaOntakeBlock = new(big.Int).SetUint64(840_512)
// TODO: update this value when mainnet fork height is decided
MainnetOntakeBlock = new(big.Int).SetUint64(9_000_000)
MainnetOntakeBlock = new(big.Int).SetUint64(538_304)
)

// TaikoGenesisBlock returns the Taiko network genesis block configs.
Expand Down
42 changes: 21 additions & 21 deletions core/taiko_genesis/internal_l2a.json

Large diffs are not rendered by default.

40 changes: 24 additions & 16 deletions miner/taiko_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"compress/zlib"
"errors"
"fmt"
"maps"
"math/big"
"time"

Expand All @@ -17,8 +18,8 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"

"github.com/holiman/uint256"
"golang.org/x/exp/maps"
)

// BuildTransactionsLists builds multiple transactions lists which satisfy all the given conditions
Expand Down Expand Up @@ -71,14 +72,15 @@ func (w *Miner) buildTransactionsLists(
localTxs, remoteTxs = w.getPendingTxs(localAccounts, baseFee)
)

commitTxs := func() (*PreBuiltTxList, error) {
commitTxs := func(firstTransaction *types.Transaction) (*types.Transaction, *PreBuiltTxList, error) {
env.tcount = 0
env.txs = []*types.Transaction{}
env.gasPool = new(core.GasPool).AddGas(blockMaxGasLimit)
env.header.GasLimit = blockMaxGasLimit

w.commitL2Transactions(
lastTransaction := w.commitL2Transactions(
env,
firstTransaction,
newTransactionsByPriceAndNonce(signer, maps.Clone(localTxs), baseFee),
newTransactionsByPriceAndNonce(signer, maps.Clone(remoteTxs), baseFee),
maxBytesPerTxList,
Expand All @@ -87,19 +89,22 @@ func (w *Miner) buildTransactionsLists(

b, err := encodeAndCompressTxList(env.txs)
if err != nil {
return nil, err
return nil, nil, err
}

return &PreBuiltTxList{
return lastTransaction, &PreBuiltTxList{
TxList: env.txs,
EstimatedGasUsed: env.header.GasLimit - env.gasPool.Gas(),
BytesLength: uint64(len(b)),
}, nil
}

var (
lastTx *types.Transaction
res *PreBuiltTxList
)
for i := 0; i < int(maxTransactionsLists); i++ {
res, err := commitTxs()
if err != nil {
if lastTx, res, err = commitTxs(lastTx); err != nil {
return nil, err
}

Expand Down Expand Up @@ -227,16 +232,22 @@ func (w *Miner) getPendingTxs(localAccounts []string, baseFee *big.Int) (
// commitL2Transactions tries to commit the transactions into the given state.
func (w *Miner) commitL2Transactions(
env *environment,
firstTransaction *types.Transaction,
txsLocal *transactionsByPriceAndNonce,
txsRemote *transactionsByPriceAndNonce,
maxBytesPerTxList uint64,
minTip uint64,
) {
) *types.Transaction {
var (
txs = txsLocal
isLocal = true
txs = txsLocal
isLocal = true
lastTransaction *types.Transaction
)

if firstTransaction != nil {
env.txs = append(env.txs, firstTransaction)
}

loop:
for {
// If we don't have enough gas for any further transactions then we're done.
Expand Down Expand Up @@ -284,8 +295,6 @@ loop:
// Start executing the transaction
env.state.SetTxContext(tx.Hash(), env.tcount)

snap := env.state.RevisionId()
gasPool := env.gasPool.Gas()
err := w.commitTransaction(env, tx)
switch {
case errors.Is(err, core.ErrNonceTooLow):
Expand All @@ -295,7 +304,6 @@ loop:

case errors.Is(err, nil):
// Everything ok, collect the logs and shift in the next transaction from the same account
env.tcount++
txs.Shift()

data, err := rlp.EncodeToBytes(env.txs)
Expand All @@ -304,7 +312,6 @@ loop:
txs.Pop()
continue
}

if len(data) >= int(maxBytesPerTxList) {
// Encode and compress the txList, if the byte length is > maxBytesPerTxList, remove the latest tx and break.
b, err := compress(data)
Expand All @@ -314,9 +321,8 @@ loop:
continue
}
if len(b) > int(maxBytesPerTxList) {
lastTransaction = env.txs[env.tcount-1]
env.txs = env.txs[0 : env.tcount-1]
env.state.RevertToSnapshot(snap)
env.gasPool.SetGas(gasPool)
break loop
}
}
Expand All @@ -328,6 +334,8 @@ loop:
txs.Pop()
}
}

return lastTransaction
}

// encodeAndCompressTxList encodes and compresses the given transactions list.
Expand Down
4 changes: 2 additions & 2 deletions miner/taiko_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func testGenerateWorker(t *testing.T, txCount int) *Miner {
}

func TestBuildTransactionsLists(t *testing.T) {
w := testGenerateWorker(t, 1000)
w := testGenerateWorker(t, 2000)

maxBytesPerTxList := (params.BlobTxBytesPerFieldElement - 1) * params.BlobTxFieldElementsPerBlob
txList, err := w.BuildTransactionsLists(
testBankAddress,
nil,
240_000_000,
uint64(maxBytesPerTxList),
uint64(maxBytesPerTxList)/10,
nil,
1,
)
Expand Down

0 comments on commit 2f6a17b

Please sign in to comment.