Code Monkey home page Code Monkey logo

bsc-genesis-contract's Introduction

bsc-genesis-contracts

This repo hold all the genesis contracts on BNB Smart chain. More details in doc-site.

Prepare

Install node.js dependency:

npm install

Install foundry:

curl -L https://foundry.paradigm.xyz | bash
foundryup
forge install --no-git --no-commit foundry-rs/[email protected]

Install poetry:

curl -sSL https://install.python-poetry.org | python3 -
poetry install

Tips: You can manage multi version of Node:

## Install nvm and node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
nvm install  12.18.3 && nvm use 12.18.3

Unit test

Add follow line to .env file in project dir, replace archive_node with a valid bsc mainnet node url which should be in archive mode:

RPC_BSC=${archive_node}

You can get a free archive node endpoint from https://nodereal.io/.

Run forge test:

forge test

Flatten all system contracts

bash scripts/flatten.sh

All system contracts will be flattened and output into ${workspace}/contracts/flattened/.

How to generate genesis file

  1. Edit init_holders.js file to alloc the initial BNB holder.
  2. Edit validators.js file to alloc the initial validator set.
  3. Edit system contracts setting as needed.
  4. Run node scripts/generate-genesis.js will generate genesis.json

How to generate mainnet/testnet/dev genesis file

poetry run python -m scripts.generate ${network}

Check the genesis.json file, and you can get the exact compiled bytecode for different network. (poetry run python -m scripts.generate --help for more details)

You can refer to generate:dev in package.json for more details about how to custom params for local dev-net.

How to update contract interface for test

// get metadata
forge build

// generate interface
cast interface ${workspace}/out/{contract_name}.sol/${contract_name}.json -p ^0.8.0 -n ${contract_name} > ${workspace}/test/utils/interface/I${contract_name}.sol

BEP-171 unlock bot

npm install ts-node -g

cp .env.example .env
# set UNLOCK_RECEIVER, OPERATOR_PRIVATE_KEY to .env

ts-node scripts/bep171-unlock-bot.ts 

License

The library is licensed under the Apache License, Version 2.0, also included in our repository in the LICENSE file.

bsc-genesis-contract's People

Contributors

brilliant-lx avatar buddh0 avatar cleanunicorn avatar cosinlink avatar dependabot[bot] avatar emailtovamos avatar matuskysel avatar mister-ea avatar nathanbsc avatar pythonberg1997 avatar realuncle avatar rumeelhussainbnb avatar unclezoro avatar yutianwu avatar zlacfzy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bsc-genesis-contract's Issues

1

0

Dev

Please how i can cancel mint function in this contract

Not able generate the Genesis # for Private network

npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] generate-testnet script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2021-11-30T12_12_25_409Z-debug.log

APIs

Are the APIs available somewhere publicity??
How I could access the BEP20 APIs from within the NodeJs app

node generate-genesis.js, get error Cannot read property '1' of null

date: 2022-03-24
branch: master
commit id: ce622fe

clone repo
cd repo 
npm install  
node generate-genesis.js

get error

System file updated.
System reward file updated.
BSCValidatorSet file updated.
TokenHub file updated.
TendermintLightClient file updated.
RelayerIncentivize file updated.
CrossChain file updated.
System file updated.
child process exited with code 1
/private/tmp/bsc-genesis-contract/generate-genesis.js:87
    return { key, compiledData: matched[1], contractName, contractFile }
                                       ^

TypeError: Cannot read property '1' of null
    at /private/tmp/bsc-genesis-contract/generate-genesis.js:87:40
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 6)

spawn solc ENOENT while node generate-genesis.js

Hi, I am Nikhil Upadhyay I am trying to do the generate-genesis.js but am not able to run the whole project when I am trying to run the project it gives me errors like

events.js:377
throw er; // Unhandled 'error' event
^

Error: spawn solc ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:467:16)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn solc',
path: 'solc',
spawnargs: [
'--bin-runtime',
'/=/',
'--optimize',
'--optimize-runs',
'200',
'contracts/BSCValidatorSet.sol'
]
}

npm version = 7.24.1
node version = v14.17.6
nvm version = 0.34.0
and I have followed bss-genesis-contract as same as it is

can anyone help me with it?

Use Local Memory Type Variable Instead of Global Storage Type Variable in Event to Save Gas

Hi, we recently have conducted a systematic study about Solidity event usage, evolution, and impact, and we are attempting to build a tool to improve the practice of Solidity event use based on our findings. We have tried our prototype tool on some of the most popular GitHub Solidity repositories, and for your repository, we find a potential optimization of gas consumption arisen from event use.

The point is that when we use emit operation to store the value of a certain variable, local memory type variable would be preferable to global storage type (state) variable if they hold the same value. The reason is that an extra SLOAD operation would be needed to access the variable if it is storage type, and the SLOAD operation costs 800 gas.

For your repository, we find that the following event use can be improved:

  • TendermintLightClient.sol
    function name:init
    event name:  initConsensusState
    variable:    initialHeight->height
  function init() external onlyNotInit {
    uint256 pointer;
    uint256 length;
    (pointer, length) = Memory.fromBytes(INIT_CONSENSUS_STATE_BYTES);

    /* solium-disable-next-line */
    assembly {
      sstore(chainID_slot, mload(pointer))
    }

    ConsensusState memory cs;
    uint64 height;
    (cs, height) = decodeConsensusState(pointer, length, false);
    cs.preValidatorSetChangeHeight = 0;
    lightClientConsensusStates[height] = cs;

    initialHeight = height;
    latestHeight = height;
    alreadyInit = true;
    rewardForValidatorSetChange = INIT_REWARD_FOR_VALIDATOR_SER_CHANGE;

    emit initConsensusState(initialHeight, cs.appHash);
  }

Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!

error when generate genesis.json

got error when generate genesis.json, how to fix it ?

> npm run generate-mainnet

