Skip to content

Commit

Permalink
Merge branch 'main' into quota_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored May 8, 2024
2 parents d7d64e6 + 6e78ab0 commit b9feb2c
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 162 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/eventindexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: 1.21.0
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/guardianproverhealthcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: 1.21.0
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/relayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
go-version: 1.21.0
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
Expand Down
15 changes: 7 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5
github.com/pkg/errors v0.9.1
github.com/pressly/goose/v3 v3.19.2
github.com/pressly/goose/v3 v3.20.0
github.com/prometheus/client_golang v1.19.0
github.com/prysmaticlabs/prysm/v4 v4.2.0
github.com/rabbitmq/amqp091-go v1.9.0
Expand All @@ -36,7 +36,7 @@ require (
github.com/swaggo/swag v1.16.3
github.com/testcontainers/testcontainers-go v0.30.0
github.com/urfave/cli/v2 v2.27.2
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
golang.org/x/sync v0.7.0
gopkg.in/go-playground/assert.v1 v1.2.1
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -117,7 +117,7 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.13.0 // indirect
github.com/go-sql-driver/mysql v1.8.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
Expand Down Expand Up @@ -229,8 +229,7 @@ require (
github.com/prysmaticlabs/gohashtree v0.0.3-alpha // indirect
github.com/prysmaticlabs/prombbolt v0.0.0-20210126082820-9b7adba6db7c // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-20 v0.3.4 // indirect
github.com/quic-go/quic-go v0.39.4 // indirect
github.com/quic-go/quic-go v0.42.0 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
Expand Down Expand Up @@ -270,7 +269,7 @@ require (
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/dig v1.17.1 // indirect
go.uber.org/fx v1.20.1 // indirect
go.uber.org/mock v0.3.0 // indirect
go.uber.org/mock v0.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
Expand All @@ -281,7 +280,7 @@ require (
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/api v0.44.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
Expand All @@ -306,6 +305,6 @@ require (

replace github.com/ethereum/go-ethereum v1.13.15 => github.com/taikoxyz/taiko-geth v0.0.0-20240504072040-7e1b8b65a3f8

replace github.com/ethereum-optimism/optimism v1.7.4 => github.com/taikoxyz/optimism v0.0.0-20240504104604-6c9729321b29
replace github.com/ethereum-optimism/optimism v1.7.4 => github.com/taikoxyz/optimism v0.0.0-20240508063202-db34e8c760ea

replace github.com/uber/jaeger-client-go => github.com/uber/jaeger-client-go v2.25.0+incompatible
93 changes: 16 additions & 77 deletions go.sum

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/taiko-client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ lint:
&& goimports -local "github.com/taikoxyz/taiko-mono/packages/taiko-client" -w ./ \
&& golangci-lint run

test:
PACKAGE=${PACKAGE} \
test: lint
@PACKAGE=${PACKAGE} \
RUN_TESTS=true \
./integration_test/entrypoint.sh

dev_net:
COMPILE_PROTOCOL=${COMPILE_PROTOCOL} \
@COMPILE_PROTOCOL=${COMPILE_PROTOCOL} \
./integration_test/entrypoint.sh

gen_bindings:
TAIKO_GETH_DIR=${TAIKO_GETH_DIR} \
@TAIKO_GETH_DIR=${TAIKO_GETH_DIR} \
./scripts/gen_bindings.sh

.PHONY: build \
Expand Down
2 changes: 1 addition & 1 deletion packages/taiko-client/bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8532b7750513b87732340030139513d2b2ee203b
d4b62d23b4819bd932ad52b040a01f2cbbbeb9f2
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,86 @@ import (
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/testutils"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/internal/utils"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/pkg/rpc"
)

var (
maxBlocksGasLimit = uint64(50)
maxTxlistBytes = uint64(10000)
chainID = genesis.Config.ChainID
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
genesis = &core.Genesis{
Config: params.AllEthashProtocolChanges,
Alloc: types.GenesisAlloc{testAddr: {Balance: big.NewInt(2e15)}},
ExtraData: []byte("test genesis"),
Timestamp: 9000,
BaseFee: big.NewInt(params.InitialBaseFee),
}
chainID = new(big.Int).SetUint64(167001)
testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
testAddr = crypto.PubkeyToAddress(testKey.PublicKey)
)

func TestDecomporess(t *testing.T) {
d := NewTxListDecompressor(
maxBlocksGasLimit,
maxTxlistBytes,
type TxListDecompressorTestSuite struct {
testutils.ClientTestSuite
d *TxListDecompressor
}

func (s *TxListDecompressorTestSuite) SetupTest() {
s.ClientTestSuite.SetupTest()
s.d = NewTxListDecompressor(
params.MaxGasLimit,
rpc.BlockMaxTxListBytes,
chainID,
)
}

func (s *TxListDecompressorTestSuite) TestZeroBytes() {
s.Empty(s.d.TryDecompress(chainID, []byte{}, false))
}

func (s *TxListDecompressorTestSuite) TestCalldataSize() {
s.Empty(s.d.TryDecompress(chainID, randBytes(rpc.BlockMaxTxListBytes+1), false))
s.Empty(s.d.TryDecompress(chainID, randBytes(rpc.BlockMaxTxListBytes-1), false))
}

func (s *TxListDecompressorTestSuite) TestValidTxList() {
compressed, err := utils.Compress(rlpEncodedTransactionBytes(1, true))
require.NoError(t, err)

tests := []struct {
name string
blockID *big.Int
txListBytes []byte
decompressed []byte
}{
{
"txListBytes binary too large",
chainID,
randBytes(maxTxlistBytes + 1),
[]byte{},
},
{
"txListBytes not decodable to rlp",
chainID,
randBytes(0x1),
[]byte{},
},
{
"success empty tx list",
chainID,
rlpEncodedTransactionBytes(0, true),
[]byte{},
},
{
"success non-empty tx list",
chainID,
compressed,
rlpEncodedTransactionBytes(1, true),
},
}
s.Nil(err)
decompressed, err := utils.Decompress(compressed)
s.Nil(err)

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.decompressed, d.TryDecompress(tt.blockID, tt.txListBytes, false))
})
}
s.Equal(s.d.TryDecompress(chainID, compressed, true), decompressed)
s.Equal(s.d.TryDecompress(chainID, compressed, false), decompressed)
}

func (s *TxListDecompressorTestSuite) TestInvalidTxList() {
compressed, err := utils.Compress(randBytes(1024))
s.Nil(err)

s.Zero(len(s.d.TryDecompress(chainID, compressed, true)))
s.Zero(len(s.d.TryDecompress(chainID, compressed, false)))
}

func (s *TxListDecompressorTestSuite) TestInvalidZlibBytes() {
s.Zero(len(s.d.TryDecompress(chainID, randBytes(1024), true)))
s.Zero(len(s.d.TryDecompress(chainID, randBytes(1024), false)))
}

func TestDriverTestSuite(t *testing.T) {
suite.Run(t, new(TxListDecompressorTestSuite))
}

func rlpEncodedTransactionBytes(l int, signed bool) []byte {
txs := make(types.Transactions, 0)
for i := 0; i < l; i++ {
var tx *types.Transaction
if signed {
txData := &types.LegacyTx{
Nonce: 1,
To: &testAddr,
GasPrice: common.Big256,
Value: common.Big1,
Gas: 10,
}

tx = types.MustSignNewTx(testKey, types.LatestSigner(genesis.Config), txData)
txData := &types.LegacyTx{Nonce: 1, To: &testAddr, GasPrice: common.Big256, Value: common.Big1, Gas: 10}

tx = types.MustSignNewTx(testKey, types.LatestSigner(&params.ChainConfig{ChainID: chainID}), txData)
} else {
tx = types.NewTransaction(1, testAddr, common.Big1, 10, new(big.Int).SetUint64(10*params.GWei), nil)
}
txs = append(
txs,
tx,
)
txs = append(txs, tx)
}
b, _ := rlp.EncodeToBytes(txs)
return b
Expand Down

0 comments on commit b9feb2c

Please sign in to comment.