-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slashing v2 #1278
Slashing v2 #1278
Changes from all commits
3d0e7ff
43a0ed9
a49f9cb
f972cab
752f084
5a77d7d
26681a8
8e677e8
43429ef
482a3c5
fd1eb5f
63a0dcc
7eaa715
3fac834
d69d179
0efb0a4
2153e0d
f6b9893
e460c06
8639f91
9ee70ea
bd41980
40ad0a5
4be5e41
03c6804
98dad7d
4601bd5
fc6ee07
ffc8cc4
6a5bc2d
436f32d
37190aa
ed7b90e
af4fd6e
1d7d4d4
d427af7
a0ac5e9
b72a219
8860fa3
24395fd
258834f
9ce6759
1ae48da
bc2e0d7
ad73cd1
60158d5
b1cb149
3cd8478
a3e04ce
782afbb
ad9da64
071d47b
5dc163c
bdc437e
2f42a2b
72d36d1
182d0cb
683b64a
0d38a72
6e2c66c
f004c6c
ceb8856
9f99a17
32b75c5
85c3639
177ab4c
3f4e528
c7433c9
f5dbcfd
de8b5b1
3e18286
40b9faf
a500931
c916f21
587e9fd
82f3529
2a34342
d5ab2f3
b8571b6
2511ef1
a0c9fed
86439ee
a029cb9
9cddb06
41bcf70
54b6ae5
e56c08b
2659120
3841a7a
03273a7
c17b8e6
dd3bdcb
48d1107
d93502d
c565dab
303fbe5
7170bd9
b7ece9a
74e0fb8
5329d73
9be314e
1a945a2
ffaefec
0012a46
0663984
70605a2
6f2c29b
a6c0381
637b275
4908504
34e46ac
f499b88
bcace44
de77006
791ad9c
44378a1
a901ed6
5449296
12fc6a9
08597c9
cff38d8
1d97ed6
f178308
1e75912
a133bc5
8895552
97eed84
3d3189c
220d03f
7ab62b4
554a72b
3c25861
99fec69
e43bbef
c76a8e1
cb85459
4edb773
78ac9ae
b00a0a1
f8dd859
c1987da
9bc99f1
30d9d90
aeea789
9ff81a6
5a479e0
e46e687
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,11 @@ func (v Validator) GetDelegatorShares() sdk.Rat { | |
return sdk.ZeroRat() | ||
} | ||
|
||
// Implements sdk.Validator | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this sdk.Validator, or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is |
||
func (v Validator) GetRevoked() bool { | ||
return false | ||
} | ||
|
||
// Implements sdk.Validator | ||
func (v Validator) GetBondHeight() int64 { | ||
return 0 | ||
|
@@ -107,7 +112,7 @@ func (vs *ValidatorSet) RemoveValidator(addr sdk.Address) { | |
} | ||
|
||
// Implements sdk.ValidatorSet | ||
func (vs *ValidatorSet) Slash(ctx sdk.Context, pubkey crypto.PubKey, height int64, amt sdk.Rat) { | ||
func (vs *ValidatorSet) Slash(ctx sdk.Context, pubkey crypto.PubKey, height int64, power int64, amt sdk.Rat) { | ||
panic("not implemented") | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package rest | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/gorilla/mux" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/context" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/wire" | ||
"github.com/cosmos/cosmos-sdk/x/slashing" | ||
) | ||
|
||
func registerQueryRoutes(ctx context.CoreContext, r *mux.Router, cdc *wire.Codec) { | ||
r.HandleFunc( | ||
"/slashing/signing_info/{validator}", | ||
signingInfoHandlerFn(ctx, "slashing", cdc), | ||
).Methods("GET") | ||
} | ||
|
||
// http request handler to query signing info | ||
func signingInfoHandlerFn(ctx context.CoreContext, storeName string, cdc *wire.Codec) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
|
||
// read parameters | ||
vars := mux.Vars(r) | ||
bech32validator := vars["validator"] | ||
|
||
validatorAddr, err := sdk.GetValAddressBech32(bech32validator) | ||
if err != nil { | ||
w.WriteHeader(http.StatusBadRequest) | ||
w.Write([]byte(err.Error())) | ||
return | ||
} | ||
|
||
key := slashing.GetValidatorSigningInfoKey(validatorAddr) | ||
res, err := ctx.QueryStore(key, storeName) | ||
if err != nil { | ||
w.WriteHeader(http.StatusInternalServerError) | ||
w.Write([]byte(fmt.Sprintf("couldn't query signing info. Error: %s", err.Error()))) | ||
return | ||
} | ||
|
||
var signingInfo slashing.ValidatorSigningInfo | ||
err = cdc.UnmarshalBinary(res, &signingInfo) | ||
if err != nil { | ||
w.WriteHeader(http.StatusInternalServerError) | ||
w.Write([]byte(fmt.Sprintf("couldn't decode signing info. Error: %s", err.Error()))) | ||
return | ||
} | ||
|
||
output, err := cdc.MarshalJSON(signingInfo) | ||
if err != nil { | ||
w.WriteHeader(http.StatusInternalServerError) | ||
w.Write([]byte(err.Error())) | ||
return | ||
} | ||
|
||
w.Write(output) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package rest | ||
|
||
import ( | ||
"github.com/gorilla/mux" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/context" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys" | ||
"github.com/cosmos/cosmos-sdk/wire" | ||
) | ||
|
||
// RegisterRoutes registers staking-related REST handlers to a router | ||
func RegisterRoutes(ctx context.CoreContext, r *mux.Router, cdc *wire.Codec, kb keys.Keybase) { | ||
registerQueryRoutes(ctx, r, cdc) | ||
registerTxRoutes(ctx, r, cdc, kb) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to use
tests.WaitForNextNBlocksTM