Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: compact blocks prototype #3713

Draft
wants to merge 66 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
959a4b8
use celestia-core branch with compact blocks
cmwaters Jul 19, 2024
79cbec4
modify two node simple benchmark
cmwaters Jul 19, 2024
b9408ed
Merge branch 'main' into cal/compact-blocks
cmwaters Jul 19, 2024
6f5018e
update go mod
cmwaters Jul 22, 2024
0d92d07
start the tx client later
cmwaters Jul 23, 2024
fe475f1
make some modifications to e2e simple
cmwaters Jul 23, 2024
1584726
use latest compact blocks changes
cmwaters Jul 24, 2024
dd0c28d
Merge branch 'main' into cal/compact-blocks
cmwaters Jul 24, 2024
a7ea55b
add docker container version
cmwaters Jul 24, 2024
12d9412
bump go mod
cmwaters Jul 29, 2024
5b4d614
udpate metric gathering
cmwaters Jul 30, 2024
28f3f03
fix metrics
cmwaters Jul 30, 2024
3cb2353
panic in ante handler with 0 version
cmwaters Jul 30, 2024
9bc97a2
checkpoint
cmwaters Jul 30, 2024
a8007d8
checkpoint
cmwaters Jul 30, 2024
e4563ba
checkpoint
cmwaters Jul 31, 2024
75e4ea6
checkpoint
cmwaters Jul 31, 2024
76c34d6
checkpoint
cmwaters Aug 1, 2024
bc97f50
checkpoint
cmwaters Aug 8, 2024
6f42cdf
Merge branch 'main' into cal/compact-blocks
cmwaters Aug 8, 2024
66b38d5
checkpoint
cmwaters Aug 9, 2024
0c3586b
checkpoint
cmwaters Aug 9, 2024
e1d7500
checkpoint
cmwaters Aug 9, 2024
729e0a1
checkpoint
cmwaters Aug 12, 2024
bbce586
checkpoint
cmwaters Aug 13, 2024
0ab0600
checkpoint
cmwaters Aug 13, 2024
c22c574
checkpoint
cmwaters Aug 13, 2024
6c85542
checkpoint
cmwaters Aug 14, 2024
b1018cd
Merge branch 'main' into cal/compact-blocks
cmwaters Aug 14, 2024
17c3665
checkpoint
cmwaters Aug 14, 2024
7e9dcd4
fix msg gatekeeper
cmwaters Aug 14, 2024
f4a6dbb
checkpoint
cmwaters Aug 14, 2024
a0e20e0
Merge branch 'main' into cal/compact-blocks
cmwaters Aug 14, 2024
a161691
checkpoint
cmwaters Aug 14, 2024
d57d1af
checkpoint
cmwaters Aug 15, 2024
87d3e21
checkpoint
cmwaters Aug 16, 2024
02b512f
checkpoint
cmwaters Aug 16, 2024
d6729fa
checkpoint
cmwaters Aug 20, 2024
4ab6269
Merge branch 'main' into cal/compact-blocks
cmwaters Aug 20, 2024
1c088cd
fix compile errors
cmwaters Aug 20, 2024
937d100
checkpoint
cmwaters Aug 22, 2024
f05744e
checkpoint
cmwaters Aug 26, 2024
44110b0
checkpoint
cmwaters Aug 26, 2024
d4ba7a0
checkpoint
cmwaters Aug 28, 2024
2dd6eff
Merge branch 'main' into cal/compact-blocks
cmwaters Aug 28, 2024
8a062d2
checkpoint
cmwaters Aug 30, 2024
754d16c
checkpoint
cmwaters Aug 30, 2024
beed88a
checkpoint
cmwaters Aug 30, 2024
116d63d
checkpoint
cmwaters Aug 30, 2024
a84eaf9
introduce option to allow txsim to ignore submission errors
cmwaters Aug 30, 2024
9d4cb4a
update txsim
cmwaters Sep 2, 2024
ba55c12
fix txsim cli
cmwaters Sep 2, 2024
791afc3
checkpoint
cmwaters Sep 3, 2024
6a6ea1f
checkpoint
cmwaters Sep 3, 2024
4858de1
checkpoint
cmwaters Sep 5, 2024
c57acbc
Merge branch 'main' into cal/compact-blocks
cmwaters Sep 5, 2024
d8ade3c
checkpoint
cmwaters Sep 5, 2024
f359e10
checkpoint
cmwaters Sep 6, 2024
7c52cbc
checkpoint
cmwaters Sep 6, 2024
66c2208
checkpoint
cmwaters Sep 6, 2024
2f05007
checkpoint
cmwaters Sep 6, 2024
43ecd7e
checkpoint
cmwaters Sep 9, 2024
d937bd8
update
cmwaters Oct 28, 2024
681e04d
Merge branch 'main' into cal/compact-blocks
cmwaters Nov 1, 2024
86d3e0d
Merge branch 'main' into cal/compact-blocks
cmwaters Nov 1, 2024
0e61251
converge a little closer to main
cmwaters Nov 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/ante/msg_gatekeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ func (mgk MsgVersioningGateKeeper) hasInvalidMsg(ctx sdk.Context, acceptedMsgs m
}

