Skip to content

Commit

Permalink
fix(prep): prep settings for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Jun 24, 2024
1 parent f17df54 commit 9c8c4af
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"scripts": {
"build": "node tools/bundle-aos.js",
"test": "yarn build && node --test --test-concurrency 1 **/*.test.js"
"test": "yarn build && node --test --test-concurrency 1 --experimental-wasm-memory64 **/*.test.js"
},
"devDependencies": {
"prettier": "^3.3.2",
Expand Down
1 change: 1 addition & 0 deletions src/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ constants.DEADLINE_DURATION_MS = 60 * 60 * 1000 -- One hour of miliseconds
constants.oneYearSeconds = 60 * 60 * 24 * 365
constants.thirtyDaysSeconds = 60 * 60 * 24 * 30
constants.defaultundernameLimit = 10
constants.totalTokenSupply = 1000000000 * 1000000 -- 1 billion tokens

-- ARNS
constants.DEFAULT_UNDERNAME_COUNT = 10
Expand Down
4 changes: 2 additions & 2 deletions src/demand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local demand = {}
DemandFactor = DemandFactor
or {
startTimestamp = 0, -- TODO: The timestamp at which the contract was initialized
currentPeriod = 0, -- TODO: the # of days since the last demand factor adjustment
currentPeriod = 0,
trailingPeriodPurchases = { 0, 0, 0, 0, 0, 0, 0 }, -- Acts as a ring buffer of trailing period purchase counts
trailingPeriodRevenues = { 0, 0, 0, 0, 0, 0 }, -- Acts as a ring buffer of trailing period revenues
purchasesThisPeriod = 0,
Expand All @@ -18,7 +18,7 @@ DemandFactor = DemandFactor

local demandFactorSettings = {
movingAvgPeriodCount = 7,
periodLengthMs = 60 * 1000 * 24, -- one day
periodLengthMs = 60 * 60 * 1000 * 24, -- one day in milseconds
demandFactorBaseValue = 1,
demandFactorMin = 0.5,
demandFactorUpAdjustment = 0.05,
Expand Down
8 changes: 3 additions & 5 deletions src/epochs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local crypto = require("crypto.init")
local utils = require("utils")
local balances = require("balances")
local arns = require("arns")
local json = require("json")
local epochs = {}

Epochs = Epochs
Expand All @@ -23,13 +22,12 @@ Epochs = Epochs
}

local epochSettings = {
-- TODO: make these configurable
prescribedNameCount = 5,
rewardPercentage = 0.0025, -- 0.25%
rewardPercentage = 0.0005, -- 0.05%
maxObservers = 50,
epochZeroStartTimestamp = 0,
epochZeroStartTimestamp = 1719900000000, -- July 2nd, 00:00:00 UTC
durationMs = 60 * 1000 * 60 * 24, -- 24 hours
distributionDelayMs = 60 * 1000 * 2 * 15, -- 15 blocks / 30 minutes
distributionDelayMs = 60 * 1000 * 30, -- 15 blocks / 30 minutes
}

function epochs.getEpochs()
Expand Down
8 changes: 3 additions & 5 deletions src/gar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ local garSettings = {
observers = {
maxPerEpoch = 50,
tenureWeightDays = 180,
tenureWeightPeriod = 180 * 24 * 60 * 60 * 1000,
tenureWeightPeriod = 180 * 24 * 60 * 60 * 1000, -- aproximately 2 years
maxTenureWeight = 4,
},
operators = {
minStake = 10000 * 1000000, -- 10,000 IO
minStake = 50000 * 1000000, -- 50,000 IO
withdrawLengthMs = 30 * 24 * 60 * 60 * 1000, -- 30 days to lower operator stake
maxDelegates = 10000,
leaveLengthMs = 90 * 24 * 60 * 60 * 1000, -- 90 days that balance will be vaulted
},
delegates = {
minStake = 50 * 1000000, -- 50 IO
minStake = 500 * 1000000, -- 500 IO
withdrawLengthMs = 30 * 24 * 60 * 60 * 1000, -- 30 days
minLockLengthMs = 24 * 60 * 60 * 1000, -- 1 day
maxLockLengthMs = 3 * 365 * 24 * 60 * 60 * 1000, -- 3 years
},
}

Expand Down
16 changes: 12 additions & 4 deletions src/main.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
-- Adjust package.path to include the current directory
local process = { _version = "0.0.1" }
local constants = require("constants")

Name = "Devnet IO"
Ticker = "dIO"
Name = Name or "Testnet IO"
Ticker = Ticker or "tIO"
Logo = "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A"
Denomination = 6
DemandFactor = DemandFactor or {}
Owner = Owner or ao.env.Process.Owner
Balances = Balances or {}
if Balances[ao.id] == nil and #Balances == 0 then -- initialize the balance for the process id
Balances[ao.id] = 1000000000 * 1000000
if #Balances == 0 then -- initialize the balance for the process id
Balances = {
[ao.id] = math.floor(50000000 * 1000000), -- 50M IO
[Owner] = math.floor(constants.totalTokenSupply - (50000000 * 1000000)), -- 950M IO
}
end
Vaults = Vaults or {}
GatewayRegistry = GatewayRegistry or {}
Expand Down Expand Up @@ -1070,6 +1075,9 @@ Handlers.add("addGateway", utils.hasMatchingTag("Action", "AddGateway"), functio
return
end
local status, result = pcall(gar.addGateway, msg.Tags.Address, json.decode(msg.Data))
-- TODO: deduct balance from owner when adding a gateway
-- reduce the owner balance when a gateway is added
balances.reduceBalance(Owner, 50000000000)
if status then
ao.send({ Target = msg.From, Data = json.encode(result) })
else
Expand Down
19 changes: 2 additions & 17 deletions tools/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const AO_LOADER_HANDLER_ENV = {
};

const AO_LOADER_OPTIONS = {
format: 'wasm32-unknown-emscripten',
format: 'wasm64-unknown-emscripten-draft_2024_02_15',
inputEncoding: 'JSON-1',
outputEncoding: 'JSON-1',
memoryLimit: '524288000', // in bytes
Expand All @@ -26,7 +26,7 @@ const AO_LOADER_OPTIONS = {
const AOS_WASM = fs.readFileSync(
path.join(
__dirname,
'fixtures/aos-9afQ1PLf2mrshqCTZEzzJTR2gWaC9zNPnYgYEqg1Pt4.wasm',
'fixtures/aos-cbn0KKrBZH7hdNkNokuXLtGryrWM--PjSTBqIzw9Kkk.wasm',
),
);

Expand All @@ -35,20 +35,6 @@ const BUNDLED_AOS_ANT_LUA = fs.readFileSync(
'utf-8',
);

const DEFAULT_ANT_STATE = JSON.stringify({
balances: { [STUB_ADDRESS]: 1 },
controllers: [STUB_ADDRESS],
name: 'ANT-ARDRIVE',
owner: STUB_ADDRESS,
records: {
'@': {
transactionId: 'UyC5P5qKPZaltMmmZAWdakhlDXsBF6qmyrbWYFchRTk',
ttlSeconds: 3600,
},
},
ticker: 'ANT',
});

const DEFAULT_HANDLE_OPTIONS = {
Id: ''.padEnd(43, '1'),
['Block-Height']: '1',
Expand All @@ -62,7 +48,6 @@ const DEFAULT_HANDLE_OPTIONS = {

module.exports = {
BUNDLED_AOS_ANT_LUA,
DEFAULT_ANT_STATE,
AOS_WASM,
AO_LOADER_OPTIONS,
AO_LOADER_HANDLER_ENV,
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit 9c8c4af

Please sign in to comment.