-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decentralize parachain relayer with linear timeout (#1266)
* Decentralize relayer with linear timeout * Fix modulo calculation * Rename as TotalRelayerCount * Restore start-relayer * Make SleepInterval configurable
- Loading branch information
Showing
7 changed files
with
209 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package parachain_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
// 100 messages distrubuted to 10 relayers, check waitingPeriod for each relayer | ||
func TestModuloSchedule(t *testing.T) { | ||
message_count := 100 | ||
total_count := 10 | ||
var waitingPeriod uint64 | ||
for nonce := 1; nonce < message_count; nonce++ { | ||
for id := 0; id < total_count; id++ { | ||
waitingPeriod = uint64((nonce + total_count - id) % total_count) | ||
fmt.Printf("algorithm 1: relay %d waiting for nonce %d for %d\n", id, nonce, waitingPeriod) | ||
} | ||
} | ||
for nonce := 1; nonce < message_count; nonce++ { | ||
for id := 0; id < total_count; id++ { | ||
modNonce := nonce % total_count | ||
if modNonce > id { | ||
waitingPeriod = uint64(modNonce - id) | ||
} else { | ||
waitingPeriod = uint64(id - modNonce) | ||
} | ||
fmt.Printf("algorithm 2: relay %d waiting for nonce %d for %d\n", id, nonce, waitingPeriod) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,10 @@ | |
"contracts": { | ||
"Gateway": null | ||
} | ||
}, | ||
"schedule": { | ||
"id": null, | ||
"totalRelayerCount": 3, | ||
"sleepInterval": 45 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters