Skip to content

Commit

Permalink
feat: add bridge_root to the pillar block
Browse files Browse the repository at this point in the history
  • Loading branch information
kstdl committed Apr 23, 2024
1 parent 8bf610a commit 70d549a
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 208 deletions.
2 changes: 1 addition & 1 deletion for_devs/local-net
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def generate_faucet_wallet(binary):
global faucet_public_address

wallet_path = f'./{data_dir}/faucet-wallet.json'

if os.path.isfile(wallet_path):
wallet = json.loads('{}')
with open(wallet_path) as json_file:
Expand Down
213 changes: 27 additions & 186 deletions for_devs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,198 +1,39 @@
aiohttp==3.9.2
aiosignal==1.3.1
anyio==4.0.0
apt-xapian-index==0.49
argcomplete==2.0.0
arrow==1.3.0
asn1crypto==1.5.1
aiohttp==3.8.5
async-timeout==4.0.3
attrs==23.1.0
Babel==2.10.3
bcrypt==4.0.1
binaryornot==0.4.4
bitarray==2.9.0
blinker==1.6.2
boto3==1.28.68
botocore==1.31.68
bottle==0.12.25
Brotli==1.0.9
build==0.10.0
CacheControl==0.13.1
certifi==2022.9.24
cffi==1.16.0
chardet==5.1.0
cleo==2.0.1
base58==2.1.1
bitarray==2.8.1
certifi==2024.2.2
chardet==5.2.0
click==8.1.6
click-configfile==0.2.3
colorama==0.4.6
command-not-found==0.3
conan==1.59.0
configparser==6.0.0
cookiecutter==2.4.0
crashtest==0.4.1
cryptography==42.0.4
cupshelpers==1.0
cytoolz==0.12.2
dbus-python==1.3.2
defer==1.0.6
distlib==0.3.7
distro==1.8.0
distro-info==1.5
docker==5.0.3
docker-compose==1.29.2
dockerpty==0.4.1
docopt==0.6.2
dulwich==0.21.6
eth-abi==5.0.1
eth-account==0.10.0
eth-abi==4.1.0
eth-account==0.9.0
eth-hash==0.5.2
eth-keyfile==0.7.0
eth-keyfile==0.6.1
eth-keys==0.4.0
eth-rlp==1.0.0
eth-typing==3.5.2
eth-utils==2.3.1
fabric==2.7.1
fasteners==0.19
fastimport==0.9.14
filelock==3.12.2
frozenlist==1.4.1
fuse-python==1.0.5
ghp-import==2.1.0
gpg==1.18.0
gyp==0.1
h11==0.14.0
hamlet==10.0.1
eth-rlp==0.3.0
eth-typing==3.4.0
eth-utils==2.2.0
hexbytes==0.3.1
html5lib==1.1
httpcore==0.18.0
httplib2==0.20.4
httpx==0.25.0
idna==3.3
importlib-metadata==4.12.0
importlib-resources==5.13.0
iniconfig==1.1.1
installer==0.7.0
invoke==1.7.3
jaraco.classes==3.2.1
jeepney==0.8.0
Jinja2==3.1.3
jmespath==0.10.0
joblib==1.2.0
jsonpointer==2.0
jsonschema==4.10.3
keyring==24.2.0
language-selector==0.1
launchpadlib==1.11.0
lazr.restfulclient==0.14.5
lazr.uri==1.0.6
livereload==2.6.3
lockfile==0.12.2
idna==3.4
ipfshttpclient==0.7.0
jsonschema==4.19.1
lru-dict==1.2.0
lunr==0.6.2
Markdown==3.4.4
markdown-it-py==3.0.0
MarkupSafe==2.1.3
marshmallow==3.20.1
mat==0.13.4
mdurl==0.1.2
mechanize==0.4.8
mergedeep==1.3.4
mkdocs==1.4.2
more-itertools==10.1.0
msgpack==1.0.3
multiaddr==0.0.9
multidict==6.0.4
mutagen==1.46.0
netifaces==0.11.0
nltk==3.8.1
node-semver==0.6.1
numpy==1.24.2
oauthlib==3.2.2
olefile==0.46
packaging==23.1
paramiko==3.4.0
netaddr==1.2.1
parsimonious==0.9.0
patch-ng==1.17.4
pathlib2==2.3.7.post1
pexpect==4.8.0
Pillow==10.2.0
pipx==1.2.0
pkginfo==1.8.2
platformdirs==3.10.0
pluggy==1.2.0
pluginbase==1.0.1
poetry==1.6.1
poetry-core==1.6.1
protobuf==4.25.1
psutil==5.9.4
ptyprocess==0.7.0
pycairo==1.24.0
pycparser==2.21
pycryptodome==3.19.0
pycryptodomex==3.19.1
pycups==2.0.1
Pygments==2.15.1
PyGObject==3.46.0
pyinotify==0.9.6
PyJWT==2.7.0
pylev==1.4.0
pylibacl==0.7.0
PyNaCl==1.5.0
pyparsing==3.1.0
pyproject_hooks==1.0.0
PyQt5==5.15.9
PyQt5-sip==12.12.2
pyrsistent==0.18.1
pytest==6.2.5
python-apt==2.6.0+ubuntu1
python-dateutil==2.8.2
python-debian==0.1.49+ubuntu2
python-dotenv==1.0.0
python-slugify==8.0.1
pytz==2023.3
pyunormalize==15.1.0
pyxattr==0.8.1
PyYAML==6.0
pyyaml_env_tag==0.1
regex==2022.10.31
protobuf==4.24.3
pycryptodome==3.18.0
pyrsistent==0.20.0
requests==2.31.0
requests-toolbelt==1.0.0
rich==13.3.1
rlp==4.0.0
s3transfer==0.7.0
SecretStorage==3.3.3
semver==2.13.0
shellingham==1.5.1
simple-term-menu==1.6.1
simplejson==3.19.1
rlp==3.0.0
six==1.16.0
sniffio==1.3.0
systemd-python==235
tabulate==0.9.0
text-unidecode==1.3
texttable==1.6.7
toml==0.10.2
tomlkit==0.12.1
toolz==0.12.0
tornado==6.3.2
tqdm==4.64.1
trove-classifiers==2023.7.6
types-python-dateutil==2.8.19.14
typing_extensions==4.9.0
ubuntu-advantage-tools==8001
ubuntu-drivers-common==0.0.0
ufw==0.36.2
unattended-upgrades==0.1
urllib3==1.26.16
usb-creator==0.3.16
userpath==1.9.0
virtualenv==20.24.1+ds
wadllib==1.3.6
watchdog==3.0.0
web3==6.12.0
webencodings==0.5.1
websocket-client==1.2.3
websockets==10.4
www-authenticate==0.9.2
xkit==0.0.0
yarl==1.9.4
yt-dlp==2023.11.14
zipp==1.0.0
typing-extensions==4.8.0
urllib3==2.0.5
varint==1.0.2
web3==6.10.0
websockets==11.0.3
yarl==1.9.2
28 changes: 15 additions & 13 deletions libraries/cli/include/cli/config_jsons/default/default_genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@
},
"initial_balances": {
"2cd4da7d3b345e022ca7e997c2bb3276a4d3d2e9": "0x1027e72f1f12813088000000",
"7e4aa664f71de4e9d0b4a6473d796372639bdcde": "0x1027e72f1f12813088000000"
"7e4aa664f71de4e9d0b4a6473d796372639bdcde": "0x27e72f1f12813088000000",
"fF310642f352E0b6b5266CE492e91D6af1241F41": "0x27e72f1f12813088000000с"
},
"gas_price": {
"blocks": 200,
"percentile": 60,
"minimum_price" : 1
"minimum_price": 1
},
"pbft": {
"committee_size": "0x3e8",
Expand Down Expand Up @@ -100,25 +101,26 @@
"hardforks": {
"fix_redelegate_block_num": 0,
"rewards_distribution_frequency": {
"0" : 100
"0": 100
},
"magnolia_hf" : {
"block_num" : 0,
"magnolia_hf": {
"block_num": 0,
"jail_time": 163459
},
"phalaenopsis_hf_block_num": 0,
"fix_claim_all_block_num": -1,
"aspen_hf" : {
"block_num_part_one" : 0,
"block_num_part_two" : 0,
"aspen_hf": {
"block_num_part_one": 0,
"block_num_part_two": 0,
"max_supply": "0x26C62AD77DC602DAE0000000",
"generated_rewards": "0x0"
},
"ficus_hf" : {
"block_num" : 0,
"pillar_block_periods" : 100,
"pillar_chain_sync_periods" : 25,
"pbft_inclusion_delay": 6
"ficus_hf": {
"block_num": 1000,
"pillar_block_periods": 100,
"pillar_chain_sync_periods": 25,
"pbft_inclusion_delay": 6,
"bridge_contract_address": "0xd3c087C17C0E8EA2084FB12ac8B1494AA1E7B749"
}
}
}
1 change: 1 addition & 0 deletions libraries/config/include/config/hardfork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct FicusHardforkConfig {
// previous pillar blocks and 2t+1 signatures for latest pillar block)
uint64_t pbft_inclusion_delay{
6}; // [periods] how many periods after the pillar block is created it is included in pbft block
taraxa::addr_t bridge_contract_address; // [address] of the bridge contract

bool isFicusHardfork(taraxa::PbftPeriod period) const;
bool isPillarBlockPeriod(taraxa::PbftPeriod period, uint64_t from_n_th_block = 1) const;
Expand Down
11 changes: 9 additions & 2 deletions libraries/config/src/hardfork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ void FicusHardforkConfig::validate(uint32_t delegation_delay) const {
if (pbft_inclusion_delay < 1 || pbft_inclusion_delay <= delegation_delay) {
throw taraxa::ConfigException("ficus_hf.pbft_inclusion_delay must be >= 1 && > dpos.delegation_delay");
}

if (bridge_contract_address == taraxa::addr_t()) {
throw taraxa::ConfigException("ficus_hf.bridge_contract_address must be set");
}
}

Json::Value enc_json(const FicusHardforkConfig& obj) {
Expand All @@ -95,6 +99,7 @@ Json::Value enc_json(const FicusHardforkConfig& obj) {
json["pillar_block_periods"] = dev::toJS(obj.pillar_block_periods);
json["pillar_chain_sync_periods"] = dev::toJS(obj.pillar_chain_sync_periods);
json["pbft_inclusion_delay"] = dev::toJS(obj.pbft_inclusion_delay);
json["bridge_contract_address"] = dev::toJS(obj.bridge_contract_address);
return json;
}

Expand All @@ -103,8 +108,10 @@ void dec_json(const Json::Value& json, FicusHardforkConfig& obj) {
obj.pillar_block_periods = dev::getUInt(json["pillar_block_periods"]);
obj.pillar_chain_sync_periods = dev::getUInt(json["pillar_chain_sync_periods"]);
obj.pbft_inclusion_delay = dev::getUInt(json["pbft_inclusion_delay"]);
obj.bridge_contract_address = taraxa::addr_t(json["bridge_contract_address"].asString());
}
RLP_FIELDS_DEFINE(FicusHardforkConfig, block_num, pillar_block_periods, pillar_chain_sync_periods, pbft_inclusion_delay)
RLP_FIELDS_DEFINE(FicusHardforkConfig, block_num, pillar_block_periods, pillar_chain_sync_periods, pbft_inclusion_delay,
bridge_contract_address)

Json::Value enc_json(const HardforksConfig& obj) {
Json::Value json(Json::objectValue);
Expand Down Expand Up @@ -158,4 +165,4 @@ void dec_json(const Json::Value& json, HardforksConfig& obj) {
}

RLP_FIELDS_DEFINE(HardforksConfig, fix_redelegate_block_num, redelegations, rewards_distribution_frequency, magnolia_hf,
phalaenopsis_hf_block_num, fix_claim_all_block_num, aspen_hf)
phalaenopsis_hf_block_num, fix_claim_all_block_num, aspen_hf, ficus_hf)
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ class FinalChain {
*/
virtual u256 dpos_total_supply(EthBlockNumber blk_num) const = 0;

/**
* @param blk_num
* @return bridge root
*/
virtual h256 get_bridge_root(EthBlockNumber blk_num) const = 0;

// TODO move out of here:

std::pair<val_t, bool> getBalance(addr_t const& addr) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class StateAPI {
std::vector<ValidatorVoteCount> dpos_validators_vote_counts(EthBlockNumber blk_num) const;
uint64_t dpos_yield(EthBlockNumber blk_num) const;
u256 dpos_total_supply(EthBlockNumber blk_num) const;
h256 get_bridge_root(const addr_t& bridge_contract_address, EthBlockNumber blk_num) const;
};
/** @} */

Expand Down
12 changes: 9 additions & 3 deletions libraries/core_libs/consensus/src/final_chain/final_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class FinalChainImpl final : public FinalChain {

std::atomic<EthBlockNumber> last_block_number_;

const HardforksConfig& hardforks_config_;
LOG_OBJECTS_DEFINE

public:
Expand Down Expand Up @@ -72,9 +73,10 @@ class FinalChainImpl final : public FinalChain {
dpos_vote_count_cache_(
config.final_chain_cache_in_blocks,
[this](uint64_t blk, const addr_t& addr) { return state_api_.dpos_eligible_vote_count(blk, addr); }),
dpos_is_eligible_cache_(config.final_chain_cache_in_blocks, [this](uint64_t blk, const addr_t& addr) {
return state_api_.dpos_is_eligible(blk, addr);
}) {
dpos_is_eligible_cache_(
config.final_chain_cache_in_blocks,
[this](uint64_t blk, const addr_t& addr) { return state_api_.dpos_is_eligible(blk, addr); }),
hardforks_config_(config.genesis.state.hardforks) {
LOG_OBJECTS_CREATE("EXECUTOR");
num_executed_dag_blk_ = db_->getStatusField(taraxa::StatusDbField::ExecutedBlkCount);
num_executed_trx_ = db_->getStatusField(taraxa::StatusDbField::ExecutedTrxCount);
Expand Down Expand Up @@ -468,6 +470,10 @@ class FinalChainImpl final : public FinalChain {

u256 dpos_total_supply(EthBlockNumber blk_num) const override { return state_api_.dpos_total_supply(blk_num); }

h256 get_bridge_root(EthBlockNumber blk_num) const override {
return state_api_.get_bridge_root(hardforks_config_.ficus_hf.bridge_contract_address, blk_num);
}

private:
std::shared_ptr<TransactionHashes> get_transaction_hashes(std::optional<EthBlockNumber> n = {}) const {
const auto& trxs = db_->getPeriodTransactions(last_if_absent(n));
Expand Down
Loading

0 comments on commit 70d549a

Please sign in to comment.