Skip to content

Commit

Permalink
Implement blacklist of known bad collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
ligi committed Jun 11, 2018
1 parent 0f57e5a commit 8367665
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 8 additions & 0 deletions black.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pizza_mandate_apology(uint256)
gasprice_bit_ether(int128)
available_assert_time(uint16,uint64)
collate_propagate_storage(bytes16)
ideal_warn_timed(uint256,uint128)
link_classic_internal(uint64,int64)
many_msg_babbage(bytes1)
coral_cable_news(uint256)
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ import com.beust.klaxon.Parser
import okhttp3.OkHttpClient
import okhttp3.Request
import org.kethereum.methodsignatures.FileBackedMethodSignatureStore
import java.io.File
import java.util.concurrent.TimeUnit

const val PAGE_SIZE = 2000
const val url = "https://www.4byte.directory/api/v1/signatures/?page_size=$PAGE_SIZE&ordering=created_at"

val client = OkHttpClient()
val client = OkHttpClient.Builder().apply {
readTimeout(42, TimeUnit.SECONDS)
}.build()

val outDir = signatureDirectory.apply { mkdirs() }

var total = 0
Expand All @@ -20,6 +25,8 @@ fun main(args: Array<String>) {
}

private fun import(url: String) {
val blackList = File("black.lst").readLines().toSet()

val store = FileBackedMethodSignatureStore(outDir)
val request = Request.Builder().url(url).build()

Expand All @@ -35,9 +42,11 @@ private fun import(url: String) {
array.map { it as JsonObject }.forEach {
val hexSignature = it["hex_signature"] as String
val textSignature = it["text_signature"] as String
if (store.upsert(hexSignature.replace("0x", ""), textSignature)) {
new++
total++
if (!blackList.contains(textSignature)) {
if (store.upsert(hexSignature.replace("0x", ""), textSignature)) {
new++
total++
}
}
}
println("processed: ${array.size} - imported: $new - total: $total")
Expand Down

0 comments on commit 8367665

Please sign in to comment.