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

Trivial Cross-network SPV PoC #1628

Draft
wants to merge 110 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
78a7a02
check
edmundnoble Mar 1, 2023
b4b9d3c
add test registry
edmundnoble Mar 1, 2023
6bc4aac
re-run ea and fix tests
edmundnoble Mar 2, 2023
75040d2
clear up some todos
edmundnoble Mar 2, 2023
0519d27
Removals
edmundnoble Mar 2, 2023
932ebd3
Fix build
edmundnoble Mar 2, 2023
ddacf98
fix haddock
edmundnoble Mar 2, 2023
4675df6
Fix build add docs
edmundnoble Mar 2, 2023
9f2d4af
fix haddock again
edmundnoble Mar 2, 2023
1257d89
Fix other warnings
edmundnoble Mar 2, 2023
f529bae
Eq for upgrades
edmundnoble Mar 2, 2023
b003881
Merge branch 'master' into edmundnoble/version-scourge
edmundnoble Mar 2, 2023
067831e
Move maxBlockGasLimit
edmundnoble Mar 3, 2023
96d062b
Delete old testnet history case in ExecBlock
edmundnoble Mar 3, 2023
694f21a
Update Utils.hs
edmundnoble Mar 3, 2023
0499683
Update chainweb.cabal
edmundnoble Mar 3, 2023
7b5334f
Remove distributive and adjunctions deps
edmundnoble Mar 3, 2023
3058250
Remove memotrie dep
edmundnoble Mar 3, 2023
c5c958e
Remove errors dep from cwtool
edmundnoble Mar 3, 2023
9b26031
Reorder some declarations around makeLenses
edmundnoble Mar 3, 2023
c08bda2
fix bench
edmundnoble Mar 3, 2023
d3ce263
Disable POW by default in devnet, but allow enabling it
edmundnoble Mar 3, 2023
c6792ba
Remove quotes from Show ChainwebVersionName
edmundnoble Mar 3, 2023
9231761
enable pow by default on Development
edmundnoble Mar 3, 2023
63c1bcf
Revert some guard heights for devnet, add HasCallStack to some places…
edmundnoble Mar 3, 2023
2fad259
Make upgrades coinv3-coinv5 precocious on devnet
edmundnoble Mar 3, 2023
6893dd8
Merge remote-tracking branch 'origin/edmundnoble/version-scourge' int…
edmundnoble Mar 3, 2023
6c51702
More cleanup
edmundnoble Mar 4, 2023
479c19e
delete stm-chans dep
edmundnoble Mar 4, 2023
edc25e5
Reorder forks according to order of mainnet appearance
edmundnoble Mar 4, 2023
a517a11
cleanup and docs
edmundnoble Mar 5, 2023
9280308
Comment Chainweb.Version.Guards
edmundnoble Mar 5, 2023
b954830
Start doing DA during tests
edmundnoble Mar 5, 2023
b23d198
self-review
edmundnoble Mar 5, 2023
48f6f09
More self-review
edmundnoble Mar 5, 2023
a78353f
changes from code review
larskuhtz Mar 9, 2023
8951c52
split VersionCheats to add VersionDefaults
edmundnoble Mar 9, 2023
c09db18
remove redundant pragma
larskuhtz Mar 10, 2023
23dd634
Specific memoization for mainnet and testnet genesis headers
edmundnoble Mar 13, 2023
db579b5
instance HasChainwebVersion ChainwebVersionCode
edmundnoble Mar 13, 2023
5c73a90
small changes from review
larskuhtz Mar 15, 2023
15ef99d
Change forks and upgrades for barebonesTestVersion
edmundnoble Mar 15, 2023
6895725
More docs and better TestVersions
edmundnoble Mar 15, 2023
d3025e5
Small fork height tweaks
edmundnoble Mar 15, 2023
217d54d
profiling enabled
edmundnoble Mar 15, 2023
80bbfe7
fix tests
edmundnoble Mar 15, 2023
7e15596
Hahahahahaha wow. Fix dumb performance glitch
edmundnoble Mar 15, 2023
ed94cc3
disable profiling
edmundnoble Mar 15, 2023
d375059
Use ChainwebVersionName in CutHashes
edmundnoble Mar 16, 2023
750fbe0
Merge branch 'master' into edmundnoble/version-scourge
edmundnoble Mar 17, 2023
c0f14f7
Enable profiling
edmundnoble Mar 17, 2023
c694a40
Revert "Enable profiling"
edmundnoble Mar 17, 2023
08e08ae
fix version configuration and validation
edmundnoble Mar 24, 2023
d1556c4
check
edmundnoble Mar 29, 2023
4376642
SPV PoC with creation and verification
edmundnoble Apr 12, 2023
a66c3d6
Fix tests
edmundnoble Apr 12, 2023
44ae9c8
fix build
edmundnoble Apr 12, 2023
374a194
Merge branch 'edmund/fast-devnet' into edmund/l2-spv-poc
edmundnoble Apr 12, 2023
c85a993
Move upgrades to after 20 chain move
edmundnoble Apr 12, 2023
63761fd
Merge branch 'edmund/fast-devnet' into edmund/l2-spv-poc
edmundnoble Apr 12, 2023
63c0922
Move upgrades to after 20 chain move
edmundnoble Apr 12, 2023
9cf0b84
Merge branch 'edmund/fast-devnet' into edmund/l2-spv-poc
edmundnoble Apr 12, 2023
28897e0
NSv2 in fast devnet
edmundnoble Apr 13, 2023
62a5038
Merge branch 'edmund/fast-devnet' into edmund/l2-spv-poc
edmundnoble Apr 13, 2023
f28a0ef
Delete extra bang pattern in CreateProof
edmundnoble Apr 14, 2023
3396134
Fix verifyTransactionOutputProofat_
edmundnoble Apr 17, 2023
b8952a4
Fix target chain encoding, change pact pin (stop checking yield prove…
edmundnoble Apr 17, 2023
ecc0463
Disable max block gas limit in fast devnet
edmundnoble Apr 19, 2023
4303d4f
Merge branch 'edmund/fast-devnet' into edmund/l2-spv-poc
edmundnoble Apr 19, 2023
f05e411
Merge remote-tracking branch 'origin/edmund/l2-spv-poc' into edmund/l…
edmundnoble Apr 19, 2023
175e0ca
Merge branch 'master' into edmund/l2-spv-poc
chessai Aug 2, 2023
0ee5acf
update pact pin
chessai Aug 2, 2023
36942c3
fix some compilation errors
chessai Aug 2, 2023
96ddc3d
Fix type error in Pact.RestAPI.Server
enobayram Aug 8, 2023
9e673cc
Remove duplicate defs in Chainweb.Test.Utils
enobayram Aug 8, 2023
0e09db5
Merge branch 'master' into edmund/l2-spv-poc
chessai Aug 16, 2023
d3ffd0c
update pact pin
chessai Aug 16, 2023
73d6770
fix output proof checking in SPV and crossnet
chessai Aug 16, 2023
b413a5c
Merge branch 'master' into edmund/l2-spv-poc
enobayram Aug 30, 2023
b729fcd
Pin latest pact/edmund/l2-spv-poc
enobayram Aug 31, 2023
cc3888c
Merge branch 'master' into edmund/l2-spv-poc
enobayram Oct 9, 2023
5fd6c95
Disable keyset format validation
EnoF Oct 24, 2023
b8b7c3e
Merge branch 'feat/disable-keyset-validation' into edmund/l2-spv-poc
EnoF Oct 24, 2023
b63156b
Some yolo fix
EnoF Oct 24, 2023
1426b92
wip command verifier
imalsogreg Nov 8, 2023
d970619
Thread KeysetPublicKey through chainweb
imalsogreg Nov 8, 2023
4bd97c1
Migrate to KeysetPublicKey in tests
imalsogreg Nov 8, 2023
9bbafb8
Work the validateCommand function with chainid and version through more
imalsogreg Nov 8, 2023
9eb1b57
Merge remote-tracking branch 'origin/mlep/webauthn-jwk-formats' into …
edmundnoble Nov 9, 2023
62d3270
Update pact
edmundnoble Nov 9, 2023
95563b1
Revert KeysetPublicKey
edmundnoble Nov 9, 2023
62c9a99
Work the validateCommand function with chainid and version through more
imalsogreg Nov 8, 2023
7433e75
fix tests
edmundnoble Nov 9, 2023
a0428f6
Update pact
edmundnoble Nov 9, 2023
f4b6260
Revert KeysetPublicKey
edmundnoble Nov 9, 2023
6d5a402
fix tests
edmundnoble Nov 9, 2023
70f5f20
Merge branch 'mlep/webauthn-jwk-formats' into HEAD
edmundnoble Nov 9, 2023
90b8397
Update git sha for pact
imalsogreg Nov 9, 2023
4d4e243
Update git sha for pact
imalsogreg Nov 9, 2023
6f355d6
supply argument to enforceKeyFormats
imalsogreg Nov 9, 2023
979baf8
supply argument to enforceKeyFormats
imalsogreg Nov 9, 2023
87eaeea
Fix cwtool
edmundnoble Nov 10, 2023
5abe334
Add chainweb222Pact fork
edmundnoble Nov 10, 2023
a075f10
Fix tests
edmundnoble Nov 10, 2023
dd93343
Update pact
edmundnoble Nov 13, 2023
30c4b03
Merge branch 'mlep/webauthn-jwk-formats' into edmund/l2-spv-poc
edmundnoble Nov 13, 2023
92c1c75
Fix tests
edmundnoble Nov 13, 2023
9eee09e
Merge branch 'mlep/webauthn-jwk-formats' into edmund/l2-spv-poc
edmundnoble Nov 13, 2023
e6544a0
Update cabal.project
enobayram Nov 13, 2023
5cde2fd
Merge branch 'master' into edmund/l2-spv-poc
enobayram Dec 4, 2023
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: 5 additions & 0 deletions bench/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ import qualified Chainweb.Pact.Backend.ForkingBench as ForkingBench
import qualified JSONEncoding

import Chainweb.Storage.Table.RocksDB
import Chainweb.Version.Development
import Chainweb.Version.FastDevelopment
import Chainweb.Version.Registry

main :: IO ()
main = withTempRocksDb "benchmarks" $ \rdb -> do
registerVersion Development
registerVersion FastDevelopment
defaultMain
[ Checkpointer.bench
, ForkingBench.bench rdb
Expand Down
4 changes: 3 additions & 1 deletion bench/Chainweb/Pact/Backend/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ import qualified Pact.Types.SQLite as PSQL
-- chainweb imports

import Chainweb.BlockHash
import Chainweb.BlockHeader
import Chainweb.BlockHeight
import Chainweb.Graph
import Chainweb.MerkleLogHash
import Chainweb.Pact.Backend.RelationalCheckpointer
import Chainweb.Pact.Backend.Types
import Chainweb.Pact.Backend.Utils
import Chainweb.Pact.Types
import Chainweb.Test.TestVersions
import Chainweb.Utils.Bench
import Chainweb.Utils (sshow)
import Chainweb.Version

v :: ChainwebVersion
v = FastTimedCPM petersonChainGraph
v = fastForkingCpmTestVersion petersonChainGraph

bench :: C.Benchmark
bench = C.bgroup "pact-backend" $
Expand Down
29 changes: 22 additions & 7 deletions bench/Chainweb/Pact/Backend/ForkingBench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import Pact.Types.Util hiding (unwrap)

import Chainweb.BlockCreationTime
import Chainweb.BlockHeader
import Chainweb.BlockHeader.Genesis
import Chainweb.BlockHeaderDB
import Chainweb.BlockHeaderDB.Internal
import Chainweb.ChainId
Expand All @@ -89,6 +88,7 @@ import Chainweb.Pact.Utils (toTxCreationTime)
import Chainweb.Payload
import Chainweb.Payload.PayloadStore
import Chainweb.Payload.PayloadStore.InMemory
import Chainweb.Test.TestVersions
import Chainweb.Time
import Chainweb.Transaction
import Chainweb.Utils
Expand Down Expand Up @@ -379,7 +379,7 @@ cid :: ChainId
cid = someChainId testVer

testVer :: ChainwebVersion
testVer = FastTimedCPM petersonChainGraph
testVer = slowForkingCpmTestVersion petersonChainGraph

assertNotLeft :: (MonadThrow m, Exception e) => Either e a -> m a
assertNotLeft (Left l) = throwM l
Expand All @@ -397,7 +397,10 @@ createCoinAccount v meta name = do
nameKeyset <- NEL.fromList <$> getKeyset name
let attach = attachCaps "sender00" name 1000.0
let theData = object [T.pack name .= fmap (formatB16PubKey . fst) (attach nameKeyset)]
res <- mkExec (T.pack theCode) theData meta (NEL.toList $ attach sender00Keyset) (Just $ Pact.NetworkId $ toText v) Nothing
res <- mkExec (T.pack theCode) theData meta
(NEL.toList $ attach sender00Keyset)
(Just $ Pact.NetworkId $ toText (_versionName v))
Nothing
pure (nameKeyset, res)
where
theCode = printf "(coin.transfer-create \"sender00\" \"%s\" (read-keyset \"%s\") 1000.0)" name name
Expand Down Expand Up @@ -550,14 +553,20 @@ createCoinContractRequest v meta ks request =
object
[ "create-account-guard" .= fmap (formatB16PubKey . fst) guardd
]
mkExec (T.pack theCode) theData meta (NEL.toList ks) (Just $ Pact.NetworkId $ toText v) Nothing
mkExec (T.pack theCode) theData meta
(NEL.toList ks)
(Just $ Pact.NetworkId $ toText $ _versionName v)
Nothing
CoinAccountBalance (Account account) -> do
let theData = Null
theCode =
printf
"(coin.get-balance \"%s\")"
account
mkExec (T.pack theCode) theData meta (NEL.toList ks) (Just $ Pact.NetworkId $ toText v) Nothing
mkExec (T.pack theCode) theData meta
(NEL.toList ks)
(Just $ Pact.NetworkId $ toText $ _versionName v)
Nothing
CoinTransferAndCreate (SenderName (Account sn)) (ReceiverName (Account rn)) (Guard guardd) (Amount amount) -> do
let theCode =
printf
Expand All @@ -570,7 +579,10 @@ createCoinContractRequest v meta ks request =
object
[ "receiver-guard" .= fmap (formatB16PubKey . fst) guardd
]
mkExec (T.pack theCode) theData meta (NEL.toList ks) (Just $ Pact.NetworkId $ toText v) Nothing
mkExec (T.pack theCode) theData meta
(NEL.toList ks)
(Just $ Pact.NetworkId $ toText $ _versionName v)
Nothing

CoinTransfer (SenderName (Account sn)) (ReceiverName (Account rn)) (Amount amount) -> do
let theCode =
Expand All @@ -581,7 +593,10 @@ createCoinContractRequest v meta ks request =
-- Super janky, but gets the job done for now
(fromRational @Double $ toRational amount)
theData = object []
mkExec (T.pack theCode) theData meta (NEL.toList ks) (Just $ Pact.NetworkId $ toText v) Nothing
mkExec (T.pack theCode) theData meta
(NEL.toList ks)
(Just $ Pact.NetworkId $ toText $ _versionName v)
Nothing

makeMetaWithSender :: String -> ChainId -> IO PublicMeta
makeMetaWithSender sender c =
Expand Down
2 changes: 1 addition & 1 deletion bench/JSONEncoding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Chainweb.Payload
import Chainweb.RestAPI.NodeInfo
import Chainweb.Test.Orphans.Internal
import Chainweb.Utils.Paging
import Chainweb.Version
import Chainweb.Version.Mainnet

-- -------------------------------------------------------------------------- --
-- Main
Expand Down
29 changes: 17 additions & 12 deletions chainweb.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ library
, Chainweb.BlockCreationTime
, Chainweb.BlockHash
, Chainweb.BlockHeader
, Chainweb.BlockHeader.Genesis
, Chainweb.BlockHeader.Genesis.Development0Payload
, Chainweb.BlockHeader.Genesis.DevelopmentKADPayload
, Chainweb.BlockHeader.Genesis.DevelopmentNPayload
, Chainweb.BlockHeader.Genesis.Development1to9Payload
, Chainweb.BlockHeader.Genesis.Development10to19Payload
, Chainweb.BlockHeader.Genesis.FastDevelopment0Payload
, Chainweb.BlockHeader.Genesis.FastDevelopment1to19Payload
, Chainweb.BlockHeader.Genesis.FastTimedCPM0Payload
, Chainweb.BlockHeader.Genesis.FastTimedCPMNPayload
, Chainweb.BlockHeader.Genesis.FastTimedCPM1to9Payload
, Chainweb.BlockHeader.Genesis.Testnet0Payload
, Chainweb.BlockHeader.Genesis.TestnetNPayload
, Chainweb.BlockHeader.Genesis.Testnet1to19Payload
, Chainweb.BlockHeader.Genesis.Mainnet0Payload
, Chainweb.BlockHeader.Genesis.Mainnet1Payload
, Chainweb.BlockHeader.Genesis.Mainnet2Payload
Expand All @@ -139,7 +140,7 @@ library
, Chainweb.BlockHeader.Genesis.Mainnet7Payload
, Chainweb.BlockHeader.Genesis.Mainnet8Payload
, Chainweb.BlockHeader.Genesis.Mainnet9Payload
, Chainweb.BlockHeader.Genesis.MainnetKADPayload
, Chainweb.BlockHeader.Genesis.Mainnet10to19Payload
, Chainweb.BlockHeader.Validation
, Chainweb.BlockHeaderDB
, Chainweb.BlockHeaderDB.Internal
Expand Down Expand Up @@ -234,14 +235,19 @@ library
, Chainweb.Utils
, Chainweb.Utils.Paging
, Chainweb.Utils.RequestLog
, Chainweb.Utils.Rule
, Chainweb.Utils.Serialization
, Chainweb.Version
, Chainweb.Version.Development
, Chainweb.Version.FastDevelopment
, Chainweb.Version.Guards
, Chainweb.Version.Mainnet
, Chainweb.Version.Registry
, Chainweb.Version.Testnet
, Chainweb.Version.Utils
, Chainweb.WebBlockHeaderDB
, Chainweb.WebPactExecutionService

, Control.Concurrent.FixedThreadPool

, Data.IVar
, Data.LogMessage
, Data.PQueue
Expand Down Expand Up @@ -305,7 +311,6 @@ library
, Chainweb.Pact.Transactions.Mainnet9Transactions
, Chainweb.Pact.Transactions.MainnetKADTransactions
, Chainweb.Pact.Transactions.OtherTransactions
, Chainweb.Pact.Transactions.UpgradeTransactions
, Chainweb.Pact.Types
, Chainweb.Pact.Utils
, Chainweb.Pact.Validations
Expand Down Expand Up @@ -378,12 +383,12 @@ library
, rosetta >= 1.0
, safe-exceptions >= 0.1
, scheduler >= 1.4
, semigroupoids >= 5.3.7
, servant >= 0.18.2
, servant-client >= 0.18.2
, servant-client-core >= 0.18.2
, servant-server >= 0.18.2
, stm >= 2.4
, stm-chans
, stopwatch >= 0.1
, streaming >= 0.2
, streaming-commons >= 0.2
Expand Down Expand Up @@ -479,13 +484,13 @@ test-suite chainweb-tests
Chainweb.Test.SPV
Chainweb.Test.SPV.EventProof
Chainweb.Test.Sync.WebBlockHeaderStore
Chainweb.Test.TestVersions
Chainweb.Test.TreeDB
Chainweb.Test.TreeDB.RemoteDB
Chainweb.Test.Utils
Chainweb.Test.Version
Chainweb.Test.Utils.BlockHeader
Chainweb.Test.Utils.TestHeader
Chainweb.Test.Utils.ApiQueries

-- Data
Data.Test.PQueue
Expand Down Expand Up @@ -680,7 +685,6 @@ executable cwtool
, digraph >= 0.2
, direct-sqlite >= 2.3.27
, directory >= 1.3
, errors >= 2.3
, file-embed
, filepath >= 1.4
, exceptions >= 0.8
Expand All @@ -699,6 +703,7 @@ executable cwtool
, process >= 1.5
, quickcheck-instances >= 0.3
, random >= 1.2
, retry >= 0.9
, rocksdb-haskell-kadena >= 1.1.0
, safe-exceptions >= 0.1
, servant-client >= 0.18.2
Expand Down
2 changes: 1 addition & 1 deletion docs/RecoveringFromDeepForks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Help! My node has failed with the following fatal error:
```
Fatal error: Requested rewind exceeds limit (4). Our previous cut block height: 1, fork ancestor's block height: 6.
Offending new block:
BlockHeader {_blockNonce = Nonce 0, _blockCreationTime = BlockCreationTime {_bct = Time (TimeSpan (Micros 1575672858613932))}, _blockParent = "ugAOff6YkKmvp_pJIHqx6HLTRPwyHEHD2c2Olm6L2Fg", _blockAdjacentHashes = BlockHashRecord {_getBlockHashRecord = fromList []}, _blockTarget = HashTarget (PowHashNat 115792089237316195423570985008687907853269984665640564039457584007913129639935), _blockPayloadHash = BlockPayloadHash (MerkleLogHash U-3paUKNKQUkggFmNOnGBEAJnjpy4K_-7t_dGyV0lhw), _blockChainId = ChainId 8, _blockWeight = BlockWeight (HashDifficulty (PowHashNat 1)), _blockHeight = 1, _blockChainwebVersion = fastTimedCPM-peterson, _blockEpochStart = EpochStartTime (Time (TimeSpan (Micros 0))), _blockFlags = FeatureFlags 0, _blockHash = "SKZ0mTWp08ooXsWz_yyT7v_MSrRdyKkmCyWJBTK8u3g"}
BlockHeader {_blockNonce = Nonce 0, _blockCreationTime = BlockCreationTime {_bct = Time (TimeSpan (Micros 1575672858613932))}, _blockParent = "ugAOff6YkKmvp_pJIHqx6HLTRPwyHEHD2c2Olm6L2Fg", _blockAdjacentHashes = BlockHashRecord {_getBlockHashRecord = fromList []}, _blockTarget = HashTarget (PowHashNat 115792089237316195423570985008687907853269984665640564039457584007913129639935), _blockPayloadHash = BlockPayloadHash (MerkleLogHash U-3paUKNKQUkggFmNOnGBEAJnjpy4K_-7t_dGyV0lhw), _blockChainId = ChainId 8, _blockWeight = BlockWeight (HashDifficulty (PowHashNat 1)), _blockHeight = 1, _blockChainwebVersion = fastfork-CPM-peterson, _blockEpochStart = EpochStartTime (Time (TimeSpan (Micros 0))), _blockFlags = FeatureFlags 0, _blockHash = "SKZ0mTWp08ooXsWz_yyT7v_MSrRdyKkmCyWJBTK8u3g"}

Your node is part of a losing fork longer than your reorg-limit, which
is a situation that requires manual intervention.
Expand Down
19 changes: 10 additions & 9 deletions node/ChainwebNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ import Chainweb.Time
import Chainweb.Utils
import Chainweb.Utils.RequestLog
import Chainweb.Version
import Chainweb.Version.Mainnet
import Chainweb.Version.Registry

import Chainweb.Storage.Table
import Chainweb.Storage.Table.RocksDB
Expand Down Expand Up @@ -128,18 +130,16 @@ data ChainwebNodeConfiguration = ChainwebNodeConfiguration

makeLenses ''ChainwebNodeConfiguration

defaultChainwebNodeConfiguration :: ChainwebVersion -> ChainwebNodeConfiguration
defaultChainwebNodeConfiguration v = ChainwebNodeConfiguration
{ _nodeConfigChainweb = defaultChainwebConfiguration v
defaultChainwebNodeConfiguration :: ChainwebNodeConfiguration
defaultChainwebNodeConfiguration = ChainwebNodeConfiguration
{ _nodeConfigChainweb = defaultChainwebConfiguration Mainnet01
, _nodeConfigLog = defaultLogConfig
& logConfigLogger . L.loggerConfigThreshold .~ level
, _nodeConfigDatabaseDirectory = Nothing
, _nodeConfigResetChainDbs = False
}
where
level = case v of
Mainnet01 -> L.Info
_ -> L.Info
level = L.Info

validateChainwebNodeConfiguration :: ConfigValidation ChainwebNodeConfiguration []
validateChainwebNodeConfiguration o = do
Expand Down Expand Up @@ -185,7 +185,7 @@ getBackupsDir conf = (</> "backups") <$> getDbBaseDir conf
getDbBaseDir :: HasCallStack => ChainwebNodeConfiguration -> IO FilePath
getDbBaseDir conf = case _nodeConfigDatabaseDirectory conf of
Nothing -> getXdgDirectory XdgData
$ "chainweb-node" </> sshow v
$ "chainweb-node" </> sshow (_versionName v)
Just d -> return d
where
v = _configChainwebVersion $ _nodeConfigChainweb conf
Expand Down Expand Up @@ -431,7 +431,7 @@ withNodeLogger logConfig v f = runManaged $ do

liftIO $ f
$ maybe id (\x -> addLabel ("cluster", toText x)) (_logConfigClusterId logConfig)
$ addLabel ("chainwebVersion", sshow v)
$ addLabel ("chainwebVersion", sshow (_versionName v))
$ logger
where
teleLogConfig = _logConfigTelemetryBackend logConfig
Expand Down Expand Up @@ -517,7 +517,7 @@ mainInfo :: ProgramInfo ChainwebNodeConfiguration
mainInfo = programInfoValidate
"Chainweb Node"
pChainwebNodeConfiguration
(defaultChainwebNodeConfiguration Mainnet01)
defaultChainwebNodeConfiguration
validateChainwebNodeConfiguration

handles :: [Handler a] -> IO a -> IO a
Expand All @@ -529,6 +529,7 @@ main = do
checkRLimits
runWithPkgInfoConfiguration mainInfo pkgInfo $ \conf -> do
let v = _configChainwebVersion $ _nodeConfigChainweb conf
registerVersion v
hSetBuffering stderr LineBuffering
withNodeLogger (_nodeConfigLog conf) v $ \logger -> do
logFunctionJson logger Info ProcessStarted
Expand Down
Loading