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

Document on the IPFS Repo Spec, the things we store on Datastore #21

Closed
daviddias opened this issue Dec 21, 2015 · 25 comments
Closed

Document on the IPFS Repo Spec, the things we store on Datastore #21

daviddias opened this issue Dec 21, 2015 · 25 comments
Assignees
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P3 Low: Not priority right now status/ready Ready to be worked

Comments

@daviddias
Copy link
Member

No description provided.

This was referenced Dec 21, 2015
@daviddias daviddias added the help wanted Seeking public contribution on this issue label Apr 11, 2016
@daviddias daviddias added status/ready Ready to be worked exp/expert Having worked on the specific codebase is important and removed js-ipfs-ready labels Dec 5, 2016
@SidHarder
Copy link
Member

SidHarder commented Dec 8, 2016

@diasdavid :There are four keys in the go-ipfs datastore leveldb database:

key= /F5UXA3TTF4JCB5OTOYTDCBGWYFARRBGGIPJR4KKXVXBGOHK4C5MB47SOZHQM3LH6
key= /F5YGWLYSED25G5RGGECNNQKBDCCMMQ6TDYUVPLOCM4OVYF2YDZ7E5SPAZWWP4
key= /local/filesroot
key= /local/pins

The top two keys are unique to the repo and change each time init is run. The bottom two are static. The values for these keys seem to be encrypted. As an example, the data for the first key is:

Y��9_)a���˹2�R�m�Ŗke�9����

Can you help me figure out how to decode the values?

@SidHarder SidHarder removed the status/ready Ready to be worked label Dec 8, 2016
@dignifiedquire
Copy link
Member

@SidHarder why did you close this issue?

@daviddias daviddias reopened this Dec 9, 2016
@jbenet
Copy link
Member

jbenet commented Dec 9, 2016

The last two are not encrypted, i believe these are hashes to look into the blocks. The first two may be routing records. also likely an object hash.

@Kubuxu
Copy link
Member

Kubuxu commented Dec 9, 2016

We in 0.4.3 (I think) shifted from binary keys which were getting corrupted by our sanitation operations to base32 encoded keys.

@daviddias
Copy link
Member Author

@Kubuxu I believe you just changed that in blockstore, not datastore, right?

@Kubuxu
Copy link
Member

Kubuxu commented Dec 9, 2016

no, datastore too as it was also problem with IPNS records where keys are hashes of public key.

@SidHarder
Copy link
Member

OK, I am making some progress:

The value for the key '/local/filesroot' is the hash of the root folder. The value is binary. The go function is core/core.go:563.

The value of this key should match the result of the command: 'ipfs files stat --hash /', (however, I have not been able to make this work yet)
Also, the value is a binary cid?

@SidHarder
Copy link
Member

@dignifiedquire I'm sorry I didn't mean to close it.

@Kubuxu
Copy link
Member

Kubuxu commented Dec 9, 2016

Yes, the value is binary CID, v1 probably in new version and v0 in an older ones.

@SidHarder
Copy link
Member

The "/local/pins" key:

go-ipfs reference: pin/pin.go:450

@SidHarder
Copy link
Member

SidHarder commented Dec 12, 2016

Im trying to verify the /local/filesroot key, when I use the js-ipfs-cid class as below the result I get is: 2Dkx8D3WqjChhe3ZGUvQ2Jkj5LT428yvFGzv3KD6c1Pz which doesn't match the result of "ipfs files stat --hash /" which is QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn. Not sure what I'm doing wrong.

var levelup = require('levelup')
const CID = require('cids')

var ops = [{
valueEncoding : 'binary'
}]

var db = levelup('../../.ipfs/datastore', ops, function (err, db) {

var key = '/local/filesroot'		

db.get(key, function (err, value) {
	if (err) {
		if (err.notFound) {
			console.log(err)
			return
		}
		console.log(err)
		return callback(err)
	}	
				
	var buffer = new Buffer(value, 'binary')
	var cid = new CID(buffer)
	var result = cid.toBaseEncodedString()
	console.log(result)		
})

})

@SidHarder
Copy link
Member

