Skip to content

Commit

Permalink
added engine v2
Browse files Browse the repository at this point in the history
ripping old engine out

replaced old engine

removed parse references

fixed lint issues

delete testdata

fix parse
  • Loading branch information
brennanjl committed Dec 18, 2024
1 parent c37fc0c commit a2a2d11
Show file tree
Hide file tree
Showing 158 changed files with 32,490 additions and 37,019 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ jobs:
- name: Compile packages, apps, and specs
run: |
go build -mod=readonly ./... ./core/... ./parse/...
go build -mod=readonly ./... ./core/...
- name: Lint
uses: golangci/golangci-lint-action@v6.1.1
with:
install-mode: "binary"
version: "latest"
args: ./... ./core/... ./parse/... --timeout=10m --config=.golangci.yml
args: ./... ./core/... --timeout=10m --config=.golangci.yml

# unit test
- name: Run unit test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ jobs:
- name: Compile packages, apps, and specs
run: |
go build -mod=readonly ./... ./core/... ./parse/... ./test/specifications/
go build -mod=readonly ./... ./core/... ./test/specifications/
- name: Lint
uses: golangci/golangci-lint-action@v6.1.0
with:
install-mode: "binary"
version: "latest"
args: ./... ./core/... ./parse/... ./test/... --timeout=10m --config=.golangci.yml
args: ./... ./core/... ./test/... --timeout=10m --config=.golangci.yml

# unit test
- name: Run unit test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/kgw-test-reuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:

- name: Init workspace
run: |
go work init . ./test ./parse ./core
go work init . ./test ./core
- name: Generate go vendor
run: |
Expand Down
13 changes: 2 additions & 11 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tasks:

