-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c31578e
commit 739dd7d
Showing
5 changed files
with
198 additions
and
13 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 |
---|---|---|
|
@@ -12,3 +12,4 @@ go.work.sum | |
.vscode/ | ||
coverage.txt | ||
target | ||
strawberry |
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 |
---|---|---|
@@ -1,5 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"net/http" | ||
"sync" | ||
|
||
"github.com/eigerco/strawberry/internal/block" | ||
"github.com/eigerco/strawberry/internal/state" | ||
"github.com/eigerco/strawberry/internal/statetransition" | ||
) | ||
|
||
func main() { | ||
println("Hello from Eiger") | ||
globalState := &state.State{} | ||
mu := &sync.RWMutex{} | ||
|
||
// a simple http server that demonstrates the block import capabilities | ||
// this will be replaced with proper p2p network communication in milestone 2 | ||
mux := http.NewServeMux() | ||
mux.HandleFunc("/block/import", func(w http.ResponseWriter, r *http.Request) { | ||
r.Header.Set("Content-Type", "application/json") | ||
newBlock := block.Block{} | ||
if err := json.NewDecoder(r.Body).Decode(&newBlock); err != nil { | ||
jsonError(w, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
|
||
mu.Lock() | ||
defer mu.Unlock() | ||
|
||
if err := statetransition.UpdateState(globalState, newBlock); err != nil { | ||
jsonError(w, err.Error(), http.StatusBadRequest) | ||
return | ||
} | ||
|
||
if err := json.NewEncoder(w).Encode(map[string]string{"status": "success"}); err != nil { | ||
jsonError(w, err.Error(), http.StatusInternalServerError) | ||
return | ||
} | ||
}) | ||
log.Println("demo server running on port :8080") | ||
log.Fatal(http.ListenAndServe(":8080", mux)) | ||
} | ||
|
||
func jsonError(w http.ResponseWriter, message string, statusCode int) { | ||
w.WriteHeader(statusCode) | ||
if err := json.NewEncoder(w).Encode(map[string]string{ | ||
"status": "error", | ||
"message": message, | ||
}); err != nil { | ||
http.Error(w, err.Error(), http.StatusInternalServerError) | ||
} | ||
} |
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,124 @@ | ||
{ | ||
"Header": { | ||
"ParentHash": [4,30,48,54,86,12,155,134,131,49,73,60,180,248,126,64,82,110,245,115,40,94,90,224,114,245,220,17,20,54,61,160], | ||
"PriorStateRoot": [197,136,205,3,81,250,172,194,223,214,213,59,188,94,190,133,219,120,202,184,76,184,171,78,102,252,246,123,156,30,63,189], | ||
"ExtrinsicHash": [11,15,65,182,25,99,235,153,234,109,87,233,218,79,84,0,251,48,199,241,42,96,173,52,117,178,71,138,151,44,119,111], | ||
"TimeSlotIndex": 123, | ||
"EpochMarker": { | ||
"Entropy": [10,134,253,174,212,142,121,52,114,86,50,231,218,151,135,4,109,251,153,33,20,255,206,15,6,21,55,32,53,54,165,223], | ||
"Keys": [[165,169,224,72,98,131,119,235,152,42,5,21,202,168,50,125,219,36,240,60,196,143,229,192,77,92,205,225,33,81,99,244],[150,101,167,55,172,24,218,15,19,30,65,236,39,217,188,161,203,52,52,4,156,131,123,126,145,199,223,203,114,153,185,94]] | ||
}, | ||
"WinningTicketsMarker": [{ | ||
"Identifier": [73,110,21,47,170,180,51,35,163,95,204,18,56,90,180,105,206,20,205,137,217,152,148,130,198,123,63,29,152,1,46,45], | ||
"EntryIndex": 112 | ||
},{ | ||
"Identifier": [2,199,58,6,137,170,0,147,70,213,31,105,254,178,231,82,123,242,72,119,0,130,17,198,227,44,13,171,55,161,40,192], | ||
"EntryIndex": 222} | ||
], | ||
"OffendersMarkers": ["uDVJpILBlvET8THsaZ5APOI6YgXHQ6UxL6UI4jH7Pyg="], | ||
"BlockAuthorIndex": 1, | ||
"VRFSignature": [192,175,130,72,223,80,158,84,185,36,142,168,174,125,103,243,84,87,4,136,255,216,70,41,127,253,160,94,128,19,233,85,22,11,92,88,141,249,118,102,35,244,201,88,232,39,243,30,244,151,59,186,14,67,148,81,188,90,75,73,119,219,241,245,53,32,160,221,67,75,68,133,227,126,79,83,31,69,113,124,152,147,118,94,139,66,248,254,56,111,10,79,238,96,162,220], | ||
"BlockSealSignature": [178,47,158,233,159,137,183,17,126,89,52,250,241,100,88,144,108,203,223,144,132,62,106,221,136,51,87,44,80,132,168,216,240,172,184,73,146,212,116,85,241,0,47,54,13,12,240,186,68,163,40,172,67,94,0,64,65,179,17,13,91,106,42,233,42,252,163,200,160,203,189,201,216,190,219,46,42,7,128,238,6,124,104,184,146,36,164,185,83,143,188,207,213,26,234,228] | ||
}, | ||
"Extrinsic": { | ||
"ET": { | ||
"TicketProofs": [{ | ||
"EntryIndex": 0, | ||
"Proof": [31,151,177,172,243,122,180,121,21,81,4,117,20,73,106,138,89,211,18,62,165,23,21,47,40,216,140,156,15,194,32,254,198,43,15,22,13,32,7,45,70,151,15,182,76,61,15,117,3,125,165,2,253,196,2,136,201,191,207,67,123,68,201,22,69,123,7,121,90,70,120,87,112,125,209,135,147,41,9,31,37,206,62,133,143,47,84,95,105,135,182,157,218,102,74,140,169,243,237,68,206,160,151,190,218,11,94,161,55,101,55,99,141,227,45,234,64,252,38,185,235,203,232,253,148,57,72,29,210,61,178,184,15,58,202,94,51,55,47,129,68,148,18,220,89,90,252,11,111,170,156,114,64,67,66,250,102,7,158,113,102,252,88,10,247,56,111,194,76,9,75,22,134,40,84,3,169,137,89,155,189,176,163,91,167,85,9,189,174,134,182,14,181,28,127,218,146,198,211,220,161,167,205,34,225,205,92,217,25,92,144,163,171,28,7,93,13,109,59,236,188,252,197,7,87,151,80,181,173,13,217,62,35,50,102,142,133,158,135,4,3,129,130,75,241,98,106,17,38,6,34,122,143,205,194,144,131,198,237,228,215,126,45,147,107,112,140,168,27,13,197,171,33,230,135,30,216,129,109,230,71,208,1,63,173,213,124,196,19,106,163,193,248,37,216,204,129,176,41,80,151,253,211,22,225,134,25,198,94,143,55,184,175,198,67,244,212,23,246,59,231,69,80,222,128,240,194,32,69,104,103,165,223,79,56,231,99,226,47,181,23,65,78,160,14,249,148,117,204,251,174,251,52,240,153,178,243,182,168,238,74,241,189,55,129,133,164,165,213,200,74,200,26,168,170,0,68,19,167,59,100,187,29,200,190,56,60,166,181,184,102,192,106,9,141,163,224,127,205,226,160,183,252,50,35,103,185,195,203,100,206,62,40,37,97,228,148,65,237,217,1,154,72,118,107,88,52,120,64,152,69,151,46,34,166,57,175,7,86,104,32,45,89,98,88,152,36,220,200,222,44,237,92,192,82,139,67,45,168,109,46,237,94,65,216,113,194,21,151,187,182,93,172,41,115,127,132,0,241,175,97,99,78,23,242,203,26,186,63,10,11,0,210,15,114,96,58,174,215,99,84,175,69,240,101,224,8,109,245,121,166,17,232,16,135,149,222,9,5,139,226,128,201,136,40,174,120,31,12,63,208,85,232,245,125,103,224,66,251,139,160,101,236,61,38,122,236,134,52,253,123,196,7,159,196,99,186,184,109,175,232,169,227,177,170,89,200,236,154,193,0,69,109,107,180,217,104,31,143,201,183,168,190,182,68,24,60,73,92,134,145,146,131,239,147,59,215,124,144,32,48,9,228,48,226,166,109,72,123,72,75,245,245,63,78,246,1,64,112,118,255,41,183,103,2,23,3,223,46,199,197,225,31,223,147,4,45,98,113,43,237,203,112,166,194,24,232,15,182,123,152,229,104,180,232,225,147,131,105,47,164,167,93,63,213,133,61,201,70,100,125,180,240,101,74,119,11,144,224,121,54,177,215,189,60,7,44,229,82,139,64,109,235,201,101,232,14,247,32,183,215,14,208,254,215,136,128,42,8,253,224,127,100,162,209,218,199,174,224,134,32,20,87,123,156,182,68,221,215,126,130,131,223,79,77,5,225,237,21,225,91,242,215,33,42,138,164,203,44,82,203,110,115,89,71,51,135,151,143,79,231,167,75,42,200,91,87,227,210,218,40,141,72,123,119,23,223,142,244,141,29,220,21,70] | ||
}] | ||
}, | ||
"ED": { | ||
"Verdicts": [{ | ||
"ReportHash": [13,79,77,193,75,245,90,147,3,39,36,6,24,65,246,226,70,245,175,198,142,24,135,90,210,161,180,185,143,79,244,122], | ||
"EpochIndex": 1, | ||
"Judgements": [{ | ||
"IsValid":true, | ||
"ValidatorIndex": 2, | ||
"Signature": [80,130,132,41,216,182,85,168,156,102,199,121,220,99,4,212,113,72,49,81,45,220,55,146,126,217,79,70,64,233,28,8,248,81,187,51,73,202,31,165,3,224,204,119,165,211,118,167,134,13,167,47,72,121,195,79,138,15,155,219,138,7,247,244] | ||
}] | ||
}], | ||
"Culprits": [{ | ||
"ReportHash": [59,157,239,20,121,165,69,250,54,134,130,85,123,121,65,74,173,234,28,255,150,94,144,255,65,79,50,5,75,63,3,181], | ||
"ValidatorEd25519PublicKey": "0Dg6mgLlAJrHzNxJ+/6BaIhRlMdWWTiq5k46xtp0IRI=", | ||
"Signature": [94,7,211,165,63,135,78,17,236,190,110,140,208,182,106,182,201,41,23,151,136,125,153,37,79,199,172,101,185,66,247,138,43,55,230,35,136,89,244,42,5,213,231,33,108,129,151,92,91,254,108,116,168,115,179,63,24,144,21,133,164,52,198,238] | ||
}], | ||
"Faults": [{ | ||
"ReportHash": [195,144,97,209,184,170,114,197,238,185,74,38,187,44,237,28,56,96,190,207,251,200,19,118,219,152,121,254,81,18,165,172], | ||
"IsValid": true, | ||
"ValidatorEd25519PublicKey": "peBeqMnplL2kX5eIEnPw+doDp9b8AP1NwN/NzGcHUk0=", | ||
"Signature": [174,246,243,145,230,101,125,219,86,188,109,98,251,116,122,159,240,162,255,92,49,244,88,187,64,209,239,35,100,74,66,174,178,185,255,13,241,129,19,181,41,59,243,186,35,168,226,118,8,17,60,47,189,56,108,238,184,102,176,158,216,69,87,175]} | ||
]}, | ||
"EP": [{ | ||
"ServiceIndex": 1, | ||
"Data": "cHJlaW1hZ2UgZGF0YQ==" | ||
}], | ||
"EA": [{ | ||
"Anchor": [166,169,128,196,239,33,60,197,205,142,148,9,56,150,47,144,19,20,27,100,26,206,35,15,203,203,32,35,99,40,92,77], | ||
"Bitfield": [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | ||
"ValidatorIndex": 1, | ||
"Signature": [175,22,223,202,247,170,7,240,109,151,77,177,245,92,49,24,139,132,94,160,183,163,15,132,35,226,111,149,134,15,154,141,118,131,150,18,177,178,228,41,115,124,5,193,250,32,44,254,143,92,36,190,10,119,175,115,220,165,131,230,3,114,223,144] | ||
}], | ||
"EG": { | ||
"Guarantees": [{ | ||
"WorkReport": { | ||
"WorkPackageSpecification": { | ||
"WorkPackageHash": [97,50,176,3,151,177,122,169,174,154,43,50,12,39,95,159,59,130,197,37,47,253,100,26,216,34,145,59,98,9,187,180], | ||
"AuditableWorkBundleLength": 100, | ||
"ErasureRoot": [209,62,210,4,186,110,15,173,199,64,68,231,218,58,32,53,87,123,44,207,168,148,64,11,218,144,63,42,166,193,12,106], | ||
"SegmentRoot": [35,180,90,173,110,202,23,216,79,157,204,1,60,134,90,90,103,164,108,128,242,186,50,1,9,217,239,253,73,27,117,122]}, | ||
"RefinementContext": { | ||
"Anchor": { | ||
"HeaderHash": [231,248,198,159,179,236,165,0,73,53,63,174,55,250,5,161,109,38,25,203,144,53,85,242,6,187,93,1,205,222,124,219], | ||
"PosteriorStateRoot": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], | ||
"PosteriorBeefyRoot": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}, | ||
"LookupAnchor": { | ||
"HeaderHash": [177,71,173,61,130,143,194,109,210,214,53,174,85,81,37,81,82,228,228,90,51,19,123,164,139,120,213,177,184,108,137,162], | ||
"Timeslot": 125 | ||
}, | ||
"PrerequisiteWorkPackage": null | ||
}, | ||
"CoreIndex": 1, | ||
"AuthorizerHash": [100,45,117,169,156,113,29,79,198,70,46,82,207,186,84,80,89,222,104,153,87,193,83,155,219,47,178,50,239,242,2,189], | ||
"Output": "b3V0cHV0IGRhdGE=", | ||
"WorkResults": [{ | ||
"ServiceId": 1, | ||
"ServiceHashCode": [45,94,225,243,239,115,129,96,33,157,84,208,145,142,206,184,181,107,150,84,251,239,62,159,155,34,189,63,185,216,230,49], | ||
"PayloadHash": [165,13,222,176,169,106,81,213,171,30,207,162,44,182,75,133,6,162,181,185,28,158,160,74,119,146,201,167,229,139,100,212], | ||
"GasPrioritizationRatio": 10, | ||
"Output": { | ||
"Inner": "Bwg="} | ||
},{ | ||
"ServiceId": 2, | ||
"ServiceHashCode": [138,41,230,207,166,71,173,161,5,154,205,46,186,74,100,130,109,129,107,188,219,204,125,69,210,61,117,207,227,245,237,194], | ||
"PayloadHash": [3,29,214,164,2,137,93,41,231,191,234,214,7,252,138,227,183,124,126,106,221,21,5,119,43,135,30,217,55,205,205,237], | ||
"GasPrioritizationRatio": 20, | ||
"Output": {"Inner": 1} | ||
},{ | ||
"ServiceId": 3, | ||
"ServiceHashCode": [252,91,28,157,72,167,108,13,75,217,132,120,245,136,147,53,91,240,238,31,13,110,37,239,126,237,16,166,33,158,87,171], | ||
"PayloadHash": [30,234,90,186,161,50,57,167,55,112,28,200,191,235,249,55,121,43,110,161,42,246,64,99,31,104,190,93,162,254,80,228], | ||
"GasPrioritizationRatio": 30, | ||
"Output": {"Inner": 2} | ||
},{ | ||
"ServiceId": 4, | ||
"ServiceHashCode": [208,180,216,219,204,38,249,133,160,119,101,67,178,38,19,152,209,43,62,151,106,204,238,247,69,148,115,241,147,87,253,177], | ||
"PayloadHash": [13,200,5,134,224,183,55,144,57,65,108,88,57,55,67,177,94,11,69,239,111,223,41,123,128,190,140,201,186,80,30,88], | ||
"GasPrioritizationRatio": 20, | ||
"Output": {"Inner": 3} | ||
},{ | ||
"ServiceId": 5, | ||
"ServiceHashCode": [214,144,215,106,189,171,102,129,47,24,107,33,106,166,210,204,239,195,168,214,51,81,36,129,254,73,61,132,3,12,127,224], | ||
"PayloadHash": [13,166,144,157,108,187,22,6,104,186,56,156,124,102,176,183,250,177,44,98,189,131,158,180,88,39,160,253,67,45,9,107], | ||
"GasPrioritizationRatio": 10, | ||
"Output": {"Inner": 4}} | ||
] | ||
}, | ||
"Timeslot": 200, | ||
"Credentials": [{ | ||
"ValidatorIndex": 1, | ||
"Signature": [202,78,103,4,76,39,11,144,227,246,145,71,188,15,83,225,170,195,195,71,133,52,218,197,213,233,26,119,62,135,160,65,84,38,157,19,211,128,81,190,171,39,242,21,170,89,62,193,96,47,125,1,119,243,232,21,213,195,100,209,67,9,27,177] | ||
}] | ||
}] | ||
} | ||
} | ||
} |