@Kubuxu Can you help me understand why when I retrieve the value for the "/local/filesroot" key and convert it to base58 I get this: 2Dkx8D3WqjChhe3ZGUvQ2Jkj5LT428yvFGzv3KD6c1Pz instead of QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn which is the result of "ipfs files stat --hash /".

Also, I am retrieving the key/value pair and converting it using Node.

@Kubuxu
Copy link
Member

Kubuxu commented Dec 15, 2016

I just dumped this key from go-ipfs:
and it is: 122059948439065f29619ef41280cbb932be52c56d99c5966b65e0111239f098bbef which is QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn

@Kubuxu
Copy link
Member

Kubuxu commented Dec 16, 2016

Also the key you sent has quite a weird pattern at the end hex FDFDFDFD at the end, suggesting some corruption.

@SidHarder
Copy link
Member

@Kubuxu It must be how level up is retrieving the value. I see if I can figure it out. Thanks for your help.

@SidHarder
Copy link
Member

SidHarder commented Dec 20, 2016

OK the code below will extract the /local/filesroot key and base58 encode it. The extracted value matches the result of ipfs files stat --hash. The "valueEncoding: binary" is really important.

const level = require('level')
const bs58 = require('bs58')
const db = level('../../.ipfs/datastore', { valueEncoding: 'binary' })

db.get('/local/filesroot', function (err, value) {
if(err) {
console.log(err)
}
else{
console.log(bs58.encode(value))
}
})

@daviddias
Copy link
Member Author

awesome progress @SidHarder :) Wanna start making the PR that adds that levelDB store and tests?

@SidHarder
Copy link
Member

@diasdavid I'll get started.

@SidHarder
Copy link
Member

@diasdavid Does it make sense to have a datastore.js module in js-ipfs-repo/src/stores? This module could be used during the init process to add the necessary keys and values.

@daviddias
Copy link
Member Author

@SidHarder absolutely. Just have in mind that it needs to be LevelDB for nodejs and indexedDB for when in the browser

@daviddias daviddias added status/ready Ready to be worked and removed status/in-progress In progress labels Mar 13, 2017
@daviddias
Copy link
Member Author

We still need this list, @SidHarder could you PR to the README the current keys that ipfs uses to store things in the repo?

@SidHarder
Copy link
Member

@diasdavid the keys that Go IPFS stores in the Datastore are:

key= /F5UXA3TTF4JCB5OTOYTDCBGWYFARRBGGIPJR4KKXVXBGOHK4C5MB47SOZHQM3LH6
key= /F5YGWLYSED25G5RGGECNNQKBDCCMMQ6TDYUVPLOCM4OVYF2YDZ7E5SPAZWWP4
key= /local/filesroot
key= /local/pins

I'm sorry but I don't understand what you mean by PR to the README.

@Kubuxu
Copy link
Member

Kubuxu commented Mar 23, 2017

The first two records are:

 echo F5UXA3TTF4JCB5OTOYTDCBGWYFARRBGGIPJR4KKXVXBGOHK4C5MB47SOZHQM3LH6 | bases base32 bin
/ipns/� ��v&1���A���C��)W��g�\�X�~N��ͬ�%
 echo F5YGWLYSED25G5RGGECNNQKBDCCMMQ6TDYUVPLOCM4OVYF2YDZ7E5SPAZWWP4 | bases base32 bin
/pk/� ��v&1���A���C��)W��g�\�X�~N��%      

Using https://github.com/whyrusleeping/bases

@daviddias
Copy link
Member Author

@SidHarder Would you like to wrap this task and add the findings to the Readme?

@daviddias daviddias added status/deferred Conscious decision to pause or backlog and removed status/ready Ready to be worked labels Jun 20, 2017
@daviddias
Copy link
Member Author

//cc @pgte

@daviddias daviddias added status/ready Ready to be worked P3 Low: Not priority right now and removed status/deferred Conscious decision to pause or backlog labels Oct 17, 2017
@daviddias daviddias changed the title Itemise the things that are still present on the levelDB repo Document on the IPFS Repo Spec, the things we store on Datastore Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue P3 Low: Not priority right now status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

5 participants