core-geth icon indicating copy to clipboard operation
core-geth copied to clipboard

cli: --datadir="" doesn't yield an ephemeral memory db

Open meowsbits opened this issue 4 years ago • 0 comments
trafficstars

System information

> ./build/bin/geth version
CoreGeth
Version: 1.11.22-unstable
Git Commit: f63ac8285f3d543a19c0625c3151857292b93383
Git Commit Date: 20210119
Architecture: amd64
Protocol Versions: [65 64 63]
Go Version: go1.15.5
Operating System: linux
GOPATH=/home/ia/go
GOROOT=/home/ia/go1.15.5.linux-amd64

Expected behaviour

./build/bin/geth --datadir="" --exec "console.log('hello world');" console uses an ephemeral memory DB.

This is what I expect from working with the the node database configurations, like https://github.com/etclabscore/core-geth/blob/master/node/node.go#L618.

Modifying the behavior to fit my expectation would however break an important API (ie the --datadir flag use).

I would propose adding a --datadir.ephemeral boolean flag to implement the desired functionality.

Actual behaviour

The current working directory is used as the data directory.

Steps to reproduce the behaviour

> git status && ./build/bin/geth --datadir="" --exec="console.log('hello world');" console && tree geth && { test -f history && echo 'history file exists'; }
On branch master
nothing to commit, working tree clean
INFO [01-22|06:02:49.564] Starting Geth on Ethereum mainnet...
INFO [01-22|06:02:49.564] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [01-22|06:02:49.565] Maximum peer count                       ETH=50 LES=0 total=50
INFO [01-22|06:02:49.565] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [01-22|06:02:49.567] Set global gas cap                       cap=25000000
INFO [01-22|06:02:49.567] Allocated trie memory caches             clean=1023.00MiB dirty=1024.00MiB
INFO [01-22|06:02:49.567] Allocated cache and file handles         database=/home/ia/go/src/github.com/ethereum/go-ethereum/geth/chaindata cache=2.00GiB handles=524288
INFO [01-22|06:02:49.656] Opened ancient database                  database=/home/ia/go/src/github.com/ethereum/go-ethereum/geth/chaindata/ancient
INFO [01-22|06:02:49.656] Writing default main-net genesis block
INFO [01-22|06:02:49.807] Persisted trie from memory database      nodes=12356 size=1.78MiB time=36.591202ms gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [01-22|06:02:49.808] Wrote custom genesis block OK            config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 ConstantinopleFix: 7280000 Istanbul: 9069000 MuirGlacier: 9200000 Engine: ethash}"
INFO [01-22|06:02:49.808] Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 ConstantinopleFix: 7280000 Istanbul: 9069000 MuirGlacier: 9200000 Engine: ethash}"
INFO [01-22|06:02:49.808] Disk storage enabled for ethash caches   dir=/home/ia/go/src/github.com/ethereum/go-ethereum/geth/ethash count=3
INFO [01-22|06:02:49.808] Disk storage enabled for ethash DAGs     dir=/home/ia/.ethash count=2
INFO [01-22|06:02:49.808] Initialising Ethereum protocol           versions="[65 64 63]" network=1 dbversion=<nil>
WARN [01-22|06:02:49.808] Upgrade blockchain database version      from=<nil> to=8
INFO [01-22|06:02:49.809] Loaded most recent local header          number=0 hash="d4e567…cb8fa3" td=17179869184 age=51y9mo2w
INFO [01-22|06:02:49.809] Loaded most recent local full block      number=0 hash="d4e567…cb8fa3" td=17179869184 age=51y9mo2w
INFO [01-22|06:02:49.809] Loaded most recent local fast block      number=0 hash="d4e567…cb8fa3" td=17179869184 age=51y9mo2w
INFO [01-22|06:02:49.809] Regenerated local transaction journal    transactions=0 accounts=0
INFO [01-22|06:02:49.831] Allocated fast sync bloom                size=2.00GiB
INFO [01-22|06:02:49.833] Starting peer-to-peer node               instance=CoreGeth/v1.11.22-unstable-f63ac828-20210119/linux-amd64/go1.15.5
INFO [01-22|06:02:49.848] New local node record                    seq=1 id=42c047242d2e97f3 ip=127.0.0.1 udp=30303 tcp=30303
INFO [01-22|06:02:49.848] Started P2P networking                   self=enode://03c1b83867205915df834b0972d7208b4ff387d28e3a8314bc15708ae6c3af4d2158be059ba7e05abe14462030873d63629c4d77784b382aa1eea8bd8148a94e@127.0.0.1:30303
INFO [01-22|06:02:49.849] IPC endpoint opened                      url=/home/ia/go/src/github.com/ethereum/go-ethereum/geth.ipc
INFO [01-22|06:02:49.863] Mapped network port                      proto=tcp extport=30303 intport=30303 interface=NAT-PMP(192.168.86.1)
INFO [01-22|06:02:49.865] Mapped network port                      proto=udp extport=30303 intport=30303 interface=NAT-PMP(192.168.86.1)
hello world
null
INFO [01-22|06:02:49.882] IPC endpoint closed                      url=/home/ia/go/src/github.com/ethereum/go-ethereum/geth.ipc
INFO [01-22|06:02:49.887] Initialized fast sync bloom              items=70 errorrate=0.000 elapsed=55.879ms
INFO [01-22|06:02:49.932] Deallocated fast sync bloom              items=70 errorrate=0.000
INFO [01-22|06:02:49.932] Ethereum protocol stopped
INFO [01-22|06:02:49.932] Transaction pool stopped
INFO [01-22|06:02:49.932] Writing clean trie cache to disk         path=/home/ia/go/src/github.com/ethereum/go-ethereum/geth/triecache threads=12
INFO [01-22|06:02:49.932] Persisted the clean trie cache           path=/home/ia/go/src/github.com/ethereum/go-ethereum/geth/triecache elapsed="572.227µs"
INFO [01-22|06:02:49.932] Blockchain stopped
INFO [01-22|06:02:50.435] New local node record                    seq=2 id=42c047242d2e97f3 ip=75.134.144.252 udp=30303 tcp=30303
geth
├── chaindata
│   ├── 000001.log
│   ├── ancient
│   │   ├── bodies.0000.cdat
│   │   ├── bodies.cidx
│   │   ├── diffs.0000.rdat
│   │   ├── diffs.ridx
│   │   ├── FLOCK
│   │   ├── hashes.0000.rdat
│   │   ├── hashes.ridx
│   │   ├── headers.0000.cdat
│   │   ├── headers.cidx
│   │   ├── receipts.0000.cdat
│   │   └── receipts.cidx
│   ├── CURRENT
│   ├── LOCK
│   ├── LOG
│   └── MANIFEST-000000
├── LOCK
├── nodekey
├── nodes
│   ├── 000001.log
│   ├── CURRENT
│   ├── LOCK
│   ├── LOG
│   └── MANIFEST-000000
├── transactions.rlp
└── triecache
    ├── data.0.bin
    ├── data.10.bin
    ├── data.11.bin
    ├── data.1.bin
    ├── data.2.bin
    ├── data.3.bin
    ├── data.4.bin
    ├── data.5.bin
    ├── data.6.bin
    ├── data.7.bin
    ├── data.8.bin
    ├── data.9.bin
    └── metadata.bin

4 directories, 37 files
history file exists

meowsbits avatar Jan 22 '21 12:01 meowsbits