Skip to content

Commit

Permalink
Update Carmen and fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbertJordan committed Oct 30, 2023
1 parent 959bc57 commit 05d5137
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 109 deletions.
2 changes: 1 addition & 1 deletion carmen
Submodule carmen updated 79 files
+6 −0 .github/workflows/go-osx.yml
+17 −3 .github/workflows/go.yml
+1 −1 go/backend/archive/archive.go
+32 −32 go/backend/archive/archive_test.go
+4 −3 go/backend/archive/benchmark_test.go
+1 −1 go/backend/archive/ldb/archive.go
+1 −1 go/backend/archive/sqlite/archive.go
+1 −1 go/backend/index/file/file.go
+0 −110 go/backend/stock/cache/cache.go
+0 −41 go/backend/stock/cache/cache_test.go
+3 −0 go/backend/stock/file/file.go
+8 −0 go/backend/stock/file/file_test.go
+199 −1 go/backend/stock/file/stack_test.go
+4 −3 go/backend/stock/memory/memory.go
+8 −0 go/backend/stock/memory/memory_test.go
+200 −0 go/backend/stock/stock_fuzzing_utils.go
+9 −0 go/backend/stock/synced/synced_test.go
+16 −4 go/backend/utils/buffered_file.go
+283 −0 go/backend/utils/buffered_file_test.go
+1 −1 go/backend/utils/chunk_reader.go
+2 −59 go/common/cached_hasher.go
+2 −45 go/common/cached_hasher_test.go
+25 −0 go/common/keccak.go
+29 −52 go/common/types.go
+260 −0 go/evmstore/evmstore.go
+145 −0 go/evmstore/evmstore_test.go
+32 −0 go/evmstore/interface.go
+40 −0 go/evmstore/tx_position.go
+35 −0 go/evmstore/tx_position_test.go
+4 −0 go/go.mod
+8 −0 go/go.sum
+5 −0 go/state/go_schema1.go
+5 −0 go/state/go_schema2.go
+5 −0 go/state/go_schema3.go
+2 −2 go/state/go_schema4.go
+2 −2 go/state/go_schema5.go
+18 −5 go/state/go_state.go
+100 −53 go/state/mpt/archive_trie.go
+182 −6 go/state/mpt/archive_trie_test.go
+71 −7 go/state/mpt/config.go
+1 −0 go/state/mpt/doc.go
+241 −68 go/state/mpt/forest.go
+34 −14 go/state/mpt/forest_test.go
+221 −66 go/state/mpt/hasher.go
+4 −3 go/state/mpt/hasher_mocks.go
+51 −23 go/state/mpt/hasher_test.go
+12 −4 go/state/mpt/live_trie.go
+10 −10 go/state/mpt/live_trie_test.go
+68 −0 go/state/mpt/node_path.go
+85 −0 go/state/mpt/node_path_test.go
+449 −48 go/state/mpt/nodes.go
+84 −0 go/state/mpt/nodes_mocks.go
+815 −154 go/state/mpt/nodes_test.go
+20 −0 go/state/mpt/rlp/rlp.go
+11 −11 go/state/mpt/root_hash_test.go
+35 −7 go/state/mpt/state.go
+6 −4 go/state/mpt/state_test.go
+298 −0 go/state/mpt/tool/benchmark.go
+142 −0 go/state/mpt/tool/benchmark_test.go
+53 −0 go/state/mpt/tool/common.go
+39 −0 go/state/mpt/tool/export.go
+44 −0 go/state/mpt/tool/import.go
+104 −0 go/state/mpt/tool/info.go
+261 −0 go/state/mpt/tool/io.go
+79 −0 go/state/mpt/tool/io_test.go
+32 −0 go/state/mpt/tool/main.go
+66 −0 go/state/mpt/tool/verify.go
+199 −39 go/state/mpt/verification.go
+131 −2 go/state/mpt/verification_test.go
+152 −0 go/state/mpt/visitor.go
+48 −0 go/state/mpt/visitor_mocks.go
+82 −0 go/state/mpt/visitor_test.go
+208 −0 go/state/mpt/write_buffer.go
+127 −0 go/state/mpt/write_buffer_mocks.go
+269 −0 go/state/mpt/write_buffer_test.go
+2 −2 go/state/state_configs.go
+4 −4 go/state/state_db.go
+2 −2 go/state/state_db_test.go
+39 −18 go/state/state_test.go
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48
github.com/stretchr/testify v1.8.0
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a
github.com/urfave/cli/v2 v2.24.4
github.com/urfave/cli/v2 v2.25.7
go.uber.org/mock v0.2.0
golang.org/x/text v0.12.0
gonum.org/v1/gonum v0.6.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,9 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU=
github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
Expand Down
68 changes: 34 additions & 34 deletions state/carmen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package state

