internet-sicherheit / ethereum-cache-creator

GNU General Public License v3.0
0 stars 0 forks source link

Identify User, SC & Miner in transaction via metadata in Blockheader to label arcs #13

Closed beeshot closed 4 years ago

beeshot commented 4 years ago

In POW and Eth the Miner can be identified via Metadata in the Header (contains e.g. timestamp and software version? How would this look in Bloxberg, since it uses POA? Is a nonce related?

How to identify a smart contract in data set.

In order to label transactions, these groups need to be identified.

1) User 2) SC (normal) 3) SC (Miner) 4) Miner

kiview commented 4 years ago

This is a SC deployment transaction in bloxberg: https://blockexplorer.bloxberg.org/tx/0xe1067b5f2b4a6443d67aee3047b7ca9c2d6721eaa984a76e5ee641ed080f7f55/

We can find indications of SC creation in the trace logs:

[
  {
    "action": {
      "from": "0xab59a1ea1ac9af9f77518b9b4ad80942ade35088",
      "gas": "0x62DC9F",
      "init": "0x608060405234801561001057600080fd5b50610b54806100206000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635d7fc16d14610072578063864d72f21461018257806397b4f97c1461031e578063d13319c41461038a578063dfb299351461041a575b600080fd5b610164600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803515159060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610483565b60405180826000191660001916815260200191505060405180910390f35b34801561018e57600080fd5b506101b160048036038101908080356000191690602001909291905050506106d6565b60405180806020018060200186600019166000191681526020018060200185151515158152602001848103845289818151815260200191508051906020019080838360005b838110156102115780820151818401526020810190506101f6565b50505050905090810190601f16801561023e5780820380516001836020036101000a031916815260200191505b50848103835288818151815260200191508051906020019080838360005b8381101561027757808201518184015260208101905061025c565b50505050905090810190601f1680156102a45780820380516001836020036101000a031916815260200191505b50848103825286818151815260200191508051906020019080838360005b838110156102dd5780820151818401526020810190506102c2565b50505050905090810190601f16801561030a5780820380516001836020036101000a031916815260200191505b509850505050505050505060405180910390f35b34801561032a57600080fd5b5061033361096b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561037657808201518184015260208101905061035b565b505050509050019250505060405180910390f35b34801561039657600080fd5b5061039f6109c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103df5780820151818401526020810190506103c4565b50505050905090810190601f16801561040c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561042657600080fd5b50610481600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610a69565b005b60008085836040518083805190602001908083835b6020831015156104bd5780518252602082019150602081019050602083039250610498565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310151561051057805182526020820191506020810190506020830392506104eb565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051809103902090506001819080600181540180825580915050906001820390600052602060002001600090919290919091509060001916905550600080815480929190600101919050556000819055508560036000836000191660001916815260200190815260200160002060000190805190602001906105ba929190610a83565b50806003600083600019166000191681526020019081526020016000206002018160001916905550836003600083600019166000191681526020019081526020016000206001019080519060200190610614929190610a83565b50826003600083600019166000191681526020019081526020016000206003019080519060200190610647929190610a83565b508460036000836000191660001916815260200190815260200160002060040160006101000a81548160ff0219169083151502179055507f1031f56f812c8a9ce241b0794ce9b5ed111824465b8534628b8e26b005bc77ae816001604051808360001916600019168152602001821515151581526020019250505060405180910390a180915050949350505050565b60608060006060600060036000876000191660001916815260200190815260200160002060000160036000886000191660001916815260200190815260200160002060010160036000896000191660001916815260200190815260200160002060020154600360008a60001916600019168152602001908152602001600020600301600360008b6000191660001916815260200190815260200160002060040160009054906101000a900460ff16848054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108195780601f106107ee57610100808354040283529160200191610819565b820191906000526020600020905b8154815290600101906020018083116107fc57829003601f168201915b50505050509450838054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b50505050509350818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109515780601f1061092657610100808354040283529160200191610951565b820191906000526020600020905b81548152906001019060200180831161093457829003601f168201915b505050505091509450945094509450945091939590929450565b606060018054806020026020016040519081016040528092919081815260200182805480156109bd57602002820191906000526020600020905b815460001916815260200190600101908083116109a5575b5050505050905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a5f5780601f10610a3457610100808354040283529160200191610a5f565b820191906000526020600020905b815481529060010190602001808311610a4257829003601f168201915b5050505050905090565b8060049080519060200190610a7f929190610a83565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610ac457805160ff1916838001178555610af2565b82800160010185558215610af2579182015b82811115610af1578251825591602001919060010190610ad6565b5b509050610aff9190610b03565b5090565b610b2591905b80821115610b21576000816000905550600101610b09565b5090565b905600a165627a7a72305820d1aa4372283c78700a5d1a18e8bf5919ac9c59c862a3c9dcd4949433ee49ed520029",
      "value": "0x0"
    },
    "result": {
      "address": "0xe5a9654c7e190701016ebf18206020bf16d8beab",
      "code": "0x60806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635d7fc16d14610072578063864d72f21461018257806397b4f97c1461031e578063d13319c41461038a578063dfb299351461041a575b600080fd5b610164600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803515159060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610483565b60405180826000191660001916815260200191505060405180910390f35b34801561018e57600080fd5b506101b160048036038101908080356000191690602001909291905050506106d6565b60405180806020018060200186600019166000191681526020018060200185151515158152602001848103845289818151815260200191508051906020019080838360005b838110156102115780820151818401526020810190506101f6565b50505050905090810190601f16801561023e5780820380516001836020036101000a031916815260200191505b50848103835288818151815260200191508051906020019080838360005b8381101561027757808201518184015260208101905061025c565b50505050905090810190601f1680156102a45780820380516001836020036101000a031916815260200191505b50848103825286818151815260200191508051906020019080838360005b838110156102dd5780820151818401526020810190506102c2565b50505050905090810190601f16801561030a5780820380516001836020036101000a031916815260200191505b509850505050505050505060405180910390f35b34801561032a57600080fd5b5061033361096b565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561037657808201518184015260208101905061035b565b505050509050019250505060405180910390f35b34801561039657600080fd5b5061039f6109c7565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103df5780820151818401526020810190506103c4565b50505050905090810190601f16801561040c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561042657600080fd5b50610481600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610a69565b005b60008085836040518083805190602001908083835b6020831015156104bd5780518252602082019150602081019050602083039250610498565b6001836020036101000a03801982511681845116808217855250505050505090500182805190602001908083835b60208310151561051057805182526020820191506020810190506020830392506104eb565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051809103902090506001819080600181540180825580915050906001820390600052602060002001600090919290919091509060001916905550600080815480929190600101919050556000819055508560036000836000191660001916815260200190815260200160002060000190805190602001906105ba929190610a83565b50806003600083600019166000191681526020019081526020016000206002018160001916905550836003600083600019166000191681526020019081526020016000206001019080519060200190610614929190610a83565b50826003600083600019166000191681526020019081526020016000206003019080519060200190610647929190610a83565b508460036000836000191660001916815260200190815260200160002060040160006101000a81548160ff0219169083151502179055507f1031f56f812c8a9ce241b0794ce9b5ed111824465b8534628b8e26b005bc77ae816001604051808360001916600019168152602001821515151581526020019250505060405180910390a180915050949350505050565b60608060006060600060036000876000191660001916815260200190815260200160002060000160036000886000191660001916815260200190815260200160002060010160036000896000191660001916815260200190815260200160002060020154600360008a60001916600019168152602001908152602001600020600301600360008b6000191660001916815260200190815260200160002060040160009054906101000a900460ff16848054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108195780601f106107ee57610100808354040283529160200191610819565b820191906000526020600020905b8154815290600101906020018083116107fc57829003601f168201915b50505050509450838054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108b55780601f1061088a576101008083540402835291602001916108b5565b820191906000526020600020905b81548152906001019060200180831161089857829003601f168201915b50505050509350818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109515780601f1061092657610100808354040283529160200191610951565b820191906000526020600020905b81548152906001019060200180831161093457829003601f168201915b505050505091509450945094509450945091939590929450565b606060018054806020026020016040519081016040528092919081815260200182805480156109bd57602002820191906000526020600020905b815460001916815260200190600101908083116109a5575b5050505050905090565b606060048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a5f5780601f10610a3457610100808354040283529160200191610a5f565b820191906000526020600020905b815481529060010190602001808311610a4257829003601f168201915b5050505050905090565b8060049080519060200190610a7f929190610a83565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610ac457805160ff1916838001178555610af2565b82800160010185558215610af2579182015b82811115610af1578251825591602001919060010190610ad6565b5b509050610aff9190610b03565b5090565b610b2591905b80821115610b21576000816000905550600101610b09565b5090565b905600a165627a7a72305820d1aa4372283c78700a5d1a18e8bf5919ac9c59c862a3c9dcd4949433ee49ed520029",
      "gasUsed": "0x8DC05"
    },
    "subtraces": 0,
    "traceAddress": [],
    "type": "create"
  }
]