func (mgk MsgVersioningGateKeeper) IsAllowed(ctx context.Context, msgName string) (bool, error) {
appVersion := sdk.UnwrapSDKContext(ctx).BlockHeader().Version.App
sdkCtx := sdk.UnwrapSDKContext(ctx)
appVersion := sdkCtx.BlockHeader().Version.App
acceptedMsgs, exists := mgk.acceptedMsgs[appVersion]
if !exists {
return false, sdkerrors.ErrNotSupported.Wrapf("app version %d is not supported", appVersion)
return false, sdkerrors.ErrNotSupported.Wrapf("circuit breaker: app version %d is not supported", appVersion)
}
_, exists = acceptedMsgs[msgName]
if !exists {
Expand Down
1 change: 0 additions & 1 deletion app/grpc/tx/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func (s *txServer) TxStatus(ctx context.Context, req *TxStatusRequest) (*TxStatu
Height: resTx.Height,
Index: resTx.Index,
ExecutionCode: resTx.ExecutionCode,
Error: resTx.Error,
Status: resTx.Status,
}, nil
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ require (
github.com/cosmos/ledger-cosmos-go v0.13.2 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
Expand Down Expand Up @@ -260,5 +259,6 @@ replace (
github.com/cosmos/ledger-cosmos-go => github.com/cosmos/ledger-cosmos-go v0.12.4
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.43.0-tm-v0.34.35
//v1.39.0-tm-v0.34.29
github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.43.0-tm-v0.34.35.0.20241028112242-a31a8fe76311
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ github.com/celestiaorg/bittwister v0.0.0-20231213180407-65cdbaf5b8c7 h1:nxplQi8w
github.com/celestiaorg/bittwister v0.0.0-20231213180407-65cdbaf5b8c7/go.mod h1:1EF5MfOxVf0WC51Gb7pJ6bcZxnXKNAf9pqWtjgPBAYc=
github.com/celestiaorg/blobstream-contracts/v3 v3.1.0 h1:h1Y4V3EMQ2mFmNtWt2sIhZIuyASInj1a9ExI8xOsTOw=
github.com/celestiaorg/blobstream-contracts/v3 v3.1.0/go.mod h1:x4DKyfKOSv1ZJM9NwV+Pw01kH2CD7N5zTFclXIVJ6GQ=
github.com/celestiaorg/celestia-core v1.43.0-tm-v0.34.35 h1:L4GTm+JUXhB0a/nGPMq6jEqqe6THuYSQ8m2kUCtZYqw=
github.com/celestiaorg/celestia-core v1.43.0-tm-v0.34.35/go.mod h1:bFr0lAGwaJ0mOHSBmib5/ca5pbBf1yKWGPs93Td0HPw=
github.com/celestiaorg/celestia-core v1.43.0-tm-v0.34.35.0.20241028112242-a31a8fe76311 h1:h5DHE1WwvQnbP9u6REwZN6TAEWtQTomEnqy4Yl90DLw=
github.com/celestiaorg/celestia-core v1.43.0-tm-v0.34.35.0.20241028112242-a31a8fe76311/go.mod h1:bFr0lAGwaJ0mOHSBmib5/ca5pbBf1yKWGPs93Td0HPw=
github.com/celestiaorg/cosmos-sdk v1.25.0-sdk-v0.46.16 h1:f+fTe7GGk0/qgdzyqB8kk8EcDf9d6MC22khBTQiDXsU=
github.com/celestiaorg/cosmos-sdk v1.25.0-sdk-v0.46.16/go.mod h1:07Z8HJqS8Rw4XlZ+ok3D3NM/X/in8mvcGLvl0Zb5wrA=
github.com/celestiaorg/go-square v1.1.1 h1:Cy3p8WVspVcyOqHM8BWFuuYPwMitO1pYGe+ImILFZRA=
Expand Down
58 changes: 30 additions & 28 deletions pkg/user/tx_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,37 +433,39 @@ func (client *TxClient) ConfirmTx(ctx context.Context, txHash string) (*TxRespon
return nil, err
}

switch resp.Status {
case core.TxStatusPending:
// Continue polling if the transaction is still pending
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-pollTicker.C:
continue
}
case core.TxStatusCommitted:
txResponse := &TxResponse{
Height: resp.Height,
TxHash: txHash,
Code: resp.ExecutionCode,
}
if resp.ExecutionCode != abci.CodeTypeOK {
executionErr := &ExecutionError{
TxHash: txHash,
Code: resp.ExecutionCode,
ErrorLog: resp.Error,
if resp != nil {
switch resp.Status {
case core.TxStatusPending:
// Continue polling if the transaction is still pending
select {
case <-ctx.Done():
return nil, ctx.Err()
case <-pollTicker.C:
continue
}
case core.TxStatusCommitted:
txResponse := &TxResponse{
Height: resp.Height,
TxHash: txHash,
Code: resp.ExecutionCode,
}
if resp.ExecutionCode != abci.CodeTypeOK {
executionErr := &ExecutionError{
TxHash: txHash,
Code: resp.ExecutionCode,
ErrorLog: resp.Error,
}
client.deleteFromTxTracker(txHash)
return nil, executionErr
}
client.deleteFromTxTracker(txHash)
return txResponse, nil
case core.TxStatusEvicted:
return nil, client.handleEvictions(txHash)
default:
client.deleteFromTxTracker(txHash)
return nil, executionErr
return nil, fmt.Errorf("transaction with hash %s not found; it was likely rejected", txHash)
}
client.deleteFromTxTracker(txHash)
return txResponse, nil
case core.TxStatusEvicted:
return nil, client.handleEvictions(txHash)
default:
client.deleteFromTxTracker(txHash)
return nil, fmt.Errorf("transaction with hash %s not found; it was likely rejected", txHash)
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion test/cmd/txsim/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
pollTime time.Duration
send, sendIterations, sendAmount int
stake, stakeValue, blob int
useFeegrant, suppressLogs bool
useFeegrant, suppressLogs, ignoreFailures bool
upgradeSchedule string
blobShareVersion int
)
Expand Down Expand Up @@ -177,6 +177,10 @@ well funded account that can act as the master account. The command runs until a
opts.SuppressLogs()
}

if ignoreFailures {
opts.IgnoreFailures()
}

encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
err = txsim.Run(
cmd.Context(),
Expand Down Expand Up @@ -215,6 +219,7 @@ func flags() *flag.FlagSet {
flags.StringVar(&blobSizes, "blob-sizes", "100-1000", "range of blob sizes to send")
flags.StringVar(&blobAmounts, "blob-amounts", "1", "range of blobs per PFB specified as a single value or a min-max range (e.g., 10 or 5-10). A single value indicates the exact number of blobs to be created.")
flags.BoolVar(&useFeegrant, "feegrant", false, "use the feegrant module to pay for fees")
flags.BoolVar(&ignoreFailures, "ignore-failures", false, "ignore failures")
flags.BoolVar(&suppressLogs, "suppressLogs", false, "disable logging")
flags.IntVar(&blobShareVersion, "blob-share-version", -1, "optionally specify a share version to use for the blob sequences")
return flags
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/benchmark/throughput.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TwoNodeSimple(logger *log.Logger) error {
ValidatorResource: testnet.DefaultResources,
TxClientsResource: testnet.DefaultResources,
SelfDelegation: 10000000,
CelestiaAppVersion: latestVersion,
CelestiaAppVersion: "6f334a2",
TxClientVersion: testnet.TxsimVersion,
EnableLatency: false,
LatencyParams: LatencyParams{70, 0}, // in milliseconds
Expand All @@ -76,15 +76,15 @@ func TwoNodeSimple(logger *log.Logger) error {
PerPeerBandwidth: 5 * testnet.MB,
UpgradeHeight: 0,
TimeoutCommit: 1 * time.Second,
TimeoutPropose: 1 * time.Second,
Mempool: "v1",
TimeoutPropose: 5 * time.Second,
Mempool: "v2",
BroadcastTxs: true,
Prometheus: true,
GovMaxSquareSize: appconsts.DefaultGovMaxSquareSize,
MaxBlockBytes: appconsts.DefaultMaxBytes,
LocalTracingType: "local",
PushTrace: false,
DownloadTraces: false,
PushTrace: true,
DownloadTraces: true,
TestDuration: 3 * time.Minute,
TxClients: 2,
DisableBBR: true,
Expand Down
178 changes: 178 additions & 0 deletions test/e2e/experiment/compact_blocks/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
package main

import (
"context"
"fmt"
"log"
"strings"
"time"

"github.com/celestiaorg/celestia-app/v3/app"
"github.com/celestiaorg/celestia-app/v3/app/encoding"
"github.com/celestiaorg/celestia-app/v3/test/e2e/testnet"
"github.com/celestiaorg/celestia-app/v3/test/util/genesis"
blobtypes "github.com/celestiaorg/celestia-app/v3/x/blob/types"
"github.com/celestiaorg/knuu/pkg/knuu"
"github.com/tendermint/tendermint/config"

"github.com/tendermint/tendermint/pkg/trace"
"github.com/tendermint/tendermint/pkg/trace/schema"
)

const (
compactBlocksVersion = "70e7354"
)

func main() {
if err := Run(); err != nil {
log.Fatalf("failed to run experiment: %v", err)
}
}

func Run() error {
const (
nodes = 8
timeoutCommit = 3 * time.Second
timeoutPropose = 4 * time.Second
version = compactBlocksVersion
timeFormat = "20060102_150405"
)

blobParams := blobtypes.DefaultParams()
// set the square size to 128
blobParams.GovMaxSquareSize = 128
ecfg := encoding.MakeConfig(app.ModuleBasics)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

identifier := fmt.Sprintf("%s_%s", "compact-blocks", time.Now().Format(timeFormat))
kn, err := knuu.New(ctx, knuu.Options{
Scope: identifier,
ProxyEnabled: true,
})
testnet.NoError("failed to initialize Knuu", err)

network, err := testnet.New(kn, testnet.Options{
GenesisModifiers: []genesis.Modifier{
genesis.SetBlobParams(ecfg.Codec, blobParams),
},
ChainID: identifier,
})
if err != nil {
return err
}
defer network.Cleanup(ctx)

cparams := app.DefaultConsensusParams()
cparams.Block.MaxBytes = 8 * 1024 * 1024
network.SetConsensusParams(cparams)

err = network.CreateGenesisNodes(ctx, nodes, version, 10000000, 0, testnet.DefaultResources, true)
if err != nil {
return err
}

gRPCEndpoints, err := network.RemoteGRPCEndpoints(ctx)
if err != nil {
return err
}

err = network.CreateTxClients(
ctx,
compactBlocksVersion,
40,
"128000-256000",
1,
testnet.DefaultResources,
gRPCEndpoints[:2],
map[int64]uint64{},
)
if err != nil {
return err
}

log.Printf("Setting up network\n")
err = network.Setup(
ctx,
testnet.WithTimeoutCommit(timeoutCommit),
testnet.WithTimeoutPropose(timeoutPropose),
testnet.WithMempool("v2"),
func(cfg *config.Config) {
// create a partially connected network by only dialing 5 peers
cfg.P2P.MaxNumOutboundPeers = 3
cfg.P2P.MaxNumInboundPeers = 4
cfg.Mempool.MaxTxsBytes = 100 * 1024 * 1024
cfg.Instrumentation.TraceType = "local"
cfg.Instrumentation.TracingTables = strings.Join([]string{
schema.RoundStateTable,
schema.BlockTable,
schema.ProposalTable,
schema.CompactBlockTable,
schema.MempoolRecoveryTable,
}, ",")
},
)
if err != nil {
return err
}

pushConfig, err := trace.GetPushConfigFromEnv()
if err != nil {
return err
}
log.Print("Setting up trace push config")
for _, node := range network.Nodes() {
if err = node.Instance.Build().SetEnvironmentVariable(trace.PushBucketName, pushConfig.BucketName); err != nil {
return fmt.Errorf("failed to set TRACE_PUSH_BUCKET_NAME: %v", err)
}
if err = node.Instance.Build().SetEnvironmentVariable(trace.PushRegion, pushConfig.Region); err != nil {
return fmt.Errorf("failed to set TRACE_PUSH_REGION: %v", err)
}
if err = node.Instance.Build().SetEnvironmentVariable(trace.PushAccessKey, pushConfig.AccessKey); err != nil {
return fmt.Errorf("failed to set TRACE_PUSH_ACCESS_KEY: %v", err)
}
if err = node.Instance.Build().SetEnvironmentVariable(trace.PushKey, pushConfig.SecretKey); err != nil {
return fmt.Errorf("failed to set TRACE_PUSH_SECRET_KEY: %v", err)
}
if err = node.Instance.Build().SetEnvironmentVariable(trace.PushDelay, fmt.Sprintf("%d", pushConfig.PushDelay)); err != nil {
return fmt.Errorf("failed to set TRACE_PUSH_DELAY: %v", err)
}
}

log.Printf("Starting network\n")
err = network.Start(ctx)
if err != nil {
return err
}

// run the test for 5 minutes
heightTicker := time.NewTicker(20 * time.Second)
timeout := time.NewTimer(5 * time.Minute)
client, err := network.Node(0).Client()
if err != nil {
return err
}
log.Println("--- RUNNING TESTNET")
for {
select {
case <-heightTicker.C:
status, err := client.Status(context.Background())
if err != nil {
log.Printf("Error getting status: %v", err)
continue
}
log.Printf("Height: %v", status.SyncInfo.LatestBlockHeight)

case <-timeout.C:
log.Println("--- COLLECTING DATA")
file := "/Users/callum/Developer/go/src/github.com/celestiaorg/big-blocks-research/traces"
if err := trace.S3Download(file, identifier, pushConfig, schema.RoundStateTable, schema.BlockTable, schema.ProposalTable, schema.CompactBlockTable, schema.MempoolRecoveryTable); err != nil {
return fmt.Errorf("failed to download traces from S3: %w", err)
}

log.Println("--- FINISHED ✅: ChainID: ", identifier)
return nil
}
}
}
Loading
Loading