import (
"bytes"
"fmt"
"errors"
"math/big"
"testing"

Expand All @@ -14,7 +14,7 @@ import (
// TestCarmenState_MakeCarmenStateDBInvalid tests db initialization with invalid Variant
func TestCarmenState_MakeCarmenStateDBInvalid(t *testing.T) {
csDB, err := MakeCarmenStateDB("", "invalid-Variant", "", 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand All @@ -31,9 +31,9 @@ func TestCarmenState_MakeCarmenStateDBInvalid(t *testing.T) {
// TestCarmenState_InitCloseCarmenDB test closing db immediately after initialization
func TestCarmenState_InitCloseCarmenDB(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand All @@ -52,9 +52,9 @@ func TestCarmenState_InitCloseCarmenDB(t *testing.T) {
// TestCarmenState_AccountLifecycle tests account operations - create, check if it exists, if it's empty, suicide and suicide confirmation
func TestCarmenState_AccountLifecycle(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -96,9 +96,9 @@ func TestCarmenState_AccountLifecycle(t *testing.T) {
// TestCarmenState_AccountBalanceOperations tests balance operations - add, subtract and check if the value is correct
func TestCarmenState_AccountBalanceOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -143,9 +143,9 @@ func TestCarmenState_AccountBalanceOperations(t *testing.T) {
// TestCarmenState_NonceOperations tests account nonce updating
func TestCarmenState_NonceOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -180,9 +180,9 @@ func TestCarmenState_NonceOperations(t *testing.T) {
// TestCarmenState_CodeOperations tests account code updating
func TestCarmenState_CodeOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -225,9 +225,9 @@ func TestCarmenState_CodeOperations(t *testing.T) {
// TestCarmenState_StateOperations tests account state update
func TestCarmenState_StateOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -263,9 +263,9 @@ func TestCarmenState_StateOperations(t *testing.T) {
// TestCarmenState_TrxBlockSyncPeriodOperations tests creation of randomized sync-periods with blocks and transactions
func TestCarmenState_TrxBlockSyncPeriodOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -308,9 +308,9 @@ func TestCarmenState_TrxBlockSyncPeriodOperations(t *testing.T) {
// TestCarmenState_RefundOperations tests adding and subtracting refund value
func TestCarmenState_RefundOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -347,9 +347,9 @@ func TestCarmenState_RefundOperations(t *testing.T) {
// TestCarmenState_AccessListOperations tests operations with creating, updating a checking AccessList
func TestCarmenState_AccessListOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -447,10 +447,10 @@ func TestCarmenState_GetArchiveState(t *testing.T) {
if tc.Archive != "sqlite" && tc.Archive != "leveldb" {
continue // relevant only if the Archive is enabled
}
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
tempDir := t.TempDir()
csDB, err := MakeCarmenStateDB(tempDir, tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -505,9 +505,9 @@ func TestCarmenState_GetArchiveState(t *testing.T) {
// TestCarmenState_SetBalanceUsingBulkInsertion tests setting an accounts balance
func TestCarmenState_SetBalanceUsingBulkInsertion(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -547,9 +547,9 @@ func TestCarmenState_SetBalanceUsingBulkInsertion(t *testing.T) {
// TestCarmenState_SetNonceUsingBulkInsertion tests setting an accounts nonce
func TestCarmenState_SetNonceUsingBulkInsertion(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -590,9 +590,9 @@ func TestCarmenState_SetNonceUsingBulkInsertion(t *testing.T) {
// TestCarmenState_SetStateUsingBulkInsertion tests setting an accounts state
func TestCarmenState_SetStateUsingBulkInsertion(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -635,9 +635,9 @@ func TestCarmenState_SetStateUsingBulkInsertion(t *testing.T) {
// TestCarmenState_SetCodeUsingBulkInsertion tests setting an accounts code
func TestCarmenState_SetCodeUsingBulkInsertion(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -679,9 +679,9 @@ func TestCarmenState_SetCodeUsingBulkInsertion(t *testing.T) {
// TestCarmenState_BulkloadOperations tests multiple operation in one bulkload
func TestCarmenState_BulkloadOperations(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down Expand Up @@ -753,9 +753,9 @@ func TestCarmenState_BulkloadOperations(t *testing.T) {

func TestCarmenState_GetShadowDB(t *testing.T) {
for _, tc := range GetCarmenStateTestCases() {
t.Run(fmt.Sprintf("DB Variant: %s, Archive type: %v", tc.Variant, tc.Archive), func(t *testing.T) {
t.Run(tc.String(), func(t *testing.T) {
csDB, err := MakeCarmenStateDB(t.TempDir(), tc.Variant, tc.Archive, 1)
if _, ok := err.(carmen.UnsupportedConfiguration); ok {
if errors.Is(err, carmen.UnsupportedConfiguration) {
t.Skip("unsupported configuration")
}

Expand Down
23 changes: 15 additions & 8 deletions state/carmen_test_enviroment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package state

import (
"fmt"
"math/rand"
"testing"
"time"
Expand All @@ -10,15 +11,15 @@ import (

type CarmenStateTestCase struct {
Variant string
Schema int
Archive string
}

func GetCarmenStateTestCases() []CarmenStateTestCase {
variants := []string{""}
for _, variant := range carmen.GetAllVariants() {
variants = append(variants, string(variant))
}
func (c CarmenStateTestCase) String() string {
return fmt.Sprintf("DB Variant: %s, Schema: %d, Archive type: %v", c.Variant, c.Schema, c.Archive)
}

func GetCarmenStateTestCases() []CarmenStateTestCase {
archives := []string{
"none",
"leveldb",
Expand All @@ -29,9 +30,15 @@ func GetCarmenStateTestCases() []CarmenStateTestCase {

var testCases []CarmenStateTestCase

for _, variant := range variants {
for _, archive := range archives {
testCases = append(testCases, CarmenStateTestCase{Variant: variant, Archive: archive})
for _, variant := range carmen.GetAllVariants() {
for _, schema := range carmen.GetAllSchemas() {
for _, archive := range archives {
testCases = append(testCases, CarmenStateTestCase{
Variant: string(variant),
Schema: int(schema),
Archive: archive,
})
}
}
}

Expand Down
12 changes: 5 additions & 7 deletions state/proxy/shadow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proxy

import (
"bytes"
"errors"
"fmt"
"log"
"math/big"
Expand Down Expand Up @@ -406,13 +407,10 @@ func (l *shadowBulkLoad) SetCode(addr common.Address, code []byte) {
}

func (l *shadowBulkLoad) Close() error {
if err := l.prime.Close(); err != nil {
return err
}
if err := l.shadow.Close(); err != nil {
return err
}
return nil
return errors.Join(
l.prime.Close(),
l.shadow.Close(),
)
}

func (s *shadowVmStateDb) run(opName string, op func(s state.VmStateDB)) {
Expand Down
Loading

0 comments on commit 05d5137

Please sign in to comment.