Since blockexplorer can fetch this data from the public API, we are also able to fetch it somehow.

beeshot commented 4 years ago

Miners can be identified simply by miner & distributed rewards

ghost commented 4 years ago

would you mind reformulating in a paragraph what we are looking for in this issue? I would really appreciate it since it is a little bit confusing for me. Thanks in advance :)

kiview commented 4 years ago

Identify sender and receiver address of a transaction and label if the address corresponds to a user, a smart contract or validator/sealer (there are no miners in bloxberg).

kiview commented 4 years ago

Identifying if an address represents a SC can be done by calling the getCode() method on the address. This will return 0x if not a contract and else the contract's byte code.

See this example from plain web3 (not web3j):

web3.eth.getCode("0xa5Acc472597C1e1651270da9081Cc5a0b38258E3")
"0x"
kiview commented 4 years ago

Identifying if an address corresponds do a validator/sealer can be done trivially by leveraging the deployed PoA SC and one time querying the set of validators and subsequently check against this set.

This is the corresponding JS code for this, as used by the Validator DApp in Bloxberg:

export default class PoaConsensus {
  async init({ web3, netId, addresses }) {
    const { POA_ADDRESS } = addresses
    console.log('POA Address ', POA_ADDRESS)

    const poaConsensusAbi = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'PoaNetworkConsensus')

    this.instance = new web3.eth.Contract(poaConsensusAbi, POA_ADDRESS)
  }
  async getValidators() {
    console.log(this.instance)
    return await this.instance.methods.getValidators().call()
  }
}

The address of the PoA SC is 0x9850711951A84Ef8a2A31a7868d0dCa34B0661cA.