Skip to content

Commit

Permalink
Fix encode into stream (#2634)
Browse files Browse the repository at this point in the history
* rebuild tool

* wip

* fix encoded

* linter
  • Loading branch information
ToniRamirezM authored Oct 10, 2023
1 parent 330d9b5 commit f67da72
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/test/contracts/bin/**/*.abi

/tools/datastreamer/*.bin
/test/datastream.bin

**/.DS_Store
.vscode
Expand Down
4 changes: 3 additions & 1 deletion sequencer/dbmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer"
"github.com/0xPolygonHermez/zkevm-node/hex"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/pool"
"github.com/0xPolygonHermez/zkevm-node/state"
Expand Down Expand Up @@ -323,12 +324,13 @@ func (d *dbManager) StoreProcessedTxAndDeleteFromPool(ctx context.Context, tx tr
if err != nil {
return err
}
encoded := hex.EncodeToHex(binaryTxData)

l2Transaction := state.DSL2Transaction{
EffectiveGasPricePercentage: uint8(tx.response.EffectivePercentage),
IsValid: 1,
EncodedLength: uint32(len(binaryTxData)),
Encoded: binaryTxData,
Encoded: []byte(encoded),
}

d.dataToStream <- state.DSL2FullBlock{
Expand Down
16 changes: 12 additions & 4 deletions tools/datastreamer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ check-go:
@which go > /dev/null || (echo "Error: Go is not installed" && exit 1)

# Targets that require the checks
run-tool: check-go
generate-file: check-go

.PHONY: run-tool
run-tool: ## Runs the tool to populate the binary file
go run main.go run -cfg config/tool.config.toml
arguments := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))

.PHONY: generate-file
generate-file: ## Runs the tool to populate the binary file
go run main.go generate -cfg config/tool.config.toml

rebuild: ## Runs the tool to rebuild state roots from a given block
go run main.go rebuild -cfg config/tool.config.toml

decode-entry: ## Runs the tool to decode a given entry number
go run main.go decode -cfg config/tool.config.toml -entry $(arguments)

## Help display.
## Pulls comments from beside commands and prints a nicely formatted
Expand Down
2 changes: 2 additions & 0 deletions tools/datastreamer/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/0xPolygonHermez/zkevm-data-streamer/datastreamer"
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/state/runtime/executor"
"github.com/0xPolygonHermez/zkevm-node/tools/datastreamer/db"
"github.com/mitchellh/mapstructure"
"github.com/spf13/viper"
Expand All @@ -22,6 +23,7 @@ const (
type Config struct {
StreamServer datastreamer.Config `mapstructure:"StreamServer"`
StateDB db.Config `mapstructure:"StateDB"`
Executor executor.Config `mapstructure:"Executor"`
}

// Default parses the default configuration values.
Expand Down
4 changes: 4 additions & 0 deletions tools/datastreamer/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ Host = "localhost"
Port = "5432"
EnableLog = false
MaxConns = 200
[Executor]
URI = "zkevm-prover:50071"
MaxGRPCMessageSize = 100000000
`
10 changes: 7 additions & 3 deletions tools/datastreamer/config/tool.config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

[StreamServer]
Port = 6900
Filename = "streamfile.bin"
Port = 6901
Filename = "datastream.bin"
[StreamServer.Log]
Environment = "development"
Level = "debug"
Level = "info"
Outputs = ["stdout"]

[StateDB]
Expand All @@ -15,3 +15,7 @@ Host = "localhost"
Port = "5432"
EnableLog = false
MaxConns = 200

[Executor]
URI = "zkevm-prover:50071"
MaxGRPCMessageSize = 100000000
Loading

0 comments on commit f67da72

Please sign in to comment.