Skip to content

Commit d2bf5ef

Browse files
committed
remove epoch 434 shims
1 parent 358bac0 commit d2bf5ef

File tree

10 files changed

+31
-148
lines changed

10 files changed

+31
-148
lines changed

ex/config/runtime.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config :ama, :work_folder, work_folder
1515

1616
#load env
1717
#Envvar.load(Path.join([work_folder, ".env"]))
18-
config :ama, :snapshot_height, (System.get_env("SNAPSHOT_HEIGHT") || "41960861") |> :erlang.binary_to_integer()
18+
config :ama, :snapshot_height, (System.get_env("SNAPSHOT_HEIGHT") || "43401193") |> :erlang.binary_to_integer()
1919

2020
# https://snapshots.amadeus.bot/000041960861.zip
2121
# zip -0 -r 000037454455.zip db/

ex/lib/consensus/fabric_gen.ex

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,7 @@ defmodule FabricGen do
343343
#m = m ++ m_exit
344344
#m_rev = m_rev ++ m_exit_rev
345345

346-
mutations_hash = if entry.header.height >= RDBProtocol.forkheight() do
347-
RDB.vecpak_encode(receipts ++ m) |> Blake3.hash()
348-
else
349-
RDB.vecpak_encode(l ++ m) |> Blake3.hash()
350-
end
346+
mutations_hash = RDB.vecpak_encode(receipts ++ m) |> Blake3.hash()
351347

352348
RocksDB.put("temporal_tip", next_entry.hash, %{rtx: rtx, cf: cf.sysconf})
353349

ex/lib/consensus/models/entry.ex

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,34 +186,18 @@ defmodule Entry do
186186
if :crypto.hash(:sha256, ceh.dr) != neh.dr, do: throw(%{error: :invalid_dr})
187187
if !BlsEx.verify?(neh.signer, neh.vr, ceh.vr, BLS12AggSig.dst_vrf()), do: throw(%{error: :invalid_vr})
188188

189-
if neh.height >= RDBProtocol.forkheight() do
190-
191-
chain_epoch = div(neh.height, 100_000)
192-
chain_height = neh.height
193-
segment_vr_hash = DB.Chain.segment_vr_hash()
194-
diff_bits = DB.Chain.diff_bits()
195-
196-
Enum.reduce(next_entry.txs, %{}, fn(txu, batch_state)->
197-
case TXPool.validate_tx(txu, %{epoch: chain_epoch, height: chain_height, segment_vr_hash: segment_vr_hash, diff_bits: diff_bits, batch_state: batch_state}) do
198-
%{error: :ok, batch_state: batch_state} -> batch_state
199-
%{error: error} when error in [:invalid_tx_nonce, :not_enough_tx_exec_balance] -> throw %{error: error}
200-
_ -> batch_state
201-
end
202-
end)
203-
204-
else
205-
chain_epoch = DB.Chain.epoch()
189+
chain_epoch = div(neh.height, 100_000)
190+
chain_height = neh.height
206191
segment_vr_hash = DB.Chain.segment_vr_hash()
207192
diff_bits = DB.Chain.diff_bits()
208193

209194
Enum.reduce(next_entry.txs, %{}, fn(txu, batch_state)->
210-
case TXPool.validate_tx(txu, %{epoch: chain_epoch, segment_vr_hash: segment_vr_hash, diff_bits: diff_bits, batch_state: batch_state}) do
195+
case TXPool.validate_tx(txu, %{epoch: chain_epoch, height: chain_height, segment_vr_hash: segment_vr_hash, diff_bits: diff_bits, batch_state: batch_state}) do
211196
%{error: :ok, batch_state: batch_state} -> batch_state
212197
%{error: error} when error in [:invalid_tx_nonce, :not_enough_tx_exec_balance] -> throw %{error: error}
213198
_ -> batch_state
214199
end
215200
end)
216-
end
217201

218202
%{error: :ok}
219203
catch

ex/lib/consensus/models/tx.ex

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,9 @@ defmodule TX do
153153
end
154154

155155
def historical_cost(height, txu) do
156-
if height >= RDBProtocol.forkheight() do
157-
max(
158-
RDBProtocol.ama_1_cent(),
159-
RDBProtocol.cost_per_byte_historical() * byte_size(RDB.vecpak_encode(txu.tx)))
160-
else
161-
min(
156+
max(
162157
RDBProtocol.ama_1_cent(),
163-
max(
164-
RDBProtocol.ama_1_cent(),
165-
RDBProtocol.cost_per_byte_historical() * byte_size(RDB.vecpak_encode(txu.tx))))
166-
end
158+
RDBProtocol.cost_per_byte_historical() * byte_size(RDB.vecpak_encode(txu.tx)))
167159
end
168160

