Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat(sqlite): move fro warp-contracts-lmdb to warp-conracts-sqlite
Browse files Browse the repository at this point in the history
Were seeing state corruption in lmdb implementation. An issue was created with warp-contracts-lmdb, but for now we will migrate to sqlite.
  • Loading branch information
dtfiedler committed Nov 20, 2023
1 parent e528ccc commit 28333d9
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 140 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"lodash": "^4.17.21",
"prom-client": "^14.2.0",
"warp-contracts": "^1.4.22",
"warp-contracts-lmdb": "^1.1.10",
"warp-contracts-sqlite": "^1.0.2",
"winston": "^3.8.2",
"yaml": "^2.3.1"
},
Expand Down
17 changes: 11 additions & 6 deletions src/middleware/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import {
defaultCacheOptions,
} from 'warp-contracts';
import { arweave } from './arweave';
import { LmdbCache } from 'warp-contracts-lmdb';
import { SqliteContractCache } from 'warp-contracts-sqlite';

LoggerFactory.INST.logLevel(
(process.env.WARP_LOG_LEVEL as LogLevel) ?? 'fatal',
);

/**
* TODO: consider using warp-contracts-postgres cache for distribution caching (or EFS with warp-contracts-lmdb or warp-contracts-sqlite)
* TODO: consider using warp-contracts-postgres cache for distributed state caching across instances
*/
const warp = WarpFactory.forMainnet(
{
Expand All @@ -39,10 +39,15 @@ const warp = WarpFactory.forMainnet(
true,
arweave,
).useStateCache(
new LmdbCache(defaultCacheOptions, {
maxEntriesPerContract: 1000,
minEntriesPerContract: 0,
}),
new SqliteContractCache(
{
...defaultCacheOptions,
dbLocation: `./cache/warp/sqlite/state`,
},
{
maxEntriesPerContract: 1000,
},
),
);

export function warpMiddleware(ctx: KoaContext, next: Next) {
Expand Down
Loading

0 comments on commit 28333d9

Please sign in to comment.