Skip to content
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

Bounty v2 #786

Merged
merged 78 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
efce5cf
first buildable version
Dec 12, 2022
7ce1465
add createprogram
Dec 13, 2022
7c05b70
add bounty to app
Dec 13, 2022
0d7c0bc
modify privkey prints
Dec 13, 2022
5c3c8c8
fix file I/O for key storage
Dec 14, 2022
ed2eabb
fix dateLayout and run gofmt
xiumingdou Dec 26, 2022
2921860
register interfaces
xiumingdou Dec 26, 2022
6e8859d
fix lint
xiumingdou Dec 26, 2022
b22342a
add simulation interfaces
xiumingdou Dec 27, 2022
9570f6e
fix json format issue in ExportGenesis
xiumingdou Dec 28, 2022
0ef24b3
fix comments and imports
xiumingdou Dec 28, 2022
518b7d6
refactor program creation
xiumingdou Dec 29, 2022
f171029
compile .proto changes
xiumingdou Jan 2, 2023
415747e
fix refactor
xiumingdou Jan 2, 2023
c820996
Revert "compile .proto changes"
xiumingdou Jan 4, 2023
bdb483a
recompile .proto files
xiumingdou Jan 5, 2023
77b5e7b
Address review comments
xiumingdou Jan 6, 2023
1343d49
git add the bounty genesis.go
xiumingdou Jan 6, 2023
eda4225
Bounty encryption (#565)
kevin-yuhh Jan 11, 2023
625d386
Add bounty module account (#577)
zheng-bin Jan 14, 2023
6b4f26f
Finding submit (#574)
kevin-yuhh Jan 16, 2023
4b4cbb6
Bounty query for programs and findings (#578)
zheng-bin Jan 17, 2023
526bca5
Bounty cli help information (#582)
zheng-bin Jan 17, 2023
7d500bf
Host accept or reject findings (#580)
zheng-bin Jan 19, 2023
e4040d8
encrypt desc and poc before broadcast (#586)
kevin-yuhh Jan 20, 2023
b6228ec
Add bounty upgrade (#584)
zheng-bin Jan 20, 2023
89bcf97
Release finding (#585)
kevin-yuhh Feb 2, 2023
c5d0ad0
Bounty program validate (#593)
kevin-yuhh Feb 2, 2023
e1a15f7
finding withdrawal (#590)
0311xuyang Feb 2, 2023
7359565
Bounty: fix cli cancel bug (#594)
zheng-bin Feb 3, 2023
9b506bb
Bounty any parse (#596)
kevin-yuhh Feb 3, 2023
c31441d
add publickey verification (#601)
kevin-yuhh Feb 15, 2023
15c935d
[Bounty] terminate a program (#600)
haozhan9 Feb 16, 2023
9d7b0b7
add any UnpackInterfaces (#606)
kevin-yuhh Feb 21, 2023
bc350ab
Bounty genesis (#579)
kevin-yuhh Feb 24, 2023
3c70341
Add return error in GetNextFindingID and GetNextProgramID (#609)
kevin-yuhh Feb 24, 2023
471f6bb
Bounty tests (#591)
0311xuyang Apr 18, 2023
9c40571
Bounty base64 (#696)
kevin-yuhh May 29, 2023
ffb9032
merge master (#705)
kevin-yuhh Jun 2, 2023
916f091
Modify program and finding fields
zheng-bin Oct 19, 2023
7212c8d
Merge branch 'master' into bounty-v2
zheng-bin Oct 24, 2023
21f5291
Fix conflicts
zheng-bin Oct 25, 2023
9bb6d5c
Optimize structure
zheng-bin Oct 25, 2023
39fe306
Fix lint error
zheng-bin Oct 25, 2023
0ffcd87
Modify desc of program to string type
zheng-bin Oct 25, 2023
65564a8
Add test case
zheng-bin Oct 25, 2023
10718a3
Add test case
zheng-bin Oct 26, 2023
da24f66
update go.mod
zheng-bin Oct 26, 2023
cd6dbd3
Fix e2e test
zheng-bin Oct 26, 2023
6348953
Add test case
zheng-bin Oct 26, 2023
6923d96
Fix e2e test
zheng-bin Oct 27, 2023
4d8d086
Fix e2e test
zheng-bin Oct 27, 2023
8d9af12
Fix program e2e test
zheng-bin Oct 27, 2023
9e94af0
Fix release finding
zheng-bin Oct 27, 2023
7446fad
Add bounty admin
zheng-bin Nov 9, 2023
fe1f7ae
fix lint error
zheng-bin Nov 10, 2023
bf820a4
fix test error
zheng-bin Nov 12, 2023
e493a5f
fix e2e test
zheng-bin Nov 13, 2023
796581c
add confirm finding paid
zheng-bin Nov 13, 2023
6386e69
fix test error
zheng-bin Nov 14, 2023
57f3aa1
fix test error
zheng-bin Nov 14, 2023
afc9836
fix test error
zheng-bin Nov 14, 2023
f5f0c0e
add fingerprint
zheng-bin Nov 14, 2023
4dd7fa2
fix lint error
zheng-bin Nov 14, 2023
d894da8
add msg check
zheng-bin Nov 14, 2023
e24a7ff
add test case
zheng-bin Nov 14, 2023
3a7e395
add confirmFindingPaid cmd
zheng-bin Nov 14, 2023
e2c53fb
fix lint error
zheng-bin Nov 15, 2023
cfc9ddf
add a GRPC for program fingerprint
zheng-bin Nov 15, 2023
432822e
add cmd cli for query
zheng-bin Nov 15, 2023
98c79b3
add activate finding
zheng-bin Nov 16, 2023
a39b82e
fix review comment
zheng-bin Nov 16, 2023
2d798fe
Merge branch 'master' into bounty-v2
zheng-bin Nov 16, 2023
c21c0e3
fix lint error
zheng-bin Nov 16, 2023
788a638
delete coverage.txt
zheng-bin Nov 16, 2023
a49b885
fix cli information
zheng-bin Nov 16, 2023
71c27dd
change name from release to publish
zheng-bin Nov 17, 2023
2d9cd27
modify some error messages
zheng-bin Nov 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ import (
authkeeper "github.com/shentufoundation/shentu/v2/x/auth/keeper"
"github.com/shentufoundation/shentu/v2/x/bank"
bankkeeper "github.com/shentufoundation/shentu/v2/x/bank/keeper"
"github.com/shentufoundation/shentu/v2/x/bounty"
bountykeeper "github.com/shentufoundation/shentu/v2/x/bounty/keeper"
bountytypes "github.com/shentufoundation/shentu/v2/x/bounty/types"
"github.com/shentufoundation/shentu/v2/x/cert"
certclient "github.com/shentufoundation/shentu/v2/x/cert/client"
certkeeper "github.com/shentufoundation/shentu/v2/x/cert/keeper"
Expand Down Expand Up @@ -165,6 +168,7 @@ var (
ibc.AppModuleBasic{},
transfer.AppModuleBasic{},
ica.AppModuleBasic{},
bounty.AppModuleBasic{},
)

// module account permissions
Expand All @@ -180,6 +184,7 @@ var (
shieldtypes.ModuleName: {authtypes.Burner},
cvmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
bountytypes.ModuleName: {authtypes.Burner},
}
)

Expand Down Expand Up @@ -219,6 +224,7 @@ type ShentuApp struct {
CVMKeeper cvmkeeper.Keeper
OracleKeeper oraclekeeper.Keeper
ShieldKeeper shieldkeeper.Keeper
BountyKeeper bountykeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -268,6 +274,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
ibctransfertypes.StoreKey,
icahosttypes.StoreKey,
capabilitytypes.StoreKey,
bountytypes.StoreKey,
}

keys := sdk.NewKVStoreKeys(ks...)
Expand Down Expand Up @@ -397,6 +404,13 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
&app.GovKeeper,
app.GetSubspace(shieldtypes.ModuleName),
)
app.BountyKeeper = bountykeeper.NewKeeper(
appCodec,
keys[bountytypes.StoreKey],
app.CertKeeper,
app.GetSubspace(bountytypes.ModuleName),
)

app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[sdkminttypes.StoreKey], app.GetSubspace(sdkminttypes.ModuleName), &stakingKeeper,
app.AccountKeeper, app.BankKeeper, app.DistrKeeper, app.ShieldKeeper, authtypes.FeeCollectorName,
Expand Down Expand Up @@ -504,6 +518,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
params.NewAppModule(app.ParamsKeeper),
transferModule,
icaModule,
bounty.NewAppModule(app.BountyKeeper),
)

// NOTE: During BeginBlocker, slashing comes after distr so that
Expand All @@ -513,7 +528,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName,
icatypes.ModuleName, authtypes.ModuleName, sdkbanktypes.ModuleName, sdkgovtypes.ModuleName, genutiltypes.ModuleName,
sdkauthz.ModuleName, sdkfeegrant.ModuleName, crisistypes.ModuleName, shieldtypes.ModuleName, certtypes.ModuleName,
oracletypes.ModuleName, cvmtypes.ModuleName, paramstypes.ModuleName,
oracletypes.ModuleName, cvmtypes.ModuleName, paramstypes.ModuleName, bountytypes.ModuleName,
)

// NOTE: Shield endblocker comes before staking because it queries
Expand All @@ -522,7 +537,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
capabilitytypes.ModuleName, authtypes.ModuleName, sdkbanktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName,
sdkminttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, sdkauthz.ModuleName, sdkfeegrant.ModuleName,
paramstypes.ModuleName, upgradetypes.ModuleName, ibchost.ModuleName, ibctransfertypes.ModuleName, icatypes.ModuleName,
certtypes.ModuleName, oracletypes.ModuleName, cvmtypes.ModuleName,
certtypes.ModuleName, oracletypes.ModuleName, cvmtypes.ModuleName, bountytypes.ModuleName,
)

// NOTE: genutil moodule must occur after staking so that pools
Expand Down Expand Up @@ -550,6 +565,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
sdkfeegrant.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
bountytypes.ModuleName,
)

app.mm.SetOrderExportGenesis(
Expand All @@ -575,6 +591,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
evidencetypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
bountytypes.ModuleName,
)

app.mm.RegisterInvariants(&app.CrisisKeeper)
Expand Down Expand Up @@ -602,6 +619,7 @@ func NewShentuApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
shield.NewAppModule(app.ShieldKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
bounty.NewAppModule(app.BountyKeeper),
)

app.sm.RegisterStoreDecoders()
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.5.3
github.com/golangci/golangci-lint v1.50.1
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/hyperledger/burrow v0.31.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
Expand Down
136 changes: 136 additions & 0 deletions proto/shentu/bounty/v1/bounty.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
syntax = "proto3";
package shentu.bounty.v1;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos_proto/cosmos.proto";
import "google/protobuf/any.proto";

option go_package = "github.com/shentufoundation/shentu/x/bounty/types";

message Program {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string program_id = 1 [(gogoproto.moretags) = "yaml:\"program_id\""];
string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
// JSON by ProgramDetail
string detail = 3 [(gogoproto.moretags) = "yaml:\"detail\""];
string admin_address = 4 [(gogoproto.moretags) = "yaml:\"admin_address\""];
ProgramStatus status = 5 [(gogoproto.moretags) = "yaml:\"status\""];
google.protobuf.Timestamp create_time = 6
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"create_time\""];
}

message Finding {
zheng-bin marked this conversation as resolved.
Show resolved Hide resolved
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string program_id = 1 [(gogoproto.moretags) = "yaml:\"program_id\""];
string finding_id = 2 [(gogoproto.moretags) = "yaml:\"finding_id\""];
string title = 3;
string description = 4 [(gogoproto.moretags) = "yaml:\"description\""];
string proof_of_concept = 5 [(gogoproto.moretags) = "yaml:\"proof_of_concept\""];
// hash(description + proof_of_concept + submitter)
string finding_hash = 6 [(gogoproto.moretags) = "yaml:\"finding_hash\""];
string submitter_address = 7 [(gogoproto.moretags) = "yaml:\"submitter_address\""];
SeverityLevel severity_level = 8 [(gogoproto.moretags) = "yaml:\"severity_level\""];
FindingStatus status = 9 [(gogoproto.moretags) = "yaml:\"status\""];
// JSON by FindingDetail
string detail = 10 [(gogoproto.moretags) = "yaml:\"detail\""];
string payment_hash = 11 [(gogoproto.moretags) = "yaml:\"payment_hash\""];
google.protobuf.Timestamp create_time = 12
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"create_time\""];
}
zheng-bin marked this conversation as resolved.
Show resolved Hide resolved

message ProgramFingerprint {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string program_id = 1 [(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""];
string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
// JSON by ProgramDetail
string detail = 3 [(gogoproto.moretags) = "yaml:\"detail\""];
string admin_address = 4 [(gogoproto.moretags) = "yaml:\"admin_address\""];
ProgramStatus status = 5 [(gogoproto.moretags) = "yaml:\"status\""];
}

message FindingFingerprint {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string program_id = 1 [(gogoproto.moretags) = "yaml:\"program_id\""];
string finding_id = 2 [(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""];
string title = 3;
// hash(description + proof_of_concept + submitter)
string finding_hash = 4 [(gogoproto.moretags) = "yaml:\"finding_hash\""];
SeverityLevel severity_level = 5 [(gogoproto.moretags) = "yaml:\"severity_level\""];
FindingStatus status = 6 [(gogoproto.moretags) = "yaml:\"status\""];
// JSON by FindingDetail
string detail = 7 [(gogoproto.moretags) = "yaml:\"detail\""];
string payment_hash = 8 [(gogoproto.moretags) = "yaml:\"payment_hash\""];
}

enum ProgramStatus {
option (gogoproto.goproto_enum_prefix) = false;

PROGRAM_STATUS_INACTIVE = 0 [(gogoproto.enumvalue_customname) = "ProgramStatusInactive"];
PROGRAM_STATUS_ACTIVE = 1 [(gogoproto.enumvalue_customname) = "ProgramStatusActive"];
PROGRAM_STATUS_CLOSED = 2 [(gogoproto.enumvalue_customname) = "ProgramStatusClosed"];
}

enum SeverityLevel {
option (gogoproto.goproto_enum_prefix) = false;

SEVERITY_LEVEL_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "Unspecified"];
SEVERITY_LEVEL_CRITICAL = 1 [(gogoproto.enumvalue_customname) = "Critical"];
SEVERITY_LEVEL_HIGH = 2 [(gogoproto.enumvalue_customname) = "High"];
SEVERITY_LEVEL_MEDIUM = 3 [(gogoproto.enumvalue_customname) = "Medium"];
SEVERITY_LEVEL_LOW = 4 [(gogoproto.enumvalue_customname) = "Low"];
SEVERITY_LEVEL_INFORMATIONAL = 5 [(gogoproto.enumvalue_customname) = "Informational"];
}

enum FindingStatus {
option (gogoproto.goproto_enum_prefix) = false;

FINDING_STATUS_SUBMITTED = 0 [(gogoproto.enumvalue_customname) = "FindingStatusSubmitted"];
FINDING_STATUS_ACTIVE = 1 [(gogoproto.enumvalue_customname) = "FindingStatusActive"];
FINDING_STATUS_CONFIRMED = 2 [(gogoproto.enumvalue_customname) = "FindingStatusConfirmed"];
FINDING_STATUS_PAID = 3 [(gogoproto.enumvalue_customname) = "FindingStatusPaid"];
FINDING_STATUS_CLOSED = 4 [(gogoproto.enumvalue_customname) = "FindingStatusClosed"];
}

//message BountyLevel {
// option (gogoproto.equal) = false;
// option (gogoproto.goproto_getters) = false;
//
// SeverityLevel severity_level = 1 [(gogoproto.moretags) = "yaml:\"severity_level\""];
// bool poc = 2;
// cosmos.base.v1beta1.Coin min_bounty = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"min_bounty\""];
// cosmos.base.v1beta1.Coin max_bounty = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"max_bounty\""];
//}

//// ProgramDetail defines a program detail.
//type ProgramDetail struct {
// Type string `json:"type"`
// Logo string `json:"logo"`
// Desc string `json:"desc"`
// Targets []string `json:"targets"`
// ScopeRules string `json:"scope_rules"`
// KnownIssues string `json:"known_issues"`
// TotalBounty int `json:"total_bounty"`
// BountyLevels []BountyLevel `json:"bounty_levels"`
// PaymentInfo string `json:"payment_info"`
// PaymentChain string `json:"payment_chain"`
// ProgramSLA []SLAItem `json:"sla"`
//}

//// FindingDetail defines a finding detail.
//type FindingDetail struct{
// ProgramTarget []string `json:"program_target"`
// Impacts []string `json:"impacts"`
// Attachments []string `json:"attachments"`
// ReceiverInfo ReceiverInfo `json:"receiver_info"`
// PaidInfo PaidInfo `json:"paid_info"`
//}
16 changes: 16 additions & 0 deletions proto/shentu/bounty/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package shentu.bounty.v1;

import "gogoproto/gogo.proto";

import "shentu/bounty/v1/bounty.proto";

option go_package = "github.com/shentufoundation/shentu/x/bounty/types";

message GenesisState {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

repeated Program programs = 1 [(gogoproto.moretags) = "yaml:\"programs\"", (gogoproto.nullable) = false];
repeated Finding findings = 2 [(gogoproto.moretags) = "yaml:\"findings\"", (gogoproto.nullable) = false];
}