> [email protected] generate-mainnet D:\blockchain\binance-chain\bsc-genesis-contract
> node generate-genesis.js --chainid 56 --bscChainId 0038 --initConsensusStateBytes 42696e616e63652d436861696e2d5469677269730000000000000000000000000000000006915167cedaf7bbf7df47d932fdda630527ee648562cf3e52c5e5f46156a3a971a4ceb443c53a50d8653ef8cf1e5716da68120fb51b636dc6d111ec3277b098ecd42d49d3769d8a1f78b4c17a965f7a30d4181fabbd1f969f46d3c8e83b5ad4845421d8000000e8d4a510002ba4e81542f437b7ae1f8a35ddb233c789a8dc22734377d9b6d63af1ca403b61000000e8d4a51000df8da8c5abfdb38595391308bb71e5a1e0aabdc1d0cf38315d50d6be939b2606000000e8d4a51000b6619edca4143484800281d698b70c935e9152ad57b31d85c05f2f79f64b39f3000000e8d4a510009446d14ad86c8d2d74780b0847110001a1c2e252eedfea4753ebbbfce3a22f52000000e8d4a510000353c639f80cc8015944436dab1032245d44f912edc31ef668ff9f4a45cd0599000000e8d4a51000e81d3797e0544c3a718e1f05f0fb782212e248e784c1a851be87e77ae0db230e000000e8d4a510005e3fcda30bd19d45c4b73688da35e7da1fce7c6859b2c1f20ed5202d24144e3e000000e8d4a51000b06a59a2d75bf5d014fce7c999b5e71e7a960870f725847d4ba3235baeaa08ef000000e8d4a510000c910e2fe650e4e01406b3310b489fb60a84bc3ff5c5bee3a56d5898b6a8af32000000e8d4a5100071f2d7b8ec1c8b99a653429b0118cd201f794f409d0fea4d65b1b662f2b00063000000e8d4a51000 --initValidatorSetBytes f905ec80f905e8f846942a7cdd959bfe8d9487b2a43b33565295a698f7e294b6a7edd747c0554875d3fc531d19ba1497992c5e941ff80f3f7f110ffd8920a3ac38fdef318fe94a3f86048c27395000f846946488aa4d1955ee33403f8ccb1d4de5fb97c7ade294220f003d8bdfaadf52aa1e55ae4cc485e6794875941a87e90e440a39c99aa9cb5cea0ad6a3f0b2407b86048c27395000f846949ef9f4360c606c7ab4db26b016007d3ad0ab86a0946103af86a874b705854033438383c82575f25bc29418e2db06cbff3e3c5f856410a1838649e760175786048c27395000f84694ee01c3b1283aa067c58eab4709f85e99d46de5fe94ee4b9bfb1871c64e2bcabb1dc382dc8b7c4218a29415904ab26ab0e99d70b51c220ccdcccabee6e29786048c27395000f84694685b1ded8013785d6623cc18d214320b6bb6475994a20ef4e5e4e7e36258dbf51f4d905114cb1b34bc9413e39085dc88704f4394d35209a02b1a9520320c86048c27395000f8469478f3adfc719c99674c072166708589033e2d9afe9448a30d5eaa7b64492a160f139e2da2800ec3834e94055838358c29edf4dcc1ba1985ad58aedbb6be2b86048c27395000f84694c2be4ec20253b8642161bc3f444f53679c1f3d479466f50c616d737e60d7ca6311ff0d9c434197898a94d1d678a2506eeaa365056fe565df8bc8659f28b086048c27395000f846942f7be8361c80a4c1e7e9aaf001d0877f1cfde218945f93992ac37f3e61db2ef8a587a436a161fd210b94ecbc4fb1a97861344dad0867ca3cba2b860411f086048c27395000f84694ce2fd7544e0b2cc94692d4a704debef7bcb613289444abc67b4b2fba283c582387f54c9cba7c34bafa948acc2ab395ded08bb75ce85bf0f95ad2abc51ad586048c27395000f84694b8f7166496996a7da21cf1f1b04d9b3e26a3d077946770572763289aac606e4f327c2f6cc1aa3b3e3b94882d745ed97d4422ca8da1c22ec49d880c4c097286048c27395000f846942d4c407bbe49438ed859fe965b140dcf1aab71a9943ad0939e120f33518fbba04631afe7a3ed6327b194b2bbb170ca4e499a2b0f3cc85ebfa6e8c4dfcbea86048c27395000f846946bbad7cf34b5fa511d8e963dbba288b1960e75d694853b0f6c324d1f4e76c8266942337ac1b0af1a229442498946a51ca5924552ead6fc2af08b94fcba648601d1a94a2000f846944430b3230294d12c6ab2aac5c2cd68e80b16b581947b107f4976a252a6939b771202c28e64e03f52d694795811a7f214084116949fc4f53cedbf189eeab28601d1a94a2000f84694ea0a6e3c511bbd10f4519ece37dc24887e11b55d946811ca77acfb221a49393c193f3a22db829fcc8e9464feb7c04830dd9ace164fc5c52b3f5a29e5018a8601d1a94a2000f846947ae2f5b9e386cd1b50a4550696d957cb4900f03a94e83bcc5077e6b873995c24bac871b5ad856047e19464e48d4057a90b233e026c1041e6012ada897fe88601d1a94a2000f8469482012708dafc9e1b880fd083b32182b869be8e09948e5adc73a2d233a1b496ed3115464dd6c7b887509428b383d324bc9a37f4e276190796ba5a8947f5ed8601d1a94a2000f8469422b81f8e175ffde54d797fe11eb03f9e3bf75f1d94a1c3ef7ca38d8ba80cce3bfc53ebd2903ed21658942767f7447f7b9b70313d4147b795414aecea54718601d1a94a2000f8469468bf0b8b6fb4e317a0f9d6f03eaf8ce6675bc60d94675cfe570b7902623f47e7f59c9664b5f5065dcf94d84f0d2e50bcf00f2fc476e1c57f5ca2d57f625b8601d1a94a2000f846948c4d90829ce8f72d0163c1d5cf348a862d5506309485c42a7b34309bee2ed6a235f86d16f059deec5894cc2cedc53f0fa6d376336efb67e43d167169f3b78601d1a94a2000f8469435e7a025f4da968de7e4d7e4004197917f4070f194b1182abaeeb3b4d8eba7e6a4162eac7ace23d57394c4fd0d870da52e73de2dd8ded19fe3d26f43a1138601d1a94a2000f84694d6caa02bbebaebb5d7e581e4b66559e635f805ff94c07335cf083c1c46a487f0325769d88e163b653694efaff03b42e41f953a925fc43720e45fb61a19938601d1a94a2000

