Skip to content

Commit

Permalink
Prevent unexpected scheduling of network tx (#538)
Browse files Browse the repository at this point in the history
* Add unregister for address notification
* Restrict for node shared secrets tx
* Restrict oracle txs
* Restrict rewards txs
* Add generation of network transaction with specific index
  • Loading branch information
Samuel authored and Samuel committed Aug 25, 2022
1 parent 9df92fe commit d762fde
Show file tree
Hide file tree
Showing 16 changed files with 843 additions and 527 deletions.
5 changes: 3 additions & 2 deletions lib/archethic/bootstrap/network_init.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ defmodule Archethic.Bootstrap.NetworkInit do
SharedSecrets.new_node_shared_secrets_transaction(
[Crypto.first_node_public_key()],
daily_nonce_seed,
secret_key
secret_key,
0
)

tx
Expand Down Expand Up @@ -149,7 +150,7 @@ defmodule Archethic.Bootstrap.NetworkInit do
def init_network_reward_pool() do
Logger.info("Create mining reward pool")

Reward.new_rewards_mint(@genesis_network_pool_amount)
Reward.new_rewards_mint(@genesis_network_pool_amount, 0)
|> self_validation()
|> self_replication()
end
Expand Down
6 changes: 1 addition & 5 deletions lib/archethic/oracle_chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ defmodule Archethic.OracleChain do
alias __MODULE__.Summary

alias Archethic.TransactionChain.Transaction
alias Archethic.TransactionChain.Transaction.ValidationStamp

alias Crontab.CronExpression.Parser, as: CronParser
alias Crontab.Scheduler, as: CronScheduler
Expand Down Expand Up @@ -79,11 +78,8 @@ defmodule Archethic.OracleChain do
Load the transaction in the memtable
"""
@spec load_transaction(Transaction.t()) :: :ok
def load_transaction(
tx = %Transaction{type: :oracle, validation_stamp: %ValidationStamp{timestamp: timestamp}}
) do
def load_transaction(tx = %Transaction{type: :oracle}) do
MemTableLoader.load_transaction(tx)
Scheduler.ack_transaction(timestamp)
end

def load_transaction(tx = %Transaction{type: :oracle_summary}) do
Expand Down
Loading

0 comments on commit d762fde

Please sign in to comment.