Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 5eb8861

Browse files
committed
test: revert test changes, wait for anvil update
1 parent 5c6d0fe commit 5eb8861

File tree

23 files changed

+92
-175
lines changed

23 files changed

+92
-175
lines changed

.github/workflows/test.yml

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
with:
4646
repository: taikoxyz/taiko-mono
4747
path: ${{ env.TAIKO_MONO_DIR }}
48-
ref: alpha-6_eip4844
4948

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

bindings/.githead

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c12e2d75fff02dcd1b0f1edaa1781a30a1d4b4e1
1+
6e2771c54e62e73715cfbe2e7d4fc5a2fb54cf5c

bindings/gen_taiko_token.go

+1-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

driver/chain_syncer/calldata/syncer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func (s *Syncer) onBlockProposed(
251251
}
252252

253253
// Check whether the transactions list is valid.
254-
hint, invalidTxIndex, err := s.txListValidator.ValidateTxList(event.BlockId, txListBytes)
254+
hint, invalidTxIndex, err := s.txListValidator.ValidateTxList(event.BlockId, txListBytes, event.Meta.BlobUsed)
255255
if err != nil {
256256
return fmt.Errorf("failed to validate transactions list: %w", err)
257257
}

driver/txlist_fetcher/blob.go

+28-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ package txlistdecoder
33
import (
44
"context"
55
"crypto/sha256"
6+
"errors"
67
"math/big"
78

89
"github.com/ethereum/go-ethereum/common"
910
"github.com/ethereum/go-ethereum/core/types"
1011
"github.com/ethereum/go-ethereum/crypto/kzg4844"
1112
"github.com/ethereum/go-ethereum/log"
13+
"github.com/ethereum/go-ethereum/params"
1214
"github.com/taikoxyz/taiko-client/bindings"
1315
"github.com/taikoxyz/taiko-client/pkg/rpc"
1416
)
1517

