Skip to content

Instantly share code, notes, and snippets.

pragma solidity ^0.4.18;
/**
* @title Proxy
* @dev Gives the possibility to delegate any call to a foreign implementation.
*/
contract Proxy {
/**
* @dev Tells the address of the implementation where every call will be delegated.

https://github.com/ethereum/devp2p/blob/master/rlpx.md

RLPx는 cryptographic peer-to-peer 네트워크이면서 프로토콜 모음이다. 이는 애플리케이션이 p2p network를 통해 전송 수단 또는 인터페이스를 제공한다.

RLPx의 현재 버전은 Ethereum을 위한 네트워크 레이어를 제공한다.

Transport

목표

https://github.com/ethereum/wiki/wiki/%C3%90%CE%9EVp2p-Wire-Protocol

peer-to-peer 커뮤니케이션을 위해, node들은 Ethereum/Whisper/&c를 구동한다. client들은 심플한 wire-protocol에 의해 작동되도록 디자인되어 있다. 이 wire-protocol은 기존의 ÐΞV 기술RLP와 같은 표준을 사용한다.

Low-Level

ÐΞVp2p 노드들은 RLPx를 사용하여 message를 보냄으로써 커뮤니케이션한다. RLPx는 encrypted, authenticated transport protocol이다. 피어는 자신이 원하는 모든 TCP 포트에서 연결을 알리고 허용 할 수 있지만, 기본 TCP가 connection-oriented 매체를 제공하지만, ÐΞVp2p 노드들은 패킷의 관점에서 통신한다. RLPx는 이러한 packet들은 보내거나 받는 facilities를 제공한다.

TODO: https://github.com/ethereum/devp2p/blob/master/rlpx.md (RLPx)

https://github.com/ethereum/wiki/wiki/Ethereum-Wire-Protocol

Ethereum client를 구동하고 있는 노드가 peer-to-peer 커뮤니케이션은 ÐΞVp2p Wire Protocol을 구동한다.

Basic Chain Syncing

  • 두 peer는 연결하고 Hello를 말하고 Status message를 전송한다. Status는 Total Difficulty(TD)와 best block의 hash다.
    • total difficulty: 현재 블록의 difficulty의 총합이다. difficulty란 새로운 block을 마이너가 마이닝할 때 해시 값을 찾기 위해 얼마나 brute force를 했는지를 수량화할 수 있는 값이다. e.g. block #0 difficulty: 1, total difficulty: 1
pragma solidity ^0.4.24;

contract StorageTest {
  // saved at index 0
	uint storedUint256 = 15; // actually stored value: 0x000000000000000000000000000000000000000000000000000000000000000f
                           // get stored value: 0x0f = 15

  // constant variable is not stored in a storage. available only in code
	uint constant constUint256 = 16;
owner1 = web3.eth.accounts[0]
owner2 = web3.eth.accounts[1]
owner3 = web3.eth.accounts[2]
to = web3.eth.accounts[3]
HanwhaToken.new('HanwhaToken', 'HWT', 18, [1911772800, 1914451199]).then(i => token = i)
MultiSigWallet.new([owner1, owner2, owner3], 2).then(i => wallet = i)
token.mint(wallet.address, 100)
token.balanceOf(wallet.address)
owner = web3.eth.accounts[0]
buyer = web3.eth.accounts[1]
signer = web3.eth.accounts[3] // verified address that allows conversions with higher gas price
defaultGasPriceLimit = 20000000000
// BancorNetwork init configuration=
ContractRegistry.new().then(instance => contractRegistry = instance)
ContractIds.new().then(instance => contractIds = instance)
ContractFeatures.new().then(instance => contractFeatures = instance)
contractFeaturesId = contractIds.CONTRACT_FEATURES.call()
api.post('/', async (req, res) => {
const serializedTx = req.body.serializedTx;
try {
web3.eth.sendSignedTransaction(serializedTx)
.on('receipt', receipt => {
return res.status(200).json({
code: 0,
message: 'success',
response: {
txhash: receipt.transactionHash,