Skip to content

Commit

Permalink
for 080 (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode authored Jan 24, 2024
1 parent 6ef0b47 commit 6cccea1
Show file tree
Hide file tree
Showing 18 changed files with 432 additions and 363 deletions.
57 changes: 39 additions & 18 deletions cmd/console/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func runCmd(cmd *cobra.Command, args []string) {
var teeAcc string
var teeEndPointList = make([]string, 0)
for {
teeList, err := n.QueryAllTeeInfo()
teeList, err := n.QueryAllTeeWorkerMap()
if err != nil {
if err.Error() == pattern.ERR_Empty {
out.Err("No TEE was found, waiting for the next query...")
Expand All @@ -208,7 +208,12 @@ func runCmd(cmd *cobra.Command, args []string) {
}

for _, v := range teeList {
err = n.SaveTee(v.WorkAccount, v.EndPoint, v.TeeType)
endPoint, err := n.QueryTeeWorkEndpoint(v.Pubkey)
if err != nil {
continue
}

err = n.SaveTee(string(v.Pubkey[:]), endPoint, uint8(v.Role))
if err != nil {
out.Err(fmt.Sprintf("[SaveTee] %v", err))
continue
Expand Down Expand Up @@ -401,23 +406,31 @@ func runCmd(cmd *cobra.Command, args []string) {
key.N[i] = types.U8(n.MinerPoisInfo.KeyN[i])
}

var sign pattern.TeeSignature
if len(n.MinerPoisInfo.StatusTeeSign) != pattern.TeeSignatureLen {
var sign pattern.TeeSig
if len(n.MinerPoisInfo.StatusTeeSign) != pattern.TeeSigLen {
out.Err("invalid tee signature")
os.Exit(1)
}
for i := 0; i < pattern.TeeSignatureLen; i++ {
for i := 0; i < pattern.TeeSigLen; i++ {
sign[i] = types.U8(n.MinerPoisInfo.StatusTeeSign[i])
}
var signWithAcc pattern.TeeSignature
if len(responseMinerInitParam.SignatureWithTeeController) != pattern.TeeSignatureLen {
var signWithAcc pattern.TeeSig
if len(responseMinerInitParam.SignatureWithTeeController) != pattern.TeeSigLen {
out.Err("invalid tee SignatureWithTeeController")
os.Exit(1)
}
for i := 0; i < pattern.TeeSignatureLen; i++ {
for i := 0; i < pattern.TeeSigLen; i++ {
signWithAcc[i] = types.U8(responseMinerInitParam.SignatureWithTeeController[i])
}
txhash, err := n.RegisterSminerPOISKey(key, signWithAcc, sign, teeAcc)
if len(teeAcc) != pattern.WorkerPublicKeyLen {
out.Err("invalid tee work publick")
os.Exit(1)
}
var teepuk pattern.WorkerPublicKey
for i := 0; i < pattern.WorkerPublicKeyLen; i++ {
teepuk[i] = types.U8(teeAcc[i])
}
txhash, err := n.RegisterSminerPOISKey(key, signWithAcc, sign, teepuk)
if err != nil {
if txhash != "" {
out.Err(fmt.Sprintf("[%s] Register POIS key failed: %v", txhash, err))
Expand Down Expand Up @@ -511,23 +524,31 @@ func runCmd(cmd *cobra.Command, args []string) {
key.N[i] = types.U8(n.MinerPoisInfo.KeyN[i])
}

var sign pattern.TeeSignature
if len(n.MinerPoisInfo.StatusTeeSign) != len(pattern.TeeSignature{}) {
var sign pattern.TeeSig
if len(n.MinerPoisInfo.StatusTeeSign) != pattern.TeeSigLen {
out.Err("invalid tee signature")
os.Exit(1)
}
for i := 0; i < len(n.MinerPoisInfo.StatusTeeSign); i++ {
for i := 0; i < pattern.TeeSigLen; i++ {
sign[i] = types.U8(n.MinerPoisInfo.StatusTeeSign[i])
}
var signWithAcc pattern.TeeSignature
if len(responseMinerInitParam.SignatureWithTeeController) != pattern.TeeSignatureLen {
var signWithAcc pattern.TeeSig
if len(responseMinerInitParam.SignatureWithTeeController) != pattern.TeeSigLen {
out.Err("invalid tee SignatureWithTeeController")
os.Exit(1)
}
for i := 0; i < pattern.TeeSignatureLen; i++ {
for i := 0; i < pattern.TeeSigLen; i++ {
signWithAcc[i] = types.U8(responseMinerInitParam.SignatureWithTeeController[i])
}
txhash, err := n.RegisterSminerPOISKey(key, signWithAcc, sign, teeAcc)
if len(teeAcc) != pattern.WorkerPublicKeyLen {
out.Err("invalid tee work publick")
os.Exit(1)
}
var teepuk pattern.WorkerPublicKey
for i := 0; i < pattern.WorkerPublicKeyLen; i++ {
teepuk[i] = types.U8(teeAcc[i])
}
txhash, err := n.RegisterSminerPOISKey(key, signWithAcc, sign, teepuk)
if err != nil {
out.Err(fmt.Sprintf("[%s] Register POIS key failed: %v", txhash, err))
os.Exit(1)
Expand All @@ -550,15 +571,15 @@ func runCmd(cmd *cobra.Command, args []string) {
continue
}
_, spaceProofInfo = minerInfo.SpaceProofInfo.Unwrap()
teeSign = []byte(string(minerInfo.TeeSignature[:]))
teeSign = []byte(string(minerInfo.TeeSig[:]))
peerid = []byte(string(minerInfo.PeerId[:]))
earningsAcc, _ = sutils.EncodePublicKeyAsCessAccount(minerInfo.BeneficiaryAccount[:])
break
}
} else {
firstReg = false
_, spaceProofInfo = minerInfo.SpaceProofInfo.Unwrap()
teeSign = []byte(string(minerInfo.TeeSignature[:]))
teeSign = []byte(string(minerInfo.TeeSig[:]))
peerid = []byte(string(minerInfo.PeerId[:]))
earningsAcc, _ = sutils.EncodePublicKeyAsCessAccount(minerInfo.BeneficiaryAccount[:])
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/console/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Command_State_Runfunc(cmd *cobra.Command, args []string) {
os.Exit(1)
}

minerInfo.Collaterals.Div(new(big.Int).SetBytes(minerInfo.Collaterals.Bytes()), big.NewInt(1000000000000))
minerInfo.Collaterals.Div(new(big.Int).SetBytes(minerInfo.Collaterals.Bytes()), big.NewInt(configs.TokenTCESS))

beneficiaryAcc, _ := sutils.EncodePublicKeyAsCessAccount(minerInfo.BeneficiaryAccount[:])

Expand Down
2 changes: 2 additions & 0 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import "time"
const (
//
TimeFormat = "2006-01-02 15:04:05"

TokenTCESS = 1000000000000000000
// the time to wait for the event, in seconds
TimeToWaitEvent = time.Duration(time.Second * 30)
// Default config file
Expand Down
10 changes: 4 additions & 6 deletions examples/serviceproof/sproof.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,10 @@ func main() {

n.Schal("info", fmt.Sprintf("req tee ip batch verify: %s", tee))
var requestBatchVerify = &pb.RequestBatchVerify{
AggProof: batchVerifyParam,
PeerId: nil,
MinerPbk: nil,
MinerPeerIdSign: nil,
Qslices: qslice_pb,
USigs: nil,
AggProof: batchVerifyParam,
MinerId: nil,
Qslices: qslice_pb,
USigs: nil,
}
var dialOptions []grpc.DialOption
if !strings.Contains(tee, "443") {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.20

require (
github.com/AstaFrode/go-libp2p v0.26.4-0.20231113143058-912296254d44
github.com/CESSProject/cess-go-sdk v0.4.22
github.com/CESSProject/cess-go-sdk v0.4.27
github.com/CESSProject/cess_pois v0.4.22
github.com/CESSProject/p2p-go v0.2.11
github.com/CESSProject/p2p-go v0.2.12
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.1
github.com/gin-contrib/cors v1.5.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ github.com/AstaFrode/go-peertaskqueue v0.8.2-0.20231108073729-990e433425a4 h1:fu
github.com/AstaFrode/go-peertaskqueue v0.8.2-0.20231108073729-990e433425a4/go.mod h1:0YcQDsyTRKBTK9yE22DQgiwQndGFvenqMvD6Spkxl28=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/CESSProject/cess-go-sdk v0.4.22 h1:d9xnRHaaudntJEHy0cCXysuNfj+cfvfdOs3QsLnF21o=
github.com/CESSProject/cess-go-sdk v0.4.22/go.mod h1:IamF02Ng+FQvThFbQRtpEpPzmlPOXqQzgaF9YDE0YhY=
github.com/CESSProject/cess-go-sdk v0.4.27 h1:amMd/V5TJEZlIfUQjdGRxRZoSqnpJRokp+GMe/ZyQBQ=
github.com/CESSProject/cess-go-sdk v0.4.27/go.mod h1:IamF02Ng+FQvThFbQRtpEpPzmlPOXqQzgaF9YDE0YhY=
github.com/CESSProject/cess_pois v0.4.22 h1:RxQRg8A3z79mt19Jb5yd39lIjBSWKBih1KLIqN1WnIY=
github.com/CESSProject/cess_pois v0.4.22/go.mod h1:rztEZjjG+MbKzVgh5WtQcZc/7ZDkBvDNABc7Em8BKPc=
github.com/CESSProject/go-keyring v0.0.0-20220614131247-ee3a8da30fde h1:5MDRjjtg6PEhqyVjupwaapN96cOZiddOGAYwKQeaTu0=
github.com/CESSProject/go-keyring v0.0.0-20220614131247-ee3a8da30fde/go.mod h1:RUXBd3ROP98MYepEEa0Y0l/T0vQlIKqFJxI/ocdnRLM=
github.com/CESSProject/p2p-go v0.2.11 h1:2o1YzM1YcJhVsZYLAuyWKJ4ib3WA3Qpt6pllVlmKzik=
github.com/CESSProject/p2p-go v0.2.11/go.mod h1:SMwJt5Zpk98k+d2J5gsN+0Forr7MbqOYWbHLd3mBLrI=
github.com/CESSProject/p2p-go v0.2.12 h1:XqmxuxnXGMo4R/iYQTGzSGk2G+tCu96lQodPpdtEHFU=
github.com/CESSProject/p2p-go v0.2.12/go.mod h1:SMwJt5Zpk98k+d2J5gsN+0Forr7MbqOYWbHLd3mBLrI=
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
Expand Down
Loading

0 comments on commit 6cccea1

Please sign in to comment.