Skip to content

Commit

Permalink
eth/client: update default fees (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
q9f authored Oct 31, 2022
1 parent fb55de5 commit 1053e6c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/eth/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ReplayProtectionError < StandardError; end
# used by ledger wallets without EIP-155 replay protection.
#
# @param v [Integer] the signature's `v` value.
# @return [Boolean] true if ledger'#'s legacy value.
# @return [Boolean] true if ledger's legacy value.
def is_ledger?(v)
[0, 1].include? v
end
Expand Down
2 changes: 1 addition & 1 deletion lib/eth/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def self.create(host)
# use {Client.create} intead.
def initialize(_)
@id = 0
@max_priority_fee_per_gas = 0
@max_priority_fee_per_gas = Tx::DEFAULT_PRIORITY_FEE
@max_fee_per_gas = Tx::DEFAULT_GAS_PRICE
@gas_limit = Tx::DEFAULT_GAS_LIMIT
end
Expand Down
9 changes: 6 additions & 3 deletions lib/eth/tx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ class ParameterError < TypeError; end
# The minimum transaction gas limit required for a value transfer.
DEFAULT_GAS_LIMIT = 21_000.freeze

# The "default" transaction gas price of 20 GWei. Do not use.
DEFAULT_GAS_PRICE = (20 * Unit::GWEI).freeze
# The "default" transaction priority fee of 1.01 GWei. Do not use.
DEFAULT_PRIORITY_FEE = (1.01 * Unit::GWEI).freeze

# The "default" transaction gas price of 42.69 GWei. Do not use.
DEFAULT_GAS_PRICE = (42.69 * Unit::GWEI).freeze

# The calldata gas cost of a non-zero byte as per EIP-2028.
COST_NON_ZERO_BYTE = 16.freeze
Expand All @@ -55,7 +58,7 @@ class ParameterError < TypeError; end
COST_ADDRESS = 2_400.freeze

# The maximum transaction gas limit is bound by the block gas limit.
BLOCK_GAS_LIMIT = 25_000_000.freeze
BLOCK_GAS_LIMIT = 30_000_000.freeze

# The legacy transaction type is 0.
TYPE_LEGACY = 0x00.freeze
Expand Down
2 changes: 1 addition & 1 deletion spec/eth/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
expect(geth_dev_ipc.id).to eq 0
expect(geth_dev_ipc.chain_id).to eq Chain::PRIVATE_GETH
expect(geth_dev_ipc.default_account).to be_instance_of Address
expect(geth_dev_ipc.max_priority_fee_per_gas).to eq 0
expect(geth_dev_ipc.max_priority_fee_per_gas).to eq Tx::DEFAULT_PRIORITY_FEE
expect(geth_dev_ipc.max_fee_per_gas).to eq Tx::DEFAULT_GAS_PRICE
expect(geth_dev_ipc.gas_limit).to eq Tx::DEFAULT_GAS_LIMIT
end
Expand Down
2 changes: 1 addition & 1 deletion spec/eth/tx/eip1559_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
max_gas_fee: Unit::GWEI,
gas_limit: Tx::BLOCK_GAS_LIMIT + 1,
})
}.to raise_error Tx::ParameterError, "Invalid gas limit 25000001!"
}.to raise_error Tx::ParameterError, "Invalid gas limit 30000001!"
expect {
Tx.new({
nonce: -1,
Expand Down
2 changes: 1 addition & 1 deletion spec/eth/tx/eip2930_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
gas_price: Unit::GWEI,
gas_limit: Tx::BLOCK_GAS_LIMIT + 1,
})
}.to raise_error Tx::ParameterError, "Invalid gas limit 25000001!"
}.to raise_error Tx::ParameterError, "Invalid gas limit 30000001!"
expect {
Tx.new({
nonce: -1,
Expand Down
2 changes: 1 addition & 1 deletion spec/eth/tx/legacy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
gas_price: Unit::GWEI,
gas_limit: Tx::BLOCK_GAS_LIMIT + 1,
})
}.to raise_error Tx::ParameterError, "Invalid gas limit 25000001!"
}.to raise_error Tx::ParameterError, "Invalid gas limit 30000001!"
expect {
Tx.new({
nonce: -1,
Expand Down
5 changes: 3 additions & 2 deletions spec/eth/tx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
context "#GAS" do
it "defines gas limits" do
expect(Tx::DEFAULT_GAS_LIMIT).to eq 21_000
expect(Tx::DEFAULT_GAS_PRICE).to eq 20_000_000_000
expect(Tx::BLOCK_GAS_LIMIT).to eq 25_000_000
expect(Tx::DEFAULT_PRIORITY_FEE).to eq 1_010_000_000
expect(Tx::DEFAULT_GAS_PRICE).to eq 42_690_000_000
expect(Tx::BLOCK_GAS_LIMIT).to eq 30_000_000
end

it "defines gas costs" do
Expand Down

0 comments on commit 1053e6c

Please sign in to comment.