169161
def action(%{tx: %{actions: [action|_]}}), do: action

ex/lib/node/computor_gen.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ defmodule ComputorGen do
2525

2626
def handle_info(:tick, state) do
2727
state = cond do
28-
not Application.fetch_env!(:ama, :testnet) ->
28+
!state[:enabled] -> state
29+
!Application.fetch_env!(:ama, :testnet) ->
2930
IO.puts "Computor currently cannot find sols on mainnet due to difficulty. Do not waste CPU running it."
3031
state
31-
!state[:enabled] -> state
3232
!FabricSyncAttestGen.isQuorumIsInEpoch() ->
3333
IO.puts "🔴 cannot compute: out_of_sync"
3434
state

ex/lib/node/txpool.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ defmodule TXPool do
6464

6565
balance = Map.get_lazy(batch_state, {:balance, txu.tx.signer}, fn()-> DB.Chain.balance(txu.tx.signer) end)
6666
balance = balance - (RDBProtocol.reserve_ama_per_tx_exec() * 2)
67-
balance = if chain_height >= RDBProtocol.forkheight() do
68-
balance = balance - RDBProtocol.reserve_ama_per_tx_storage()
69-
else balance end
67+
balance = balance - RDBProtocol.reserve_ama_per_tx_storage()
7068
balance = balance - TX.historical_cost(chain_height, txu)
7169
if balance < 0, do: throw(%{error: :not_enough_tx_exec_balance, key: {txu.tx.nonce, txu.hash}})
7270
batch_state = Map.put(batch_state, {:balance, txu.tx.signer}, balance)

ex/native/rdb/src/consensus/bic/protocol.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,10 @@ pub const COST_PER_BYTE_HISTORICAL: i128 = 6_666; //cost to increase the ledger
1515
pub const COST_PER_BYTE_STATE: i128 = 16_666; //cost to grow the contract state
1616
pub const COST_PER_OP_WASM: i128 = 1; //cost to execute a wasm op
1717

18-
pub const COST_PER_DB_READ_BASE: i128 = 5_000;
19-
pub const COST_PER_DB_READ_BYTE: i128 = 50;
20-
pub const COST_PER_DB_WRITE_BASE: i128 = 25_000;
21-
pub const COST_PER_DB_WRITE_BYTE: i128 = 250;
22-
23-
pub const COST_PER_DB_READ_BASE2: i128 = 5_000 * 10;
24-
pub const COST_PER_DB_READ_BYTE2: i128 = 50 * 10;
25-
pub const COST_PER_DB_WRITE_BASE2: i128 = 25_000 * 10;
26-
pub const COST_PER_DB_WRITE_BYTE2: i128 = 250 * 10;
18+
pub const COST_PER_DB_READ_BASE: i128 = 5_000 * 10;
19+
pub const COST_PER_DB_READ_BYTE: i128 = 50 * 10;
20+
pub const COST_PER_DB_WRITE_BASE: i128 = 25_000 * 10;
21+
pub const COST_PER_DB_WRITE_BYTE: i128 = 250 * 10;
2722

2823
pub const COST_PER_DEPLOY: i128 = AMA_1_CENT; //cost to deploy contract
2924
pub const COST_PER_SOL: i128 = AMA_1_CENT; //cost to submit_sol

ex/native/rdb/src/consensus/bic/wasm.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ fn import_log_implementation(mut env: FunctionEnvMut<HostEnv>, ptr: i32, len: i3
6767
panic_any("exec_ptr_term_too_long")
6868
}
6969

70-
if applyenv.caller_env.entry_height >= protocol::FORKHEIGHT {
7170
crate::consensus::consensus_kv::storage_budget_decr(applyenv, protocol::COST_PER_BYTE_HISTORICAL * len as i128);
72-
} else {
73-
crate::consensus::consensus_kv::exec_budget_decr(applyenv, protocol::COST_PER_BYTE_HISTORICAL * len as i128);
74-
}
7571
set_remaining_points(&mut store, &instance, applyenv.exec_left.max(0) as u64);
7672

7773
let view = data.memory.clone().view(&store);

