yangbongsoo / blockStudy

1 stars 0 forks source link

IPFS #18

Open yangbongsoo opened 1 year ago

yangbongsoo commented 1 year ago

정의

IPFS is a distributed system for storing and accessing files, websites, applications, and data.

IPFS(InterPlanetary File System) 는 분산 P2P 파일 시스템 프로토콜로 2014년에 논문으로 처음 발표.

Q) IPFS와 FileCoin 과의 관계 Q) IPFS 는 블록체인 기술을 이용하나?? -> 이용한다면 어떤걸쓰고 있는지

HTTP 프로토콜과 차별점

예를들어, #16 에 있는 pdf 파일은 https://github.com/yangbongsoo/blockStudy/files/9947167/storj_paper.pdf URL 을 통해 접근할 수 있다.

만약 IPFS 를 쓴다면, /ipfs/bafybeiaysi4s6lnjev27ln5icwm6tueaw2vdykrtjkwiphwekaywqhcjze/ybs/storj 이런식의 주소체계로 접근할 수 있다.

https://github.com/yangbongsoo/blockStudy/files/9947167/storj_paper.pdf 주소는 본질적으로 콘텐츠랑 관련이 없다. storj_paper.pdf 파일 내용을 바꿔도 URL 은 그대로다.

결국 Location based Addressing vs Content based Addressing 이다.

그런데 Content based Addressing 은 IPFS 가 처음 얘기한건 아니다. RFC2141 cf) RFC 는 미국의 국제 인터넷 표준화기구인 IETF(Internet Engineering Task Force)에서 제공, 관리하는 스펙 문서.

URI(Uniform Resource Identifier) 라는 전체 집합은 URL(Uniform Resource Locator) 과 URN(Uniform Resource Name) 이라는 부분집합으로 이뤄져있다(HTTP 완벽가이드 p7~9).


파일마다 각자 고유의 해시값을 갖게되고, 특정 파일을 다운받길 원하면 그 파일의 해시값을 누가 갖고 있는지 네트워크에 물어본다. IPFS 네트워크에 누군가가 그 파일을 갖고 있으면 파일을 제공해준다.

스크린샷 2022-11-26 오전 1 15 12

해시값을 통해 파일 위변조를 쉽게 비교할수 있으므로, IPFS 네트워크에 누군가가 악의적으로 파일을 주더라도 방어할 수 있다.

HTTP 이용 방식은 파일에 접근하기 위해서 도메인(github.com) 그리고 포트(443 여기선 생략됐지만) 그리고 세부 path 들까지 다 알아야함. 그리고 만약 github.com 서버가 다운된다면, 더이상 이용할 수 없음

IPFS 는 중앙화된 서버 없이 노드들의 P2P 통신으로 실현한 더 빠르고 안전하고 열린 네트워크다. 고용량의 파일을 빠르고 효율적이게 전달할 수 있으며(BitSwap), 파일들의 중복을 알 수 있기 때문에 저장소도 효율적으로 사용할 수 있다(Merkle DAG, contents-addressed)

IPFS 상에 업로드된 파일의 이름은 영원히 기록되며, 만약 IPFS 상에서 지키고 싶은 파일은 원하는 만큼 지켜낼 수 있다(pinning)고는 되어 있는데 pin 하는것은 무료 아님.

IPFS does not ensure my content is available or accessible. In fact, IPFS nodes cache content for 24 hours by default and then delete it via a process called garbage collection. The only way for content to persist is to “pin” it.

구체적인 동작원리

  1. Distributed Hash Tables(DHT) — Routing
  2. Bittorrent — File exchange
  3. Git(merkle DAG) — version control systems
  4. SFS(Self-certified FileSystems)

참고: https://docs.ipfs.tech/concepts/what-is-ipfs/#decentralization 참고 : https://www.storj.io/blog/announcing-storj-ipfs-pinning-service-durable-performant-decentralized-nft-and-dapp-storage?utm_content=205179018&utm_medium=social&utm_source=twitter&hss_channel=tw-345738416 참고 : https://www.youtube.com/watch?v=Z5zNPwMDYGg 참고 : https://www.youtube.com/watch?v=5Uj6uR3fp-U

yangbongsoo commented 1 year ago

Distributed Hash Tables

네트워크에 참여한 노드들이 해시 테이블을 각자 관리. 중앙화된 서버 없이 P2P 네트워크를 실현할 수 있으며, 이를 분산 해시 테이블(Distributed hash table, DHT) 기술이라함.

-> 가상 면접 사례로 배우는 대규모 시스템 설계 기초. 분산 키-값 저장소