System file updated.
System reward file updated.
BSCValidatorSet file updated.
TokenHub file updated.
TendermintLightClient file updated.
RelayerIncentivize file updated.
CrossChain file updated.
System file updated.
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn solc ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn solc',
  path: 'solc',
  spawnargs: [
    '--bin-runtime',
    '/=/',
    '--optimize',
    '--optimize-runs',
    '200',
    'contracts/BSCValidatorSet.sol'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1

docs about Ramanujan and Niels

Hi, I'm working an external evm for bsc geth.
Normally, bsc geth is forked after Istanbul, but there are two forks owned by bsc chain (Ramanujan and Niels).
So i need to check if there are related to evm. Some i need some docs about them. Could any guy give a hand ?
Thanks!

The compiled contract cannot be run on the bsc chain

When I compiled BSCValidatorSet.sol on remix, I copied the code to genesis.json and reported the following error: "The compiled contract cannot be run on the bsc chain". The test can run on remix, but not on bsc. My code is as follows:

"0x608060405234801561001057600080fd5b5061446e806100206000396000f3fe6080604052600436106102e45760003560e01c80638624988211610190578063c8509d81116100dc578063eb57e20211610095578063f9a2bbc71161006f578063f9a2bbc714610a69578063fc3e590814610a7e578063fccc281314610a93578063fd6a687914610aa8576102e4565b8063eb57e202146109fb578063eda5868c14610a2e578063f340fa0114610a43576102e4565b8063c8509d81146106d8578063d86222d514610992578063daacdb66146109a7578063dc927faf146109bc578063e086c7b1146109d1578063e1c7392a146109e6576102e4565b8063aaf5eb6811610149578063ad3c9da611610123578063ad3c9da6146108e5578063b7ab4db514610918578063bf9f4995146104c0578063c81b16621461097d576102e4565b8063aaf5eb68146107f0578063ab51bb9614610805578063ac4317511461081a576102e4565b8063862498821461077257806396713da9146107875780639dc092621461079c578063a1a11bf5146107b1578063a5422d5c146107c6578063a78abc16146107db576102e4565b806351e806721161024f57806370fd5bad116102085780637942fd05116101e25780637942fd05146106ae57806381650b62146106c3578063831d65d1146106d8578063853230aa1461075d576102e4565b806370fd5bad1461066f57806375d47a0a1461068457806378dfed4a14610699576102e4565b806351e8067214610572578063565c56b3146105875780635667515a146105ba5780635d77156c146105cf5780636969a25c146105e45780636e47b4821461065a576102e4565b80633de0f0d8116102a15780633de0f0d8146104ab5780633dffc387146104c057806343756e5c146104eb578063493279b11461051c5780634bf6c882146105485780635192c82c1461055d576102e4565b80630bee7a67146102e95780631182b87514610317578063152ad3b8146104115780631ff180691461043a578063219f22d51461046157806335409f7f14610476575b600080fd5b3480156102f557600080fd5b506102fe610abd565b6040805163ffffffff9092168252519081900360200190f35b34801561032357600080fd5b5061039c6004803603604081101561033a57600080fd5b60ff8235169190810190604081016020820135600160201b81111561035e57600080fd5b82018360208201111561037057600080fd5b803590602001918460018302840111600160201b8311171561039157600080fd5b509092509050610ac2565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103d65781810151838201526020016103be565b50505050905090810190601f1680156104035780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041d57600080fd5b50610426610caf565b604080519115158252519081900360200190f35b34801561044657600080fd5b5061044f610cb8565b60408051918252519081900360200190f35b34801561046d57600080fd5b506102fe610cbe565b34801561048257600080fd5b506104a96004803603602081101561049957600080fd5b50356001600160a01b0316610cc3565b005b3480156104b757600080fd5b5061044f610fd7565b3480156104cc57600080fd5b506104d5610fdd565b6040805160ff9092168252519081900360200190f35b3480156104f757600080fd5b50610500610fe2565b604080516001600160a01b039092168252519081900360200190f35b34801561052857600080fd5b50610531610fe8565b6040805161ffff9092168252519081900360200190f35b34801561055457600080fd5b506104d5610fed565b34801561056957600080fd5b5061044f610ff2565b34801561057e57600080fd5b50610500610ff8565b34801561059357600080fd5b5061044f600480360360208110156105aa57600080fd5b50356001600160a01b0316610ffe565b3480156105c657600080fd5b506104d5611050565b3480156105db57600080fd5b506102fe611055565b3480156105f057600080fd5b5061060e6004803603602081101561060757600080fd5b503561105a565b604080516001600160a01b039788168152958716602087015293909516848401526001600160401b0390911660608401521515608083015260a082019290925290519081900360c00190f35b34801561066657600080fd5b506105006110be565b34801561067b57600080fd5b506104d56110c4565b34801561069057600080fd5b506105006110c9565b3480156106a557600080fd5b5061044f611050565b3480156106ba57600080fd5b506104d56110cf565b3480156106cf57600080fd5b506102fe6110d4565b3480156106e457600080fd5b506104a9600480360360408110156106fb57600080fd5b60ff8235169190810190604081016020820135600160201b81111561071f57600080fd5b82018360208201111561073157600080fd5b803590602001918460018302840111600160201b8311171561075257600080fd5b5090925090506110d9565b34801561076957600080fd5b5061044f61118c565b34801561077e57600080fd5b5061044f611192565b34801561079357600080fd5b506104d5611198565b3480156107a857600080fd5b5061050061119d565b3480156107bd57600080fd5b506105006111a3565b3480156107d257600080fd5b5061039c6111a9565b3480156107e757600080fd5b506104266111c5565b3480156107fc57600080fd5b5061044f6111ce565b34801561081157600080fd5b506102fe611050565b34801561082657600080fd5b506104a96004803603604081101561083d57600080fd5b810190602081018135600160201b81111561085757600080fd5b82018360208201111561086957600080fd5b803590602001918460018302840111600160201b8311171561088a57600080fd5b919390929091602081019035600160201b8111156108a757600080fd5b8201836020820111156108b957600080fd5b803590602001918460018302840111600160201b831117156108da57600080fd5b5090925090506111d7565b3480156108f157600080fd5b5061044f6004803603602081101561090857600080fd5b50356001600160a01b03166115ce565b34801561092457600080fd5b5061092d6115e0565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610969578181015183820152602001610951565b505050509050019250505060405180910390f35b34801561098957600080fd5b50610500611706565b34801561099e57600080fd5b5061044f61170c565b3480156109b357600080fd5b5061044f611718565b3480156109c857600080fd5b5061050061171e565b3480156109dd57600080fd5b5061044f611724565b3480156109f257600080fd5b506104a9611729565b348015610a0757600080fd5b506104a960048036036020811015610a1e57600080fd5b50356001600160a01b0316611929565b348015610a3a57600080fd5b506102fe611af8565b6104a960048036036020811015610a5957600080fd5b50356001600160a01b0316611afd565b348015610a7557600080fd5b50610500611dfe565b348015610a8a57600080fd5b506104d5611e04565b348015610a9f57600080fd5b50610500611e09565b348015610ab457600080fd5b50610500611e0f565b606481565b60005460609060ff16610b18576040805162461bcd60e51b81526020600482015260196024820152781d1a194818dbdb9d1c9858dd081b9bdd081a5b9a5d081e595d603a1b604482015290519081900360640190fd5b3361200014610b585760405162461bcd60e51b815260040180806020018281038252602f8152602001806143b4602f913960400191505060405180910390fd5b610b60614163565b6000610ba185858080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611e1592505050565b9150915080610bbd57610bb46064611f6e565b92505050610ca8565b815160009060ff16610bdd57610bd68360200151611fcf565b9050610c74565b825160ff1660011415610c7057826020015151600114610c4a577f70e72399380dcfb0338abc03dc8d47f9f470ada8e769c9a78d644ea97385ecb26040518080602001828103825260258152602001806142916025913960400191505060405180910390a1506067610c6b565b610bd68360200151600081518110610c5e57fe5b6020026020010151612dd5565b610c74565b5060655b63ffffffff8116610c995750506040805160008152602081019091529150610ca89050565b610ca281611f6e565b93505050505b9392505050565b60075460ff1681565b60035481565b606881565b3361100114610d035760405162461bcd60e51b81526004018080602001828103825260298152602001806144106029913960400191505060405180910390fd5b6001600160a01b03811660009081526004602052604090205480610d275750610fd4565b600181039050600060018281548110610d3c57fe5b60009182526020909120600360049092020101546001549091506000190180610d8b57600060018481548110610d6e57fe5b906000526020600020906004020160030181905550505050610fd4565b6040805183815290516001600160a01b038616917f3b6f9ef90462b512a1293ecec018670bf7b7f1876fb727590a8a6d7643130a70919081900360200190a26001600160a01b038416600090815260046020526040812055600154600019018314610f0d57600180546000198101908110610e0257fe5b906000526020600020906004020160018481548110610e1d57fe5b6000918252602082208354600492830290910180546001600160a01b03199081166001600160a01b0393841617825560018087015481840180548416918616919091179055600280880180549185018054909416919095161780835584546001600160401b03600160a01b91829004160267ffffffffffffffff60a01b1990911617808355935460ff600160e01b918290041615150260ff60e01b199094169390931790556003948501549401939093558254868401939192919087908110610ee257fe5b600091825260208083206004909202909101546001600160a01b031683528201929092526040019020555b6001805480610f1857fe5b60008281526020812060046000199093019283020180546001600160a01b0319908116825560018201805490911690556002810180546001600160e81b03191690556003018190559155818381610f6b57fe5b0490508015610fcf5760015460005b81811015610fcc578260018281548110610f9057fe5b9060005260206000209060040201600301540160018281548110610fb057fe5b6000918252602090912060036004909202010155600101610f7a565b50505b505050505b50565b61271081565b600181565b61100181565b606081565b600881565b60065481565b61200081565b6001600160a01b0381166000908152600460205260408120548061102657600091505061104b565b60018082038154811061103557fe5b9060005260206000209060040201600301549150505b919050565b600081565b606781565b6001818154811061106757fe5b600091825260209091206004909102018054600182015460028301546003909301546001600160a01b0392831694509082169291821691600160a01b81046001600160401b031691600160e01b90910460ff169086565b61100581565b600281565b61100881565b600b81565b606681565b33612000146111195760405162461bcd60e51b815260040180806020018281038252602f8152602001806143b4602f913960400191505060405180910390fd5b7f41ce201247b6ceb957dcdb217d0b8acb50b9ea0e12af9af4f5e7f38902101605838383604051808460ff1660ff168152602001806020018281038252848482818152602001925080828437600083820152604051601f909101601f1916909201829003965090945050505050a1505050565b6103e881565b60025481565b600981565b61100781565b61100681565b60405180608001604052806047815260200161434c6047913981565b60005460ff1681565b6402540be40081565b60005460ff1661122a576040805162461bcd60e51b81526020600482015260196024820152781d1a194818dbdb9d1c9858dd081b9bdd081a5b9a5d081e595d603a1b604482015290519081900360640190fd5b336110071461126a5760405162461bcd60e51b815260040180806020018281038252602e8152602001806142d7602e913960400191505060405180910390fd5b6112d484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080518082019091526013815272065787069726554696d655365636f6e6447617606c1b60208201529150612f4c9050565b156113af57602081146113185760405162461bcd60e51b81526004018080602001828103825260268152602001806143266026913960400191505060405180910390fd5b604080516020601f84018190048102820181019092528281526000916113569185858083850183828082843760009201919091525061303492505050565b90506064811015801561136c5750620186a08111155b6113a75760405162461bcd60e51b815260040180806020018281038252602781526020018061426a6027913960400191505060405180910390fd5b60025561153c565b61140f84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250506040805180820190915260098152686275726e526174696f60b81b60208201529150612f4c9050565b156114ff5760208114611469576040805162461bcd60e51b815260206004820152601c60248201527f6c656e677468206f66206275726e526174696f206d69736d6174636800000000604482015290519081900360640190fd5b604080516020601f84018190048102820181019092528281526000916114a79185858083850183828082843760009201919091525061303492505050565b90506127108111156114ea5760405162461bcd60e51b815260040180806020018281038252602b815260200180614214602b913960400191505060405180910390fd5b6006556007805460ff1916600117905561153c565b6040805162461bcd60e51b815260206004820152600d60248201526c756e6b6e6f776e20706172616d60981b604482015290519081900360640190fd5b7f6cdb0ac70ab7f2e2d035cca5be60d89906f2dede7648ddbd7402189c1eeed17a848484846040518080602001806020018381038352878782818152602001925080828437600083820152601f01601f191690910184810383528581526020019050858580828437600083820152604051601f909101601f19169092018290039850909650505050505050a150505050565b60046020526000908152604090205481565b6001546060906000805b8281101561163157600181815481106115ff57fe5b9060005260206000209060040201600201601c9054906101000a900460ff16611629576001909101905b6001016115ea565b5060608160405190808252806020026020018201604052801561165e578160200160208202803683370190505b50600092509050815b838110156116fe576001818154811061167c57fe5b9060005260206000209060040201600201601c9054906101000a900460ff166116f657600181815481106116ac57fe5b600091825260209091206004909102015482516001600160a01b03909116908390859081106116d757fe5b6001600160a01b03909216602092830291909101909101526001909201915b600101611667565b509250505090565b61100281565b67016345785d8a000081565b60055481565b61100381565b602981565b60005460ff1615611781576040805162461bcd60e51b815260206004820152601960248201527f74686520636f6e747261637420616c726561647920696e697400000000000000604482015290519081900360640190fd5b611789614163565b60006117ac60405180608001604052806047815260200161434c60479139611e15565b91509150806117ec5760405162461bcd60e51b81526004018080602001828103825260218152602001806143936021913960400191505060405180910390fd5b60005b8260200151518110156119115760018360200151828151811061180e57fe5b60209081029190910181015182546001818101855560009485528385208351600493840290910180546001600160a01b039283166001600160a01b03199182161782558587015182850180549185169183169190911790556040860151600283018054606089015160808a01511515600160e01b0260ff60e01b196001600160401b03909216600160a01b0267ffffffffffffffff60a01b199590981692909516919091179290921694909417161790915560a0909301516003909301929092559186015180519185019391859081106118e457fe5b602090810291909101810151516001600160a01b03168252810191909152604001600020556001016117ef565b50506103e8600255506000805460ff19166001179055565b33611001146119695760405162461bcd60e51b81526004018080602001828103825260298152602001806144106029913960400191505060405180910390fd5b6001600160a01b0381166000908152600460205260409020548061198d5750610fd4565b6001810390506000600182815481106119a257fe5b90600052602060002090600402016003015490506000600183815481106119c557fe5b906000526020600020906004020160030181905550600060018080549050039050836001600160a01b03167f8cd4e147d8af98a9e3b6724021b8bf6aed2e5dac71c38f2dce8161b82585b25d836040518082815260200191505060405180910390a280611a3457505050610fd4565b6000818381611a3f57fe5b0490508015610fcf5760005b84811015611a9d578160018281548110611a6157fe5b9060005260206000209060040201600301540160018281548110611a8157fe5b6000918252602090912060036004909202010155600101611a4b565b50600180549085015b81811015610fcc578260018281548110611abc57fe5b9060005260206000209060040201600301540160018281548110611adc57fe5b6000918252602090912060036004909202010155600101611aa6565b606581565b334114611b3b5760405162461bcd60e51b815260040180806020018281038252602d8152602001806143e3602d913960400191505060405180910390fd5b60005460ff16611b8e576040805162461bcd60e51b81526020600482015260196024820152781d1a194818dbdb9d1c9858dd081b9bdd081a5b9a5d081e595d603a1b604482015290519081900360640190fd5b60003411611bdb576040805162461bcd60e51b81526020600482015260156024820152746465706f7369742076616c7565206973207a65726f60581b604482015290519081900360640190fd5b6001600160a01b03811660009081526004602052604081205460075434929060ff1615611c0757506006545b600083118015611c175750600081115b15611cc0576000611c40612710611c34868563ffffffff61303916565b9063ffffffff61309216565b90508015611cbe5760405161dead9082156108fc029083906000818181858888f19350505050158015611c77573d6000803e3d6000fd5b506040805182815290517f627059660ea01c4733a328effb2294d2f86905bf806da763a89cee254de8bee59181900360200190a1611cbb848263ffffffff6130d416565b93505b505b8115611db8576000600180840381548110611cd757fe5b9060005260206000209060040201905080600201601c9054906101000a900460ff1615611d42576040805185815290516001600160a01b038716917ff177e5d6c5764d79c32883ed824111d9b13f5668cf6ab1cc12dd36791dd955b4919081900360200190a2611db2565b600354611d55908563ffffffff61311616565b6003908155810154611d6d908563ffffffff61311616565b60038201556040805185815290516001600160a01b038716917f93a090ecc682c002995fad3c85b30c5651d7fd29b0be5da9d784a3302aedc055919081900360200190a25b50611df8565b6040805184815290516001600160a01b038616917ff177e5d6c5764d79c32883ed824111d9b13f5668cf6ab1cc12dd36791dd955b4919081900360200190a25b50505050565b61100081565b600381565b61dead81565b61100481565b611e1d614163565b6000611e27614163565b611e2f61417b565b611e40611e3b86613170565b613195565b90506000805b611e4f836131df565b15611f605780611e7457611e6a611e6584613200565b61324e565b60ff168452611f58565b8060011415611f53576060611e90611e8b85613200565b613305565b90508051604051908082528060200260200182016040528015611ecd57816020015b611eba61419b565b815260200190600190039081611eb25790505b50602086015260005b8151811015611f4857611ee761419b565b6000611f05848481518110611ef857fe5b60200260200101516133d6565b9150915080611f2257876000995099505050505050505050611f69565b8188602001518481518110611f3357fe5b60209081029190910101525050600101611ed6565b506001925050611f58565b611f60565b600101611e46565b50919350909150505b915091565b604080516001808252818301909252606091829190816020015b6060815260200190600190039081611f88579050509050611fae8363ffffffff166134b3565b81600081518110611fbb57fe5b6020026020010181905250610ca8816134c6565b6000806060611fdd84613550565b915091508161208a577f70e72399380dcfb0338abc03dc8d47f9f470ada8e769c9a78d644ea97385ecb2816040518080602001828103825283818151815260200191508051906020019080838360005b8381101561204557818101518382015260200161202d565b50505050905090810190601f1680156120725780820380516001836020036101000a031916815260200191505b509250505060405180910390a160669250505061104b565b600080805b6001548110156121075767016345785d8a0000600182815481106120af57fe5b906000526020600020906004020160030154106120d1576001909201916120ff565b6000600182815481106120e057fe5b90600052602060002090600402016003015411156120ff576001909101905b60010161208f565b50606082604051908082528060200260200182016040528015612134578160200160208202803683370190505b509050606083604051908082528060200260200182016040528015612163578160200160208202803683370190505b509050606084604051908082528060200260200182016040528015612192578160200160208202803683370190505b5090506060856040519080825280602002602001820160405280156121c1578160200160208202803683370190505b50905060006060866040519080825280602002602001820160405280156121f2578160200160208202803683370190505b509050606087604051908082528060200260200182016040528015612221578160200160208202803683370190505b509050600098506000975060608d905060006110046001600160a01b031663149d14d96040518163ffffffff1660e01b815260040160206040518083038186803b15801561226e57600080fd5b505afa158015612282573d6000803e3d6000fd5b505050506040513d602081101561229857600080fd5b5051905067016345785d8a000081111561230d577f70e72399380dcfb0338abc03dc8d47f9f470ada8e769c9a78d644ea97385ecb26040518080602001828103825260218152602001806143056021913960400191505060405180910390a160689d505050505050505050505050505061104b565b60005b6001548110156125805767016345785d8a00006001828154811061233057fe5b906000526020600020906004020160030154106124b6576001818154811061235457fe5b906000526020600020906004020160020160009054906101000a90046001600160a01b03168a8d8151811061238557fe5b60200260200101906001600160a01b031690816001600160a01b03168152505060006402540be400600183815481106123ba57fe5b906000526020600020906004020160030154816123d357fe5b06600183815481106123e157fe5b90600052602060002090600402016003015403905061240983826130d490919063ffffffff16565b8a8e8151811061241557fe5b6020026020010181815250506001828154811061242e57fe5b906000526020600020906004020160020160009054906101000a90046001600160a01b0316888e8151811061245f57fe5b60200260200101906001600160a01b031690816001600160a01b03168152505081898e8151811061248c57fe5b60209081029190910101526124a7878263ffffffff61311616565b6001909d019c96506125789050565b6000600182815481106124c557fe5b906000526020600020906004020160030154111561257857600181815481106124ea57fe5b906000526020600020906004020160010160009054906101000a90046001600160a01b0316858c8151811061251b57fe5b60200260200101906001600160a01b031690816001600160a01b0316815250506001818154811061254857fe5b906000526020600020906004020160030154848c8151811061256657fe5b60209081029190910101526001909a01995b600101612310565b50600085156129be576110046001600160a01b0316636e056520878c8c8b60025442016040518663ffffffff1660e01b815260040180806020018060200180602001856001600160401b03166001600160401b03168152602001848103845288818151815260200191508051906020019060200280838360005b838110156126125781810151838201526020016125fa565b50505050905001848103835287818151815260200191508051906020019060200280838360005b83811015612651578181015183820152602001612639565b50505050905001848103825286818151815260200191508051906020019060200280838360005b83811015612690578181015183820152602001612678565b505050509050019750505050505050506020604051808303818588803b1580156126b957600080fd5b505af1935050505080156126df57506040513d60208110156126da57600080fd5b505160015b61291a576040516000815260443d10156126fb57506000612796565b60046000803e60005160e01c6308c379a0811461271c576000915050612796565b60043d036004833e81513d60248201116001600160401b038211171561274757600092505050612796565b80830180516001600160401b03811115612768576000945050505050612796565b8060208301013d860181111561278657600095505050505050612796565b601f01601f191660405250925050505b806127a15750612845565b60019150867fa7cdeed7d0db45e3219a6e5d60838824c16f1d39991fcfe3f963029c844bf280826040518080602001828103825283818151815260200191508051906020019080838360005b838110156128055781810151838201526020016127ed565b50505050905090810190601f1680156128325780820380516001836020036101000a031916815260200191505b509250505060405180910390a250612915565b3d80801561286f576040519150601f19603f3d011682016040523d82523d6000602084013e612874565b606091505b5060019150867fbfa884552dd8921b6ce90bfe906952ae5b3b29be0cc1a951d4f62697635a3a45826040518080602001828103825283818151815260200191508051906020019080838360005b838110156128d95781810151838201526020016128c1565b50505050905090810190601f1680156129065780820380516001836020036101000a031916815260200191505b509250505060405180910390a2505b6129be565b8015612958576040805188815290517fa217d08e65f80c73121cd9db834d81652d544bfbf452f6d04922b16c90a37b709181900360200190a16129bc565b604080516020808252601b908201527f6261746368207472616e736665722072657475726e2066616c7365000000000081830152905188917fa7cdeed7d0db45e3219a6e5d60838824c16f1d39991fcfe3f963029c844bf280919081900360600190a25b505b8015612b745760005b8851811015612b725760008982815181106129de57fe5b602002602001015190506000600182815481106129f757fe5b60009182526020909120600160049092020181015481546001600160a01b03909116916108fc9185908110612a2857fe5b9060005260206000209060040201600301549081150290604051600060405180830381858888f1935050505090508015612ae45760018281548110612a6957fe5b60009182526020909120600160049092020181015481546001600160a01b03909116917f6c61d60f69a7beb3e1c80db7f39f37b208537cbb19da3174511b477812b2fc7d9185908110612ab857fe5b9060005260206000209060040201600301546040518082815260200191505060405180910390a2612b68565b60018281548110612af157fe5b60009182526020909120600160049092020181015481546001600160a01b03909116917f25d0ce7d2f0cec669a8c17efe49d195c13455bb8872b65fa610ac7f53fe4ca7d9185908110612b4057fe5b9060005260206000209060040201600301546040518082815260200191505060405180910390a25b50506001016129c7565b505b845115612cbe5760005b8551811015612cbc576000868281518110612b9557fe5b60200260200101516001600160a01b03166108fc878481518110612bb557fe5b60200260200101519081150290604051600060405180830381858888f1935050505090508015612c4b57868281518110612beb57fe5b60200260200101516001600160a01b03167f6c61d60f69a7beb3e1c80db7f39f37b208537cbb19da3174511b477812b2fc7d878481518110612c2957fe5b60200260200101516040518082815260200191505060405180910390a2612cb3565b868281518110612c5757fe5b60200260200101516001600160a01b03167f25d0ce7d2f0cec669a8c17efe49d195c13455bb8872b65fa610ac7f53fe4ca7d878481518110612c9557fe5b60200260200101516040518082815260200191505060405180910390a25b50600101612b7e565b505b4715612d27576040805147815290517f6ecc855f9440a9282c90913bbc91619fd44f5ec0b462af28d127b116f130aa4d9181900360200190a1604051611002904780156108fc02916000818181858888f19350505050158015612d25573d6000803e3d6000fd5b505b60006003819055600555825115612d4157612d4183613632565b6110016001600160a01b031663fc4333cd6040518163ffffffff1660e01b8152600401600060405180830381600087803b158015612d7e57600080fd5b505af1158015612d92573d6000803e3d6000fd5b50506040517fedd8d7296956dd970ab4de3f2fc03be2b0ffc615d20cd4c72c6e44f928630ebf925060009150a15060009f9e505050505050505050505050505050565b80516001600160a01b0316600090815260046020526040812054801580612e265750600180820381548110612e0657fe5b9060005260206000209060040201600201601c9054906101000a900460ff165b15612e6c5782516040516001600160a01b03909116907fe209c46bebf57cf265d5d9009a00870e256d9150f3ed5281ab9d9eb3cec6e4be90600090a2600091505061104b565b600154600554600019820111801590612ec25784516040516001600160a01b03909116907fe209c46bebf57cf265d5d9009a00870e256d9150f3ed5281ab9d9eb3cec6e4be90600090a26000935050505061104b565b600580546001908101909155805481906000198601908110612ee057fe5b6000918252602082206002600490920201018054921515600160e01b0260ff60e01b199093169290921790915585516040516001600160a01b03909116917ff226e7d8f547ff903d9d419cf5f54e0d7d07efa9584135a53a057c5f1f27f49a91a2506000949350505050565b6000816040516020018082805190602001908083835b60208310612f815780518252601f199092019160209182019101612f62565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405160208183030381529060405280519060200120836040516020018082805190602001908083835b60208310612fef5780518252601f199092019160209182019101612fd0565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001201490505b92915050565b015190565b6000826130485750600061302e565b8282028284828161305557fe5b0414610ca85760405162461bcd60e51b81526004018080602001828103825260218152602001806142b66021913960400191505060405180910390fd5b6000610ca883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250613af3565b6000610ca883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250613b95565b600082820183811015610ca8576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6131786141d0565b506040805180820190915281518152602082810190820152919050565b61319d61417b565b6131a682613bef565b6131af57600080fd5b60006131be8360200151613c29565b60208085015160408051808201909152868152920190820152915050919050565b60006131e96141d0565b505080518051602091820151919092015191011190565b6132086141d0565b613211826131df565b61321a57600080fd5b6020820151600061322a82613c8c565b80830160209586015260408051808201909152908152938401919091525090919050565b80516000901580159061326357508151602110155b61326c57600080fd5b600061327b8360200151613c29565b905080836000015110156132d6576040805162461bcd60e51b815260206004820152601a60248201527f6c656e677468206973206c657373207468616e206f6666736574000000000000604482015290519081900360640190fd5b8251602080850151830180519284900392918310156132fc57826020036101000a820491505b50949350505050565b606061331082613bef565b61331957600080fd5b600061332483613dbf565b905060608160405190808252806020026020018201604052801561336257816020015b61334f6141d0565b8152602001906001900390816133475790505b50905060006133748560200151613c29565b60208601510190506000805b848110156133cb5761339183613c8c565b91506040518060400160405280838152602001848152508482815181106133b457fe5b602090810291909101015291810191600101613380565b509195945050505050565b6133de61419b565b60006133e861419b565b6133f061417b565b6133f985613195565b90506000805b613408836131df565b15611f6057806134335761342361341e84613200565b613e1b565b6001600160a01b031684526134ab565b806001141561345b5761344861341e84613200565b6001600160a01b031660208501526134ab565b80600214156134835761347061341e84613200565b6001600160a01b031660408501526134ab565b8060031415611f5357613498611e6584613200565b6001600160401b03166060850152600191505b6001016133ff565b606061302e6134c183613e35565b613f1b565b60608151600014156134e7575060408051600081526020810190915261104b565b6060826000815181106134f657fe5b602002602001015190506000600190505b83518110156135375761352d8285838151811061352057fe5b6020026020010151613f6d565b9150600101613507565b50610ca861354a825160c060ff16613fea565b82613f6d565b600060606029835111156135825760006040518060600160405280602981526020016141eb6029913991509150611f69565b60005b83518110156136185760005b8181101561360f578481815181106135a557fe5b6020026020010151600001516001600160a01b03168583815181106135c657fe5b6020026020010151600001516001600160a01b031614156136075760006040518060600160405280602b815260200161423f602b9139935093505050611f69565b600101613591565b50600101613585565b505060408051602081019091526000815260019150915091565b600154815160005b8281101561374f57600161364c61419b565b6001838154811061365957fe5b600091825260208083206040805160c08101825260049490940290910180546001600160a01b0390811685526001820154811693850193909352600281015492831691840191909152600160a01b82046001600160401b03166060840152600160e01b90910460ff16151560808301526003015460a082015291505b84811015613723578681815181106136e957fe5b6020026020010151600001516001600160a01b031682600001516001600160a01b0316141561371b5760009250613723565b6001016136d5565b5081156137455780516001600160a01b03166000908152600460205260408120555b505060010161363a565b50808211156137c457805b828110156137c257600180548061376d57fe5b60008281526020812060046000199093019283020180546001600160a01b03199081168255600182810180549092169091556002820180546001600160e81b031916905560039091019190915591550161375a565b505b60008183106137d357816137d5565b825b905060005b818110156139cf576138878582815181106137f157fe5b60200260200101516001838154811061380657fe5b60009182526020918290206040805160c08101825260049390930290910180546001600160a01b0390811684526001820154811694840194909452600281015493841691830191909152600160a01b83046001600160401b03166060830152600160e01b90920460ff161515608082015260039091015460a08201526140e2565b6139a257806001016004600087848151811061389f57fe5b6020026020010151600001516001600160a01b03166001600160a01b03168152602001908152602001600020819055508481815181106138db57fe5b6020026020010151600182815481106138f057fe5b6000918252602091829020835160049092020180546001600160a01b039283166001600160a01b0319918216178255928401516001820180549184169185169190911790556040840151600282018054606087015160808801511515600160e01b0260ff60e01b196001600160401b03909216600160a01b0267ffffffffffffffff60a01b1995909716929097169190911792909216939093171692909217905560a0909101516003909101556139c7565b6000600182815481106139b157fe5b9060005260206000209060040201600301819055505b6001016137da565b5082821115611df857825b82811015610fcf5760018582815181106139f057fe5b60209081029190910181015182546001818101855560009485528385208351600493840290910180546001600160a01b039283166001600160a01b03199182161782559585015181840180549184169188169190911790556040850151600282018054606088015160808901511515600160e01b0260ff60e01b196001600160401b03909216600160a01b0267ffffffffffffffff60a01b199590971692909a169190911792909216939093171695909517905560a09092015160039093019290925587519084019290889085908110613ac657fe5b602090810291909101810151516001600160a01b03168252810191909152604001600020556001016139da565b60008183613b7f5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613b44578181015183820152602001613b2c565b50505050905090810190601f168015613b715780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000838581613b8b57fe5b0495945050505050565b60008184841115613be75760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613b44578181015183820152602001613b2c565b505050900390565b8051600090613c005750600061104b565b6020820151805160001a9060c0821015613c1f5760009250505061104b565b5060019392505050565b8051600090811a6080811015613c4357600091505061104b565b60b8811080613c5e575060c08110801590613c5e575060f881105b15613c6d57600191505061104b565b60c0811015613c815760b51901905061104b565b60f51901905061104b565b80516000908190811a6080811015613ca75760019150613db8565b60b8811015613cbc57607e1981019150613db8565b60c0811015613d3657600060b78203600186019550806020036101000a865104915060018101820193505080831015613d30576040805162461bcd60e51b81526020600482015260116024820152706164646974696f6e206f766572666c6f7760781b604482015290519081900360640190fd5b50613db8565b60f8811015613d4b5760be1981019150613db8565b600060f78203600186019550806020036101000a865104915060018101820193505080831015613db6576040805162461bcd60e51b81526020600482015260116024820152706164646974696f6e206f766572666c6f7760781b604482015290519081900360640190fd5b505b5092915050565b8051600090613dd05750600061104b565b60008090506000613de48460200151613c29565b602085015185519181019250015b80821015613e1257613e0382613c8c565b60019093019290910190613df2565b50909392505050565b8051600090601514613e2c57600080fd5b61302e8261324e565b604080516020808252818301909252606091829190602082018180368337505050602081018490529050600067ffffffffffffffff198416613e7957506018613e9d565b6fffffffffffffffffffffffffffffffff198416613e9957506010613e9d565b5060005b6020811015613ed357818181518110613eb257fe5b01602001516001600160f81b03191615613ecb57613ed3565b600101613e9d565b60008160200390506060816040519080825280601f01601f191660200182016040528015613f08576020820181803683370190505b5080830196909652508452509192915050565b606081516001148015613f4d5750607f60f81b82600081518110613f3b57fe5b01602001516001600160f81b03191611155b15613f5957508061104b565b61302e613f6b8351608060ff16613fea565b835b6060806040519050835180825260208201818101602087015b81831015613f9e578051835260209283019201613f86565b50855184518101855292509050808201602086015b81831015613fcb578051835260209283019201613fb3565b508651929092011591909101601f01601f191660405250905092915050565b606068010000000000000000831061403a576040805162461bcd60e51b815260206004820152600e60248201526d696e70757420746f6f206c6f6e6760901b604482015290519081900360640190fd5b604080516001808252818301909252606091602082018180368337019050509050603784116140945782840160f81b8160008151811061407657fe5b60200101906001600160f81b031916908160001a905350905061302e565b606061409f85613e35565b90508381510160370160f81b826000815181106140b857fe5b60200101906001600160f81b031916908160001a9053506140d98282613f6d565b95945050505050565b805182516000916001600160a01b03918216911614801561411c575081602001516001600160a01b031683602001516001600160a01b0316145b8015614141575081604001516001600160a01b031683604001516001600160a01b0316145b8015610ca85750506060908101519101516001600160401b0390811691161490565b60408051808201909152600081526060602082015290565b604051806040016040528061418e6141d0565b8152602001600081525090565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a081019190915290565b60405180604001604052806000815260200160008152509056fe746865206e756d626572206f662076616c696461746f72732065786365656420746865206c696d6974746865206275726e526174696f206d757374206265206e6f2067726561746572207468616e2031303030306475706c696361746520636f6e73656e7375732061646472657373206f662076616c696461746f725365747468652065787069726554696d655365636f6e64476170206973206f7574206f662072616e67656c656e677468206f66206a61696c2076616c696461746f7273206d757374206265206f6e65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77746865206d6573736167652073656e646572206d75737420626520676f7665726e616e636520636f6e7472616374666565206973206c6172676572207468616e2044555354595f494e434f4d494e476c656e677468206f662065787069726554696d655365636f6e64476170206d69736d61746368f84580f842f840949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d791949fb29aac15b9a4b7f17c3385939b007540f4d791646661696c656420746f20706172736520696e69742076616c696461746f72536574746865206d6573736167652073656e646572206d7573742062652063726f737320636861696e20636f6e7472616374746865206d6573736167652073656e646572206d7573742062652074686520626c6f636b2070726f6475636572746865206d6573736167652073656e646572206d75737420626520736c61736820636f6e7472616374a2646970667358221220d718e0fe5c48343ce7492429fac411e317945acdb7eb528eb2c46595842799e464736f6c63430006040033"

[HELP] Where is the source code for 'custody addresses' and 'distributed in N+2 days' in the white paper?

Hello, I see the following introduction from the white paper:
https://github.com/bnb-chain/whitepaper/blob/master/WHITEPAPER.md#rewarding

The blocking reward will not be sent to validator right away, instead, they will be distributed and accumulated on a contract;
Upon receiving the validator set update into BSC, it will trigger a few cross-chain transfers to transfer the reward to custody addresses on the corresponding validators. The custody addresses are owned by the system so that the reward cannot be spent until the promised distribution to delegators happens.
In order to make the synchronization simpler and allocate time to accommodate slashing, the reward for N day will be only distributed in N+2 days. After the delegators get the reward, the left will be transferred to validators’ own reward addresses.

I see that the source code of bnb-chain/bsc adds a transaction at the end of the block.
consensus/parlia/parlia.go

func (p *Parlia) distributeToValidator(amount *big.Int, validator common.Address,
	state *state.StateDB, header *types.Header, chain core.ChainContext,
	txs *[]*types.Transaction, receipts *[]*types.Receipt, receivedTxs *[]*types.Transaction, usedGas *uint64, mining bool) error {
	// method
	method := "deposit"

	// get packed data
	data, err := p.validatorSetABI.Pack(method,
		validator,
	)
	if err != nil {
		log.Error("Unable to pack tx for deposit", "error", err)
		return err
	}
	// get system message
	msg := p.getSystemMessage(header.Coinbase, common.HexToAddress(systemcontracts.ValidatorContract), data, amount)
	// apply message
	return p.applyTransaction(msg, state, header, chain, txs, receipts, receivedTxs, usedGas, mining)
}

The transaction call bnb-chain/bsc-genesis-contract contracts\BSCValidatorSet.sol function deposit(address valAddr).

  function deposit(address valAddr) external payable onlyCoinbase onlyInit noEmptyDeposit{
    uint256 value = msg.value;
    uint256 index = currentValidatorSetMap[valAddr];

    uint256 curBurnRatio = INIT_BURN_RATIO;
    if (burnRatioInitialized) {
      curBurnRatio = burnRatio;
    }

    if (value > 0 && curBurnRatio > 0) {
      uint256 toBurn = value.mul(curBurnRatio).div(BURN_RATIO_SCALE);
      if (toBurn > 0) {
        address(uint160(BURN_ADDRESS)).transfer(toBurn);
        emit feeBurned(toBurn);

        value = value.sub(toBurn);
      }
    }

    if (index>0) {
      Validator storage validator = currentValidatorSet[index-1];
      if (validator.jailed) {
        emit deprecatedDeposit(valAddr,value);
      } else {
        totalInComing = totalInComing.add(value);
        validator.incoming = validator.incoming.add(value);
        emit validatorDeposit(valAddr,value);
      }
    } else {
      // get incoming from deprecated validator;
      emit deprecatedDeposit(valAddr,value);
    }
  }

Does the "distributed and accumulated on a contract" mentioned in the white paper refer to the field "validator.incoming" in the above contract?
And where is the source code for 'transfer the reward to custody addresses' and 'distributed in N+2 days' mentioned in the white paper?

Looking forward to and grateful for your reply!

Getting wrong decimals and total supply in test-deployment

I'm testing in how to create a token using truffle. I've replaced the ERC20 Interface with BEP20Token using the BEP20Token.template.

Using truffle migrate --fresh I'm doing a test deployment using Ganache (GUI version). Everything works fine at first look, but looking into the deployed contract shows me wrong decimals and total supply!

I've setup:

constructor() public {
    _name = 'Test Token';
    _symbol = 'test';
    _decimals = 18;
    _totalSupply = 1000000000 * 10 ** 18;
    _balances[msg.sender] = _totalSupply;

    emit Transfer(address(0), msg.sender, _totalSupply);
}

Ganache shows me after "deployment":

_totalSupply: uint 42013000
_decimals: uint 12
_symbol: string "test"
_name: string "Test Token"

I've also done a small modification in constructor being able to pass some fundamental properties, but setting them directly in the original constructor of my BEP20Token.sol (without my modifications as follows) also leads to the same issue. You may ignore it, I think the issue is somewhere else.
master...typoworx-de:patch-1

Compiling contracts fails when using npm

npm installs Solidity compiler version 0.6.12 even if explicitly requested to download version 0.6.4. The version range should be >=0.6.4 <0.7.0 for successful compile.

Most of the contracts are missing "SPDX-License-Identifier" header required by Solidity compiler.

Ask a question about handleSynPackage method in BSCValidatorSet.sol

/*********************** Cross Chain App Implement **************************/
  function handleSynPackage(uint8, bytes calldata msgBytes) onlyInit onlyCrossChainContract external override returns(bytes memory responsePayload) {
    (IbcValidatorSetPackage memory validatorSetPackage, bool ok) = decodeValidatorSetSynPackage(msgBytes);

This method has "onlyCrossChainContract", so it has to be called only by CrossChain.sol, but in test/BSCValidatorSet.js,
I see the test code like

 let arr = [validatorA,validatorB,validatorC,validatorD,validatorE];

    let packageBytes = validatorUpdateRlpEncode(arr, arr,arr);
    await validatorSetInstance.handleSynPackage(STAKE_CHANNEL_ID,packageBytes,{from: relayerAccount});

    // deposit A: 1e16 B:1e16 C:1e17, D: 1e18, E:1e19, deprecated: 1e18
    await validatorSetInstance.deposit(validatorA, {from: systemAccount, value: web3.utils.toBN(1e16) });
    await validatorSetInstance.deposit(validatorB, {from: systemAccount, value: web3.utils.toBN(1e16) });
    await validatorSetInstance.deposit(validatorC, {from: systemAccount, value: web3.utils.toBN(1e17) });
    await validatorSetInstance.deposit(validatorD, {from: systemAccount, value: web3.utils.toBN(1e18) });
    await validatorSetInstance.deposit(validatorE, {from: systemAccount, value: web3.utils.toBN(1e18) });
    await validatorSetInstance.deposit(deprecated, {from: systemAccount, value: web3.utils.toBN(1e18) });

    //add some dust incoming
    await validatorSetInstance.deposit(validatorE, {from: systemAccount, value: web3.utils.toBN(1e5) });

    packageBytes = validatorUpdateRlpEncode(arr, arr,arr);
    let tx = await validatorSetInstance.handleSynPackage(STAKE_CHANNEL_ID,packageBytes,{from: relayerAccount});

    let validatorABalance = await web3.eth.getBalance(validatorA);
    let validatorBBalance = await web3.eth.getBalance(validatorB);
    let validatorCBalance = await web3.eth.getBalance(validatorC);
    let validatorDBalance = await web3.eth.getBalance(validatorD);
    let validatorEBalance = await web3.eth.getBalance(validatorE);
    let deprecatedBalance = await web3.eth.getBalance(deprecated);

    assert.equal(validatorABalance,0);
    assert.equal(validatorBBalance,web3.utils.toBN(1e16));
    assert.equal(validatorCBalance,0);
    assert.equal(validatorDBalance,0);
    assert.equal(validatorEBalance,0);
    assert.equal(deprecatedBalance,0);

why the relayerAccount is able to call validatorSetInstance.handleSynPackage?

and another question, why validatorBBalance has value afterwards, whereas others do not. From my understanding, they should all not have any eth balance, for the deposit only transfer the eth from systemAccount to validatorSet contract, not to the five accounts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.