Skip to content

Commit

Permalink
chore: rename 'block_submit_when_n_txs' -> 'block_submit_after_n_txs'
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Nowosielski authored and Pawel Nowosielski committed Sep 11, 2020
1 parent e35fa95 commit b254d36
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

defmodule OMG.ChildChain.ReleaseTasks.SetBlockSubmitWhenNTxs do
defmodule OMG.ChildChain.ReleaseTasks.SetBlockSubmitAfterNTxs do
@moduledoc false
@behaviour Config.Provider
require Logger

@app :omg_child_chain
@config_key :block_submit_when_n_txs
@env_var_name "BLOCK_SUBMIT_WHEN_N_TXS"
@config_key :block_submit_after_n_txs
@env_var_name "BLOCK_SUBMIT_AFTER_N_TXS"

def init(args) do
args
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.

defmodule OMG.Childchain.ReleaseTasks.SetSubmitBlockWhenNTxsTest do
defmodule OMG.Childchain.ReleaseTasks.SetSubmitBlockAfterNTxsTest do
use ExUnit.Case, async: true
alias OMG.ChildChain.ReleaseTasks.SetBlockSubmitWhenNTxs
alias OMG.ChildChain.ReleaseTasks.SetBlockSubmitAfterNTxs

@app :omg_child_chain
@env_key "BLOCK_SUBMIT_WHEN_N_TXS"
@config_key :block_submit_when_n_txs
@env_key "BLOCK_SUBMIT_AFTER_N_TXS"
@config_key :block_submit_after_n_txs

test "that txs count is set when the env var is present" do
:ok = System.put_env(@env_key, "1234")
config = SetBlockSubmitWhenNTxs.load([], [])
block_submit_when_n_txs = config |> Keyword.fetch!(@app) |> Keyword.fetch!(@config_key)
assert block_submit_when_n_txs == 1234
config = SetBlockSubmitAfterNTxs.load([], [])
block_submit_after_n_txs = config |> Keyword.fetch!(@app) |> Keyword.fetch!(@config_key)
assert block_submit_after_n_txs == 1234
:ok = System.delete_env(@env_key)
end

test "that the default config is used when the env var is not set" do
old_config = Application.get_env(@app, @config_key)
:ok = System.delete_env(@env_key)
config = SetBlockSubmitWhenNTxs.load([], [])
block_submit_when_n_txs = config |> Keyword.fetch!(@app) |> Keyword.fetch!(@config_key)
assert block_submit_when_n_txs == old_config
config = SetBlockSubmitAfterNTxs.load([], [])
block_submit_after_n_txs = config |> Keyword.fetch!(@app) |> Keyword.fetch!(@config_key)
assert block_submit_after_n_txs == old_config
end

test "fails when env var value is not integer" do
:ok = System.put_env(@env_key, "not an integer")
assert_raise ArgumentError, fn -> SetBlockSubmitWhenNTxs.load([], []) end
assert_raise ArgumentError, fn -> SetBlockSubmitAfterNTxs.load([], []) end
:ok = System.delete_env(@env_key)
end
end
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ config :omg_child_chain,
submission_finality_margin: 20,
block_queue_eth_height_check_interval_ms: 6_000,
block_submit_every_nth: 1,
block_submit_when_n_txs: :infinity,
block_submit_after_n_txs: :infinity,
block_submit_max_gas_price: 20_000_000_000,
metrics_collection_interval: 60_000,
fee_adapter_check_interval_ms: 10_000,
Expand Down
2 changes: 1 addition & 1 deletion docs/deployment_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

- "BLOCK_SUBMIT_MAX_GAS_PRICE" - The maximum gas price to use for block submission. The first block submission after application boot will use the max price. The gas price gradually adjusts on subsequent blocks to reach the current optimum price . Defaults to `20000000000` (20 Gwei).
- "BLOCK_SUBMIT_EVERY_NTH" - submits block every `N` Ethereum blocks (unless block is empty). Default is 1 (plasma block in each Ethereum block).
- "BLOCK_SUBMIT_WHEN_N_TXS" - triggers block submission quicker than above n-Ethereum blocks if there are already `N` pending transactions.
- "BLOCK_SUBMIT_AFTER_N_TXS" - triggers block submission quicker than above n-Ethereum blocks if there are already `N` pending transactions.
- "FEE_ADAPTER" - The adapter to use to populate the fee specs. Either `file` or `feed` (case-insensitive). Defaults to `file` with an empty fee specs.
- "FEE_CLAIMER_ADDRESS" - 20-bytes HEX-encoded string of Ethereum address of Fee Claimer.
- "FEE_BUFFER_DURATION_MS" - Buffer period during which a fee is still valid after being updated.
Expand Down
2 changes: 1 addition & 1 deletion docs/details.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Affects how quick the services reading Ethereum events realize there's a new blo

* **`block_submit_every_nth`** - how many new Ethereum blocks must be mined, since previous submission **attempt**, before another block is going to be formed and submitted.

* **`block_submit_when_n_txs`** - pending transaction count that will trigger block submission faster than in required Ethereum's blocks (see: `block_submi_every_nth`). When not set defaults to infinity, effecively switching this feature off.
* **`block_submit_after_n_txs`** - pending transaction count that will trigger block submission faster than in required Ethereum's blocks (see: `block_submit_every_nth`). When not set defaults to infinity, effecively switching this feature off.

* **`block_submit_max_gas_price`** - the maximum gas price to use for block submission. The first block submission after application boot will use the max price,
and gradually adjusts to the current optimum price for subsequent blocks.
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ defmodule OMG.Umbrella.MixProject do
{OMG.Eth.ReleaseTasks.SetEthereumEventsCheckInterval, []},
{OMG.Eth.ReleaseTasks.SetEthereumStalledSyncThreshold, []},
{OMG.ChildChain.ReleaseTasks.SetBlockSubmitMaxGasPrice, []},
{OMG.ChildChain.ReleaseTasks.SetBlockSubmitWhenNTxs, []},
{OMG.ChildChain.ReleaseTasks.SetBlockSubmitAfterNTxs, []},
{OMG.ChildChain.ReleaseTasks.SetFeeClaimerAddress, []},
{OMG.ChildChain.ReleaseTasks.SetFeeBufferDuration, []},
{OMG.ChildChain.ReleaseTasks.SetFeeFileAdapterOpts, []},
Expand Down

0 comments on commit b254d36

Please sign in to comment.