16-
const (
18+
var (
1719
blobCommitmentVersionKZG uint8 = 0x01 // Version byte for the point evaluation precompile.
20+
errBlobInvalid = errors.New("invalid blob encoding")
1821
)
1922

2023
type BlobFetcher struct {
@@ -52,17 +55,39 @@ func (d *BlobFetcher) Fetch(
5255
if KZGToVersionedHash(
5356
kzg4844.Commitment(common.FromHex(sidecar.KzgCommitment)),
5457
) == common.BytesToHash(meta.BlobHash[:]) {
55-
return common.Hex2Bytes(sidecar.Blob), nil
58+
return DecodeBlob(common.FromHex(sidecar.Blob))
5659
}
5760
}
5861

5962
return nil, errSidecarNotFound
6063
}
6164

62-
// KZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844
65+
// KZGToVersionedHash implements kzg_to_versioned_hash from EIP-4844.
6366
func KZGToVersionedHash(kzg kzg4844.Commitment) common.Hash {
6467
h := sha256.Sum256(kzg[:])
6568
h[0] = blobCommitmentVersionKZG
6669

6770
return h
6871
}
72+
73+
// DecodeBlob decode blob data.
74+
func DecodeBlob(blob []byte) ([]byte, error) {
75+
if len(blob) != params.BlobTxFieldElementsPerBlob*32 {
76+
return nil, errBlobInvalid
77+
}
78+
log.Info("OK")
79+
var data []byte
80+
for i, j := 0, 0; i < params.BlobTxFieldElementsPerBlob; i++ {
81+
data = append(data, blob[j:j+31]...)
82+
j += 32
83+
}
84+
85+
i := len(data) - 1
86+
for ; i >= 0; i-- {
87+
if data[i] != 0x00 {
88+
break
89+
}
90+
}
91+
data = data[:i+1]
92+
return data, nil
93+
}

go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ require (
99
github.com/ethereum/go-ethereum v1.13.11
1010
github.com/go-resty/resty/v2 v2.7.0
1111
github.com/holiman/uint256 v1.2.4
12-
github.com/joho/godotenv v1.5.1
1312
github.com/labstack/echo/v4 v4.11.1
1413
github.com/modern-go/reflect2 v1.0.2
1514
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,6 @@ github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPw
530530
github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
531531
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
532532
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
533-
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
534-
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
535533
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
536534
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
537535
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=

integration_test/test_env.sh

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export TREASURY=0x1670010000000000000000000000000000010001
2525
# show the integration test environment variables.
2626
echo "RUN_TESTS=true
2727
TAIKO_MONO_DIR=$TAIKO_MONO_DIR
28-
L1_BEACON_HTTP_ENDPOINT=$L1_BEACON_HTTP_ENDPOINT
2928
L1_NODE_HTTP_ENDPOINT=$L1_NODE_HTTP_ENDPOINT
3029
L1_NODE_WS_ENDPOINT=$L1_NODE_WS_ENDPOINT
3130
L2_EXECUTION_ENGINE_HTTP_ENDPOINT=$L2_EXECUTION_ENGINE_HTTP_ENDPOINT

internal/docker/.gitignore

-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
consensus/beacondata
2-
consensus/genesis.ssz
3-
consensus/validatordata
4-
execution/geth
5-
execution/geth.ipc
6-
execution/genesis.json
71
taikogeth/taiko-geth

internal/docker/common.sh

-31
This file was deleted.

internal/docker/docker_env.sh

+8-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44

55
# check until L1 chain is ready
6-
L1_PROBE_URL=http://localhost:$(docker port geth | grep '0.0.0.0' | awk -F ':' 'NR==1 {print $2}')
6+
L1_PROBE_URL=http://localhost:$(docker port l1_node | grep '0.0.0.0' | awk -F ':' '{print $2}')
77
until cast chain-id --rpc-url "$L1_PROBE_URL" 2> /dev/null; do
88
sleep 1
99
done
@@ -15,25 +15,20 @@ until cast chain-id --rpc-url "$L2_PROBE_URL" 2> /dev/null; do
1515
done
1616

1717

18-
L1_BEACON_PORT=$(docker port beacon-chain | grep '0.0.0.0' | awk -F ':' '{print $2}')
19-
export L1_BEACON_HTTP_ENDPOINT=http://localhost:$L1_BEACON_PORT
20-
export L1_NODE_HTTP_ENDPOINT=http://localhost:$(docker port geth | grep '0.0.0.0' | awk -F ':' 'NR==1 {print $2}')
21-
export L1_NODE_WS_ENDPOINT=ws://localhost:$(docker port geth | grep '0.0.0.0' | awk -F ':' 'NR==2 {print $2}')
18+
L1_NODE_PORT=$(docker port l1_node | grep '0.0.0.0' | awk -F ':' '{print $2}')
19+
export L1_NODE_HTTP_ENDPOINT=http://localhost:$L1_NODE_PORT
20+
export L1_NODE_WS_ENDPOINT=ws://localhost:$L1_NODE_PORT
2221

2322
export L2_EXECUTION_ENGINE_HTTP_ENDPOINT=http://localhost:$(docker port l2_node | grep "0.0.0.0" | awk -F ':' 'NR==1 {print $2}')
2423
export L2_EXECUTION_ENGINE_WS_ENDPOINT=ws://localhost:$(docker port l2_node | grep "0.0.0.0" | awk -F ':' 'NR==2 {print $2}')
2524
export L2_EXECUTION_ENGINE_AUTH_ENDPOINT=http://localhost:$(docker port l2_node | grep "0.0.0.0" | awk -F ':' 'NR==3 {print $2}')
26-
export JWT_SECRET=$DIR/taikogeth/jwt.hex
25+
export JWT_SECRET=$DIR/nodes/jwt.hex
26+
27+
echo -e "L1_NODE PORTS: \n$(docker port l1_node)"
28+
echo -e "L2_NODE PORTS: \n$(docker port l2_node)"
2729

28-
echo
29-
echo -e "L1_NODE PORTS: \n$(docker port geth)"
3030
echo "L1_NODE_HTTP_ENDPOINT: $L1_NODE_HTTP_ENDPOINT"
3131
echo "L1_NODE_WS_ENDPOINT: $L1_NODE_WS_ENDPOINT"
32-
echo
33-
echo -e "L1_BEACON PORTS: \n$(docker port beacon-chain)"
34-
echo "L1_BEACON_HTTP_ENDPOINT: $L1_BEACON_HTTP_ENDPOINT"
35-
echo
36-
echo -e "L2_NODE PORTS: \n$(docker port l2_node)"
3732
echo "L2_EXECUTION_ENGINE_HTTP_ENDPOINT: $L2_EXECUTION_ENGINE_HTTP_ENDPOINT"
3833
echo "L2_EXECUTION_ENGINE_WS_ENDPOINT: $L2_EXECUTION_ENGINE_WS_ENDPOINT"
3934
echo "L2_EXECUTION_ENGINE_AUTH_ENDPOINT: $L2_EXECUTION_ENGINE_AUTH_ENDPOINT"

internal/docker/docker-compose.yml internal/docker/nodes/docker-compose.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: "3.9"
33
services:
44
l1_node:
55
container_name: l1_node
6-
image: ghcr.dockerproxy.com/foundry-rs/foundry:latest
6+
image: ghcr.dockerproxy.com/foundry-rs/foundry:nightly-4a643801d0b3855934cdec778e33e79c79971783
77
restart: unless-stopped
88
pull_policy: always
99
ports:
@@ -12,16 +12,14 @@ services:
1212
- anvil
1313
- --host
1414
- "0.0.0.0"
15-
- --hardfork
16-
- "cancun"
1715

1816
l2_execution_engine:
1917
container_name: l2_node
2018
image: gcr.dockerproxy.com/evmchain/taiko-geth:taiko
2119
restart: unless-stopped
2220
pull_policy: always
2321
volumes:
24-
- ./taikogeth:/host
22+
- .:/host
2523
ports:
2624
- "8545"
2725
- "8546"
@@ -33,7 +31,7 @@ services:
3331
- --syncmode
3432
- full
3533
- --datadir
36-
- /host/taiko-geth
34+
- /data/taiko-geth
3735
- --networkid
3836
- "167001"
3937
- --metrics
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c49690b5a9bc72c7b451b48c5fee2b542e66559d840a133d090769abc56e39e7
1+
c49690b5a9bc72c7b451b48c5fee2b542e66559d840a133d090769abc56e39e7

internal/docker/start.sh

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
#!/bin/bash
22

3-
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3+
source scripts/common.sh
44

5-
source "$DIR"/common.sh
5+
DOCKER_SERVICE_LIST=("l1_node" "l2_execution_engine")
66

77
# start docker compose service list
88
echo "start docker compose service: ${DOCKER_SERVICE_LIST[*]}"
99

10-
# Init docker
11-
compose_up "${DOCKER_INIT_LIST[@]}"
12-
13-
# Start docker containers.
1410
compose_up "${DOCKER_SERVICE_LIST[@]}"
1511

1612
# show all the running containers

internal/docker/stop.sh

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
#!/bin/bash
22

3-
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4-
source "$DIR"/common.sh
3+
source scripts/common.sh
54

6-
echo "stop docker compose service: ${DOCKER_INIT_LIST[*]}"
7-
compose_down "${DOCKER_INIT_LIST[@]}"
5+
DOCKER_SERVICE_LIST=("l1_node" "l2_execution_engine")
86

97
echo "stop docker compose service: ${DOCKER_SERVICE_LIST[*]}"
10-
compose_down "${DOCKER_SERVICE_LIST[@]}"
11-
12-
# Delete exited containers.
13-
docker rm $(docker ps -aqf "status=exited") 2>/dev/null
148

15-
rm -rf "$DIR"/consensus/beacondata "$DIR"/consensus/validatordata "$DIR"/consensus/genesis.ssz
16-
rm -rf "$DIR"/execution/geth
17-
rm -rf "$DIR"/taikogeth/taiko-geth
9+
compose_down "${DOCKER_SERVICE_LIST[@]}"

internal/testutils/suite.go

-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/stretchr/testify/suite"
1616

1717
"github.com/taikoxyz/taiko-client/bindings"
18-
"github.com/taikoxyz/taiko-client/internal/utils"
1918
"github.com/taikoxyz/taiko-client/pkg/jwt"
2019
"github.com/taikoxyz/taiko-client/pkg/rpc"
2120
"github.com/taikoxyz/taiko-client/prover/server"
@@ -37,9 +36,6 @@ func (s *ClientTestSuite) SetupTest() {
3736
glogger := log.NewGlogHandler(log.NewTerminalHandlerWithLevel(os.Stdout, log.LevelInfo, true))
3837
log.SetDefault(log.NewLogger(glogger))
3938

40-
// Load env.
41-
utils.LoadEnv()
42-
4339
testAddrPrivKey, err := crypto.ToECDSA(common.FromHex(os.Getenv("L1_PROPOSER_PRIVATE_KEY")))
4440
s.Nil(err)
4541

internal/utils/utils.go

-21
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,12 @@ package utils
22

33
import (
44
"crypto/rand"
5-
"fmt"
65
"math/big"
7-
"os"
8-
"strings"
96

107
"github.com/ethereum/go-ethereum/common/math"
11-
"github.com/ethereum/go-ethereum/log"
12-
"github.com/joho/godotenv"
138
"github.com/modern-go/reflect2"
149
)
1510

16-
func LoadEnv() {
17-
// load test environment variables.
18-
currentPath, err := os.Getwd()
19-
if err != nil {
20-
log.Warn("get current path failed", "err", err)
21-
}
22-
path := strings.Split(currentPath, "/taiko-client")
23-
if len(path) == 0 {
24-
log.Warn("not a taiko-client repo")
25-
}
26-
err = godotenv.Load(fmt.Sprintf("%s/taiko-client/.env", path[0]))
27-
if err != nil {
28-
log.Warn("failed to load env", "current path", currentPath, "err", err)
29-
}
30-
}
31-
3211
func RandUint64(max *big.Int) uint64 {
3312
if max == nil {
3413
max = new(big.Int)

pkg/rpc/tx_blob_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ import (
1111
"github.com/ethereum/go-ethereum/core/types"
1212
"github.com/ethereum/go-ethereum/crypto"
1313
"github.com/stretchr/testify/assert"
14-
15-
"github.com/taikoxyz/taiko-client/internal/utils"
1614
)
1715

1816
func TestBlockTx(t *testing.T) {
17+
t.SkipNow()
1918
ctx, cancel := context.WithCancel(context.Background())
2019
defer cancel()
2120

22-
// Load env.
23-
utils.LoadEnv()
24-
2521
url := os.Getenv("L1_NODE_WS_ENDPOINT")
2622
l1Client, err := NewEthClient(ctx, url, time.Second*20)
2723
assert.NoError(t, err)

pkg/txlistvalidator/tx_list_validator.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,24 @@ func NewTxListValidator(
4444
func (v *TxListValidator) ValidateTxList(
4545
blockID *big.Int,
4646
txListBytes []byte,
47+
blobUsed bool,
4748
) (hint InvalidTxListReason, txIdx int, err error) {
4849
if len(txListBytes) == 0 {
4950
return HintOK, 0, nil
5051
}
5152

52-
hint, txIdx = v.isTxListValid(blockID, txListBytes)
53+
hint, txIdx = v.isTxListValid(blockID, txListBytes, blobUsed)
5354

5455
return hint, txIdx, nil
5556
}
5657

5758
// isTxListValid checks whether the transaction list is valid.
58-
func (v *TxListValidator) isTxListValid(blockID *big.Int, txListBytes []byte) (hint InvalidTxListReason, txIdx int) {
59-
if len(txListBytes) > int(v.maxBytesPerTxList) {
59+
func (v *TxListValidator) isTxListValid(
60+
blockID *big.Int,
61+
txListBytes []byte,
62+
blobUsed bool,
63+
) (hint InvalidTxListReason, txIdx int) {
64+
if !blobUsed && (len(txListBytes) > int(v.maxBytesPerTxList)) {
6065
log.Info("Transactions list binary too large", "length", len(txListBytes), "blockID", blockID)
6166
return HintNone, 0
6267
}

pkg/txlistvalidator/tx_list_validator_test.go

+1-14
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@ var (
3131
}
3232
)
3333

34-
func TestValidateTxList(t *testing.T) {
35-
v := NewTxListValidator(
36-
maxBlocksGasLimit,
37-
maxBlockNumTxs,
38-
maxTxlistBytes,
39-
chainID,
40-
)
41-
42-
// Binary is not unpackable
43-
_, _, err := v.ValidateTxList(common.Big0, randBytes(5))
44-
require.NotNil(t, err)
45-
}
46-
4734
func TestIsTxListValid(t *testing.T) {
4835
v := NewTxListValidator(
4936
maxBlocksGasLimit,
@@ -97,7 +84,7 @@ func TestIsTxListValid(t *testing.T) {
9784

9885
for _, tt := range tests {
9986
t.Run(tt.name, func(t *testing.T) {
100-
reason, txIdx := v.isTxListValid(tt.blockID, tt.txListBytes)
87+
reason, txIdx := v.isTxListValid(tt.blockID, tt.txListBytes, false)
10188
require.Equal(t, tt.wantReason, reason)
10289
require.Equal(t, tt.wantTxIdx, txIdx)
10390
})

0 commit comments

Comments
 (0)