-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5662 from oasisprotocol/kostko/feature/vault
go/vault: Add simple consensus layer vault
- Loading branch information
Showing
57 changed files
with
4,770 additions
and
43 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,5 @@ | ||
go/vault: Add simple consensus layer vault | ||
|
||
The vault service is a simple multi-sig where multiple parties vote to | ||
perform actions on behalf of the vault account. This feature is disabled | ||
by default and needs to be enabled via a governance vote. |
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
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,56 @@ | ||
package abci | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction" | ||
"github.com/oasisprotocol/oasis-core/go/consensus/cometbft/api" | ||
) | ||
|
||
// maxSubcallDepth is the maximum subcall depth. | ||
const maxSubcallDepth = 8 | ||
|
||
// ExecuteMessage implements api.MessageSubscriber. | ||
func (mux *abciMux) ExecuteMessage(ctx *api.Context, kind, msg interface{}) (interface{}, error) { | ||
switch kind { | ||
case api.MessageExecuteSubcall: | ||
// Subcall execution request. | ||
info, ok := msg.(*api.SubcallInfo) | ||
if !ok { | ||
return nil, fmt.Errorf("invalid subcall info") | ||
} | ||
return struct{}{}, mux.executeSubcall(ctx, info) | ||
default: | ||
return nil, nil | ||
} | ||
} | ||
|
||
// executeSubcall executes a subcall. | ||
func (mux *abciMux) executeSubcall(ctx *api.Context, info *api.SubcallInfo) error { | ||
if ctx.CallDepth() > maxSubcallDepth { | ||
return fmt.Errorf("call depth exceeded") | ||
} | ||
|
||
ctx = ctx.WithCallerAddress(info.Caller) | ||
defer ctx.Close() | ||
ctx = ctx.NewTransaction() | ||
defer ctx.Close() | ||
|
||
// Lookup method handler. | ||
app, err := mux.resolveAppForMethod(ctx, info.Method) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
tx := &transaction.Transaction{ | ||
Method: info.Method, | ||
Body: info.Body, | ||
} | ||
if err = app.ExecuteTx(ctx, tx); err != nil { | ||
return err | ||
} | ||
|
||
ctx.Commit() | ||
|
||
return nil | ||
} |
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
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,17 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/oasisprotocol/oasis-core/go/common/cbor" | ||
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction" | ||
staking "github.com/oasisprotocol/oasis-core/go/staking/api" | ||
) | ||
|
||
// SubcallInfo is the information about a subcall that should be executed. | ||
type SubcallInfo struct { | ||
// Caller is the address of the caller. | ||
Caller staking.Address | ||
// Method is the name of the method that should be invoked. | ||
Method transaction.MethodName | ||
// Body is the subcall body. | ||
Body cbor.RawMessage | ||
} |
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
Oops, something went wrong.