work:
cmds:
- cmd: go work init . ./core ./parse
- cmd: go work init . ./core
ignore_error: true
generates:
- go.work
Expand All @@ -25,7 +25,7 @@ tasks:
# so we have to list all the folders that are adjacent generated code.
- |
goimports -format-only -w ./app ./cmd ./common ./core ./node ./testing \
./extensions ./parse/*.go ./parse/wasm ./parse/postgres
./extensions
tidy:
desc: go mod tidy each module
Expand Down Expand Up @@ -77,13 +77,6 @@ tasks:
- go run ./cmd/kwild/generate -out ./gen
- go run ./cmd/kwil-cli/generate -out ./gen

kuneiform:wasm:
desc: Build the kuneiform wasm
cmds:
- rm -rf ./parse/wasm/*.{wasm,tar.gz}
- go generate ./parse/wasm/wasm.go
- tar -czvf ./parse/wasm/kuneiform_wasm.tar.gz ./parse/wasm/kuneiform.wasm

kuneiform:grammar:
desc: Generate kuneiform grammar go code.
cmds:
Expand Down Expand Up @@ -230,14 +223,12 @@ tasks:
desc: Run unit tests
cmds:
- go test ./core/... -tags=ext_test -count=1
- CGO_ENABLED=1 go test ./parse/... -tags=ext_test -count=1
- CGO_ENABLED=1 go test ./... -tags=ext_test,pglive -count=1 -p=1 # no parallel for now because several try to use one pg database

test:unit:race:
desc: Run unit tests with the race detector
cmds:
- go test ./core/... -tags=ext_test -count=1 -race
- CGO_ENABLED=1 go test ./parse/... -tags=ext_test -count=1 -race
- CGO_ENABLED=1 go test ./... -tags=ext_test,pglive -count=1 -race

# test:it:
Expand Down
4 changes: 2 additions & 2 deletions _previous/core/types/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ func (c *DataType) PGString() (string, error) {
scalar = "UINT256"
case DecimalStr:
if c.Metadata == ZeroMetadata {
return "", fmt.Errorf("decimal type must have metadata")
return "NUMERIC", nil
}

scalar = fmt.Sprintf("NUMERIC(%d,%d)", c.Metadata[0], c.Metadata[1])
Expand Down Expand Up @@ -1171,7 +1171,7 @@ func (c *DataType) Clean() error {
return nil
case DecimalStr:
if c.Metadata == ZeroMetadata {
return fmt.Errorf("decimal type must have metadata")
return nil
}

err := decimal.CheckPrecisionAndScale(c.Metadata[0], c.Metadata[1])
Expand Down
16 changes: 5 additions & 11 deletions app/node/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/kwilteam/kwil-db/node/accounts"
blockprocessor "github.com/kwilteam/kwil-db/node/block_processor"
"github.com/kwilteam/kwil-db/node/consensus"
"github.com/kwilteam/kwil-db/node/engine/execution"
"github.com/kwilteam/kwil-db/node/engine/interpreter"
"github.com/kwilteam/kwil-db/node/listeners"
"github.com/kwilteam/kwil-db/node/mempool"
"github.com/kwilteam/kwil-db/node/meta"
Expand Down Expand Up @@ -346,7 +346,7 @@ func (c *coreDependencies) service(loggerName string) *common.Service {
}

func buildTxApp(ctx context.Context, d *coreDependencies, db *pg.DB, accounts *accounts.Accounts,
votestore *voting.VoteStore, engine *execution.GlobalContext) *txapp.TxApp {
votestore *voting.VoteStore, engine common.Engine) *txapp.TxApp {
signer := auth.GetNodeSigner(d.privKey)

txapp, err := txapp.NewTxApp(ctx, db, engine, signer, nil, d.service("TxAPP"), accounts, votestore)
Expand Down Expand Up @@ -472,7 +472,7 @@ func failBuild(err error, msg string) {
})
}

func buildEngine(d *coreDependencies, db *pg.DB) *execution.GlobalContext {
func buildEngine(d *coreDependencies, db *pg.DB) *interpreter.ThreadSafeInterpreter {
extensions := precompiles.RegisteredPrecompiles()
for name := range extensions {
d.logger.Info("registered extension", "name", name)
Expand All @@ -484,23 +484,17 @@ func buildEngine(d *coreDependencies, db *pg.DB) *execution.GlobalContext {
}
defer tx.Rollback(d.ctx)

err = execution.InitializeEngine(d.ctx, tx)
interp, err := interpreter.NewInterpreter(d.ctx, tx, d.service("engine"))
if err != nil {
failBuild(err, "failed to initialize engine")
}

eng, err := execution.NewGlobalContext(d.ctx, tx,
extensions, d.newService("engine"))
if err != nil {
failBuild(err, "failed to build engine")
}

err = tx.Commit(d.ctx)
if err != nil {
failBuild(err, "failed to commit engine init db txn")
}

return eng
return interp
}

func buildSnapshotStore(d *coreDependencies) *snapshotter.SnapshotStore {
Expand Down
11 changes: 0 additions & 11 deletions app/node/deps.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"slices"

"github.com/kwilteam/kwil-db/common"
"github.com/kwilteam/kwil-db/config"
"github.com/kwilteam/kwil-db/core/crypto"
"github.com/kwilteam/kwil-db/core/log"
Expand Down Expand Up @@ -72,16 +71,6 @@ type coreDependencies struct {
poolOpener poolOpener
}

// newService returns a common.Service with the given logger name
func (c *coreDependencies) newService(loggerName string) *common.Service {
return &common.Service{
Logger: c.logger.New(loggerName),
GenesisConfig: c.genesisCfg,
LocalConfig: c.cfg,
Identity: c.privKey.Public().Bytes(),
}
}

// closeFuncs holds a list of closers
// it is used to close all resources on shutdown
type closeFuncs struct {
Expand Down
1 change: 0 additions & 1 deletion app/shared/display/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"github.com/kwilteam/kwil-db/core/crypto/auth"
"github.com/kwilteam/kwil-db/core/types"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
Loading

0 comments on commit a2a2d11

Please sign in to comment.