ex/native/rdb/src/consensus/consensus_apply.rs

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,7 @@ pub fn apply_entry<'db, 'a>(db: &'db TransactionDB<MultiThreaded>, pk: &[u8], sk
235235
applyenv.exec_track = false;
236236

237237
let tx_historical_cost = txu.map_get(crate::atoms::tx_historical_cost()).unwrap().decode::<i128>().unwrap();
238-
let mut exec_cost_total = ((tx_historical_cost + (applyenv.exec_max - applyenv.exec_left)) as u64).to_string();
239-
if applyenv.caller_env.entry_height >= protocol::FORKHEIGHT {
240-
exec_cost_total = ((tx_historical_cost + (applyenv.exec_max - applyenv.exec_left) + (applyenv.storage_max - applyenv.storage_left)) as u64).to_string();
241-
}
238+
let exec_cost_total = ((tx_historical_cost + (applyenv.exec_max - applyenv.exec_left) + (applyenv.storage_max - applyenv.storage_left)) as u64).to_string();
242239

243240
match res {
244241
Ok(result) => {
@@ -464,7 +461,7 @@ fn refund_exec_storage_deposit(applyenv: &mut ApplyEnv) {
464461
}
465462

466463
//Refund remainder of the storage deposit
467-
if applyenv.caller_env.entry_height >= protocol::FORKHEIGHT {
464+
{
468465
let refund = applyenv.storage_left.max(0);
469466
if refund > 0 {
470467
let key = &crate::bcat(&[b"account:", &applyenv.caller_env.account_origin, b":balance:AMA"]);
@@ -475,7 +472,6 @@ fn refund_exec_storage_deposit(applyenv: &mut ApplyEnv) {
475472
consensus_kv::kv_increment(applyenv, &crate::bcat(&[b"account:", &applyenv.caller_env.entry_signer, b":balance:AMA"]), cost/2);
476473
consensus_kv::kv_increment(applyenv, &crate::bcat(&[b"account:", &consensus::bic::coin::BURN_ADDRESS, b":balance:AMA"]), cost/2);
477474
}
478-
479475
applyenv.muts_final.append(&mut applyenv.muts);
480476
applyenv.muts_final_rev.append(&mut applyenv.muts_rev);
481477
}
@@ -501,27 +497,11 @@ fn call_txs_pre_upfront_cost<'a>(env: &mut ApplyEnv, txus: &[rustler::Term<'a>])
501497
let action = tx.map_get(crate::atoms::action()).unwrap().decode::<rustler::Term<'a>>().unwrap();
502498
let contract = action.map_get(crate::atoms::contract()).unwrap().decode::<rustler::Binary>().unwrap().to_vec();
503499
let function = action.map_get(crate::atoms::function()).unwrap().decode::<rustler::Binary>().unwrap().to_vec();
504-
match (contract.as_slice(), function.as_slice()) {
505-
//(b"Epoch", b"submit_sol") => {
506-
// if env.caller_env.entry_height >= protocol::FORKHEIGHT {
507-
// protocol::pay_cost(env, protocol::COST_PER_SOL)
508-
// }
509-
//},
510-
(b"Contract", b"deploy") => {
511-
if env.caller_env.entry_height >= protocol::FORKHEIGHT {
512-
} else {
513-
protocol::pay_cost(env, protocol::COST_PER_DEPLOY)
514-
}
515-
},
516-
(_, _) => ()
517-
}
518500

519501
//lock 0.1 AMA during execution
520502
consensus_kv::kv_increment(env, &crate::bcat(&[b"account:", &env.caller_env.account_origin, b":balance:AMA"]), -protocol::AMA_10_CENT);
521-
if env.caller_env.entry_height >= protocol::FORKHEIGHT {
522-
//lock 1.0 storage AMA during execution
523-
consensus_kv::kv_increment(env, &crate::bcat(&[b"account:", &env.caller_env.account_origin, b":balance:AMA"]), -protocol::AMA_1_DOLLAR);
524-
}
503+
//lock 1.0 storage AMA during execution
504+
consensus_kv::kv_increment(env, &crate::bcat(&[b"account:", &env.caller_env.account_origin, b":balance:AMA"]), -protocol::AMA_1_DOLLAR);
525505
}
526506
env.muts_final.append(&mut env.muts);
527507
env.muts_final_rev.append(&mut env.muts_rev);
@@ -683,12 +663,8 @@ fn call_bic(env: &mut ApplyEnv, contract: Vec<u8>, function: Vec<u8>, args: Vec<
683663
},
684664
(b"Epoch", b"slash_trainer") => consensus::bic::epoch::call_slash_trainer(env, args),
685665
(b"Contract", b"deploy") => {
686-
if env.caller_env.entry_height >= protocol::FORKHEIGHT {
687666
consensus_kv::exec_budget_decr(env, protocol::COST_PER_DEPLOY);
688667
consensus::bic::contract::call_deploy(env, args)
689-
} else {
690-
consensus::bic::contract::call_deploy(env, args)
691-
}
692668
},
693669
//(b"Lockup", b"unlock") => consensus::bic::lockup::call_unlock(env, args),
694670
//(b"LockupPrime", b"lock") => consensus::bic::lockup_prime::call_lock(env, args),

0 commit comments

Comments
 (0)