Skip to content

Showing 1 - 20 of 48 code results for  tendermint  in

of Ercoin / Ercoin


PROJECT = ercoin
PROJECT_DESCRIPTION = A simple cryptocurrency using Tendermint
PROJECT_VERSION = 1.0.2
init: $(ERCOIN_CONFIG)/priv_validator_key.json $(ERCOIN_CONFIG)/config.toml.patched $(ERCOIN_CONFIG)/genesis.json.custom
# This dependency is added to ensure that our genesis.json overwrites the Tendermint-generated one, not vice-versa.
$(ERCOIN_CONFIG)/genesis.json.custom: $(ERCOIN_CONFIG)/genesis.json
$(ERCOIN_CONFIG) $(ERCOIN_CONFIG)/priv_validator_key.json $(ERCOIN_CONFIG)/config.toml:
	$(gen_verbose) tendermint init --home $(ERCOIN_HOME)
$(ERCOIN_CONFIG)/config.toml.patched: $(ERCOIN_CONFIG)/config.toml
# Ercoin
Ercoin is a proof of stake cryptocurrency written in [Erlang](https://www.erlang.org) using [Tendermint](https://tendermint.com) and released under Apache License 2.0.
[Issues are tracked on GitLab.](https://gitlab.com/Ercoin/ercoin/issues) Contributions are welcome. Before submitting a patch, read [contributing guidelines](CONTRIBUTING.md).
## Development installation
1. Install [Tendermint](https://tendermint.com) (version 0.33.0).
2. Install [Erlang](https://www.erlang.org) (21 is the minimum version).
3. Install [libsodium](https://libsodium.org) (1.0.12 is the minimum version; when using a package manager, you may need to install a separate package containing development files).
6. Initialize the chain (see below).
7. `make run`
8. In another window, run `tendermint node --home ~/.ercoin/`
### Initializing the chain
## Persistence and initial state
ABCI server dumps current state to `$ERCOIN_HOME` (with fallback to `~/.ercoin`) at the beginning of each epoch. The initial state, encoded using Base64, is contained as `app_state` in the `genesis.json` file in Tendermint config directory.
State is serialized using [Erlang’s External Term Format](http://erlang.org/doc/apps/erts/erl_ext_dist.html).
1. `docker-compose build`
2. `docker volume create --name=ercoin_home`
3. `docker-compose run --no-deps tendermint init`
4. `docker-compose run abci-server make testnet < testnet-config.script`
5. `docker-compose up`
#### Transactions
Validators are responsible for providing replay protection. Transactions which provide timestamps are valid only for the epoch length. Due to [issue #2840 in Tendermint](https://github.com/tendermint/tendermint/issues/2840), timestamps from the near future (up to and including epoch length) are also allowed.
Transfer transactions modify accounts’ balances. They may not be performed from a locked account, but they can transfer funds to a locked account.
1. Do you accept the described method of proceeding (including this set of questions)?
2. Should we wait until Tendermint 0.33 is released? If so, then launch will happen a week after that release happens, rounded up to midnight (UTC). Fee voting will end a day before the launch. If the decision is made to not wait, then the launch time will likely need a separate voting.
3. Should we accept transactions confirmed shortly after the distribution deadline, but with creation timestamps before the deadline? To be precise: there is only one such transaction. If yes, then problematic outputs will have the missing part of the fee (amount that would be sufficient to confirm the transaction quickly, i.e. to make it relayed by the BlackCoin Original wallet) deducted from their value.
4. Should we accept transactions containing burn outputs resembling unlocked Ercoin accounts, but with incomplete (invalid) signatures? If yes, then problematic outputs will have the missing part of the fee (amount which would be additionally needed if a transaction contained a complete signature in case of a simple address) deducted from their value. Note that there are no transaction outputs for locked accounts and which contain incomplete signatures.
Remaining bits should be set to zero. Voting on points 1, 3 and 4 ends on 2020-01-19 00:00:00 UTC. Initial decision on point 2 is made at the same time, but it may be changed (by putting fresher votes) until the release of Tendermint 0.33 happens.
Validators will be drawn using the original rules (including original distribution). Note that problematic burn transactions do not involve locked accounts.
#### Voting outcome
All questions were answered positively. Tendermint 0.33 was released on 2020-01-15 (UTC), hence the launch has been scheduled to 2020-01-23 00:00:00 (UTC).
## License
    volumes:
      - ercoin_home:/ercoin
  tendermint:
    image: tendermint/tendermint:0.33.0
    ports:
      - "26656:26656"
      - "26657:26657"
    volumes:
      - ercoin_home:/tendermint
    links:
      - abci-server
    command: node --home /tendermint --proxy_app tcp://abci-server:26658
volumes:
handle_event({call, From}, #'tendermint.abci.types.RequestCheckTx'{tx=MaybeTxBin}, _, Data=#data{mempool_data=MempoolData}) ->
    {ErrorCode, NewMempoolData} =
        ercoin_tx:handle_bin(
          ercoin_data:apply_shift_to_now(MempoolData),
          ercoin_tx:default_age_margin(MempoolData) * 3 div 4),
    {keep_state, Data#data{mempool_data=NewMempoolData}, {reply, From, #'tendermint.abci.types.ResponseCheckTx'{code=ErrorCode}}};
handle_event({call, From}, #'tendermint.abci.types.RequestCommit'{}, committing, Data) ->
    Response = #'tendermint.abci.types.ResponseCommit'{data=ercoin_data:app_hash(Data)},
    Reply = {reply, From, Response},
    Actions =
handle_event(
  {call, From},
  #'tendermint.abci.types.RequestEndBlock'{},
  committing,
  Data=
        end,
    Data1 = Data#data{height=Height + 1},
    {keep_state, Data1, {reply, From, #'tendermint.abci.types.ResponseEndBlock'{validator_updates=Diffs}}};
handle_event({call, From}, #'tendermint.abci.types.RequestDeliverTx'{tx=MaybeTxBin}, committing, Data)->
    {ErrorCode, NewData} = ercoin_tx:handle_bin(MaybeTxBin, Data),
    Events =
        end,
    {keep_state, NewData, {reply, From, #'tendermint.abci.types.ResponseDeliverTx'{code=ErrorCode, events=Events}}};
handle_event({call, _}, _, committing, _) ->
    {keep_state_and_data, postpone};
handle_event(
  {call, From},
  #'tendermint.abci.types.RequestBeginBlock'{
     last_commit_info=#'tendermint.abci.types.LastCommitInfo'{votes=Votes},
     header=#'tendermint.abci.types.Header'{time=NewTimestampProto}},
  gossiping,
  Data=#data{timestamp=OldTimestamp, previous_timestamp=OldPreviousTimestamp}) ->
    NewTimestamp = ercoin_timestamp:from_protobuf(NewTimestampProto),
    ValidatorsWithPresence =
        [{ercoin_validators:key_value_by_tendermint_address(TendermintAddress, Data), Signed}
         || #'tendermint.abci.types.VoteInfo'{signed_last_block=Signed, validator=#'tendermint.abci.types.Validator'{address=TendermintAddress}} <- Votes],
    {Data1, Events} = ercoin_data:shift_to_timestamp(NewTimestamp, Data),
    ABCIEvents = [ercoin_event:to_abci(Event) || Event <- Events],
          OldTimestamp - OldPreviousTimestamp,
          ValidatorsWithPresence),
    {next_state, committing, NewData, {reply, From, #'tendermint.abci.types.ResponseBeginBlock'{events=ABCIEvents}}};
handle_event({call, From}, Query, gossiping, Data) when is_record(Query, 'tendermint.abci.types.RequestQuery') ->
    {keep_state_and_data, {reply, From, ercoin_query:perform(Query, Data)}};
handle_event({call, From}, #'tendermint.abci.types.RequestInfo'{}, gossiping, Data) ->
    Response =
        #'tendermint.abci.types.ResponseInfo'{
           last_block_app_hash=ercoin_data:app_hash(Data),
           last_block_height=Data#data.height},
    ok = ercoin_persistence:dump_data_async(Data),
    keep_state_and_data;
handle_event({call, From}, #'tendermint.abci.types.RequestInitChain'{app_state_bytes=AppStateJSON}, uninitialized, none) ->
    Data = #data{validators=Validators} = binary_to_term(base64:decode(jiffy:decode(AppStateJSON))),
    TendermintValidators = [#'tendermint.abci.types.ValidatorUpdate'{pub_key=#'tendermint.abci.types.PubKey'{data=PK, type="ed25519"}, power=Power} || {PK, <<Power, _/binary>>} <- gb_merkle_trees:to_orddict(Validators)],
    {next_state, gossiping, Data, {reply, From, #'tendermint.abci.types.ResponseInitChain'{validators=TendermintValidators}}};
handle_event({call, From}, #'tendermint.abci.types.RequestInfo'{}, uninitialized, _) ->
    Reply = #'tendermint.abci.types.ResponseInfo'{last_block_height=0, last_block_app_hash= <<>>},
    {keep_state_and_data, {reply, From, Reply}};
handle_event(enter, _, gossiping, Data) ->
    gen_statem:call(?MODULE, Request).
-spec calculate_diffs(gb_merkle_trees:tree(), gb_merkle_trees:tree()) -> list(#'tendermint.abci.types.ValidatorUpdate'{}).
calculate_diffs(New, Old) ->
    KeysFun =