Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions scripts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function createDataAvailabilityConfig(argv: any, anytrust: boolean) {
}

function applyTxFilteringConfig(config: any) {
config.execution.sequencer["transaction-filtering"] = {
config.execution["transaction-filtering"] = {
"address-filter": {
"enable": true,
"s3": {
Expand Down Expand Up @@ -875,9 +875,12 @@ export const initTxFilteringMinioCommand = {
handler: async () => {
const salt = crypto.randomUUID();
const initialAddressList = {
"salt": salt,
"hashing_scheme": "Sha256",
"address_hashes": []
id: crypto.randomUUID(),
extract_uuid: crypto.randomUUID(),
salt: salt,
issued_at: new Date().toISOString().replace(/\.\d{3}Z$/, "Z"),
hashing_scheme: "sha256-stringinput",
hashes: [] as string[],
};
fs.writeFileSync(path.join(consts.configpath, "initial_address_hashes.json"), JSON.stringify(initialAddressList, null, 2));
fs.writeFileSync(path.join(consts.configpath, "tx_filtering_salt.hex"), salt);
Expand Down Expand Up @@ -965,18 +968,21 @@ export const addFilteredAddressCommand = {
}
const salt = fs.readFileSync(saltPath).toString().trim();
const hash = computeAddressHash(argv.address, salt);
const hashWithPrefix = "0x" + hash;

const addressListPath = path.join(consts.configpath, "initial_address_hashes.json");
const addressList = JSON.parse(fs.readFileSync(addressListPath).toString());

const exists = addressList.address_hashes.some((entry: any) => entry.hash === hash);
if (!exists) {
addressList.address_hashes.push({ hash: hash });
if (!addressList.hashes.includes(hashWithPrefix)) {
addressList.hashes.push(hashWithPrefix);
addressList.id = crypto.randomUUID();
addressList.extract_uuid = crypto.randomUUID();
addressList.issued_at = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
fs.writeFileSync(addressListPath, JSON.stringify(addressList, null, 2));
console.log("Added address hash:", hash);
console.log("Added address hash:", hashWithPrefix);
await uploadFilteredAddressesToMinio();
} else {
console.log("Address hash already in list:", hash);
console.log("Address hash already in list:", hashWithPrefix);
}
}
}
Expand All @@ -999,18 +1005,22 @@ export const removeFilteredAddressCommand = {
}
const salt = fs.readFileSync(saltPath).toString().trim();
const hash = computeAddressHash(argv.address, salt);
const hashWithPrefix = "0x" + hash;

const addressListPath = path.join(consts.configpath, "initial_address_hashes.json");
const addressList = JSON.parse(fs.readFileSync(addressListPath).toString());

const index = addressList.address_hashes.findIndex((entry: any) => entry.hash === hash);
const index = addressList.hashes.indexOf(hashWithPrefix);
if (index > -1) {
addressList.address_hashes.splice(index, 1);
addressList.hashes.splice(index, 1);
addressList.id = crypto.randomUUID();
addressList.extract_uuid = crypto.randomUUID();
addressList.issued_at = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
fs.writeFileSync(addressListPath, JSON.stringify(addressList, null, 2));
console.log("Removed address hash:", hash);
console.log("Removed address hash:", hashWithPrefix);
await uploadFilteredAddressesToMinio();
} else {
console.log("Address hash not in list:", hash);
console.log("Address hash not in list:", hashWithPrefix);
}
}
}
Loading