-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upstream stf to main (#20286)
Co-authored-by: testinginprod <98415576+testinginprod@users.noreply.github.com>
- Loading branch information
1 parent
03d70aa
commit 83c4b9b
Showing
37 changed files
with
3,117 additions
and
10 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,39 @@ | ||
name: v2 core Tests | ||
on: | ||
pull_request: | ||
merge_group: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
group: ci-${{ github.ref }}-v2-tests | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
stf: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.22" | ||
check-latest: true | ||
cache: true | ||
cache-dependency-path: go.sum | ||
- uses: technote-space/get-diff-action@v6.1.2 | ||
id: git_diff | ||
with: | ||
PATTERNS: | | ||
server/v2/stf/**/*.go | ||
server/v2/stf/go.mod | ||
server/v2/stf/go.sum | ||
- name: test & coverage report creation | ||
if: env.GIT_DIFF | ||
run: | | ||
cd server/v2/stf && go test -mod=readonly -race -timeout 30m -covermode=atomic -tags='ledger test_ledger_mock' |
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,66 @@ | ||
package app | ||
|
||
import ( | ||
"time" | ||
|
||
appmodulev2 "cosmossdk.io/core/appmodule/v2" | ||
"cosmossdk.io/core/event" | ||
"cosmossdk.io/core/transaction" | ||
) | ||
|
||
type QueryRequest struct { | ||
Height int64 | ||
Path string | ||
Data []byte | ||
} | ||
|
||
type QueryResponse struct { | ||
Height int64 | ||
Value []byte | ||
} | ||
|
||
type BlockRequest[T any] struct { | ||
Height uint64 | ||
Time time.Time | ||
Hash []byte | ||
ChainId string | ||
AppHash []byte | ||
Txs []T | ||
ConsensusMessages []transaction.Type | ||
} | ||
|
||
type BlockResponse struct { | ||
Apphash []byte | ||
ConsensusMessagesResponse []transaction.Type | ||
ValidatorUpdates []appmodulev2.ValidatorUpdate | ||
PreBlockEvents []event.Event | ||
BeginBlockEvents []event.Event | ||
TxResults []TxResult | ||
EndBlockEvents []event.Event | ||
} | ||
|
||
type RequestInitChain struct { | ||
Time time.Time | ||
ChainId string | ||
Validators []appmodulev2.ValidatorUpdate | ||
AppStateBytes []byte | ||
InitialHeight int64 | ||
} | ||
|
||
type ResponseInitChain struct { | ||
Validators []appmodulev2.ValidatorUpdate | ||
AppHash []byte | ||
} | ||
|
||
type TxResult struct { | ||
Events []event.Event | ||
Resp []transaction.Type | ||
Error error | ||
Code uint32 | ||
Data []byte | ||
Log string | ||
Info string | ||
GasWanted uint64 | ||
GasUsed uint64 | ||
Codespace string | ||
} |
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,21 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/cosmos/gogoproto/jsonpb" | ||
gogoproto "github.com/cosmos/gogoproto/proto" | ||
) | ||
|
||
// MsgInterfaceProtoName defines the protobuf name of the cosmos Msg interface | ||
const MsgInterfaceProtoName = "cosmos.base.v1beta1.Msg" | ||
|
||
type ProtoCodec interface { | ||
Marshal(v gogoproto.Message) ([]byte, error) | ||
Unmarshal(data []byte, v gogoproto.Message) error | ||
Name() string | ||
} | ||
|
||
type InterfaceRegistry interface { | ||
jsonpb.AnyResolver | ||
ListImplementations(ifaceTypeURL string) []string | ||
ListAllInterfaces() []string | ||
} |
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,6 @@ | ||
package app | ||
|
||
var ( | ||
RuntimeIdentity = []byte("runtime") | ||
ConsensusIdentity = []byte("consensus") | ||
) |
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,16 @@ | ||
package appmodule | ||
|
||
// ExecMode defines the execution mode which can be set on a Context. | ||
type ExecMode uint8 | ||
|
||
// All possible execution modes. | ||
const ( | ||
ExecModeCheck ExecMode = iota | ||
ExecModeReCheck | ||
ExecModeSimulate | ||
ExecModePrepareProposal | ||
ExecModeProcessProposal | ||
ExecModeVoteExtension | ||
ExecModeVerifyVoteExtension | ||
ExecModeFinalize | ||
) |
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 header | ||
|
||
import ( | ||
"crypto/sha256" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestInfo_Bytes(t *testing.T) { | ||
sum := sha256.Sum256([]byte("test-chain")) | ||
info := Info{ | ||
Height: 12345, | ||
Hash: sum[:], | ||
Time: time.Date(2024, time.January, 1, 0, 0, 0, 0, time.UTC), | ||
AppHash: sum[:], | ||
ChainID: "test-chain", | ||
} | ||
|
||
expectedBytes := []byte{ | ||
0x39, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Height (little-endian) | ||
0x26, 0xb0, 0xb8, 0x3e, 0x72, 0x81, 0xbe, 0x3b, 0x11, 0x76, 0x58, 0xb6, 0xf2, 0x63, 0x6d, 0x3, 0x68, 0xca, 0xd3, 0xd7, 0x4f, 0x22, 0x24, 0x34, 0x28, 0xf5, 0x40, 0x1a, 0x4b, 0x70, 0x89, 0x7e, // Hash | ||
0x80, 0x0, 0x92, 0x65, 0x0, 0x0, 0x0, 0x0, // Time (little-endian) | ||
0x26, 0xb0, 0xb8, 0x3e, 0x72, 0x81, 0xbe, 0x3b, 0x11, 0x76, 0x58, 0xb6, 0xf2, 0x63, 0x6d, 0x3, 0x68, 0xca, 0xd3, 0xd7, 0x4f, 0x22, 0x24, 0x34, 0x28, 0xf5, 0x40, 0x1a, 0x4b, 0x70, 0x89, 0x7e, // Apphash | ||
0x0A, // ChainID length | ||
0x74, 0x65, 0x73, 0x74, 0x2d, 0x63, 0x68, 0x61, 0x69, 0x6e, // ChainID | ||
} | ||
|
||
bytes, err := info.Bytes() | ||
require.NoError(t, err) | ||
require.Equal(t, expectedBytes, bytes) | ||
} | ||
|
||
func TestInfo_FromBytes(t *testing.T) { | ||
info := Info{} | ||
|
||
// Test case 1: Valid byte slice | ||
bytes := []byte{ | ||
0x39, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Height (little-endian) | ||
0x26, 0xb0, 0xb8, 0x3e, 0x72, 0x81, 0xbe, 0x3b, 0x11, 0x76, 0x58, 0xb6, 0xf2, 0x63, 0x6d, 0x3, 0x68, 0xca, 0xd3, 0xd7, 0x4f, 0x22, 0x24, 0x34, 0x28, 0xf5, 0x40, 0x1a, 0x4b, 0x70, 0x89, 0x7e, // Hash | ||
0x80, 0x0, 0x92, 0x65, 0x0, 0x0, 0x0, 0x0, // Time (little-endian) | ||
0x26, 0xb0, 0xb8, 0x3e, 0x72, 0x81, 0xbe, 0x3b, 0x11, 0x76, 0x58, 0xb6, 0xf2, 0x63, 0x6d, 0x3, 0x68, 0xca, 0xd3, 0xd7, 0x4f, 0x22, 0x24, 0x34, 0x28, 0xf5, 0x40, 0x1a, 0x4b, 0x70, 0x89, 0x7e, // Apphash | ||
0x0A, // ChainID length | ||
0x74, 0x65, 0x73, 0x74, 0x2d, 0x63, 0x68, 0x61, 0x69, 0x6e, // ChainID | ||
} | ||
|
||
err := info.FromBytes(bytes) | ||
require.NoError(t, err) | ||
require.Equal(t, int64(12345), info.Height) | ||
require.Equal(t, []byte{0x26, 0xb0, 0xb8, 0x3e, 0x72, 0x81, 0xbe, 0x3b, 0x11, 0x76, 0x58, 0xb6, 0xf2, 0x63, 0x6d, 0x3, 0x68, 0xca, 0xd3, 0xd7, 0x4f, 0x22, 0x24, 0x34, 0x28, 0xf5, 0x40, 0x1a, 0x4b, 0x70, 0x89, 0x7e}, info.Hash) | ||
require.Equal(t, time.Date(2024, time.January, 1, 0, 0, 0, 0, time.UTC), info.Time) | ||
require.Equal(t, []byte{0x26, 0xb0, 0xb8, 0x3e, 0x72, 0x81, 0xbe, 0x3b, 0x11, 0x76, 0x58, 0xb6, 0xf2, 0x63, 0x6d, 0x3, 0x68, 0xca, 0xd3, 0xd7, 0x4f, 0x22, 0x24, 0x34, 0x28, 0xf5, 0x40, 0x1a, 0x4b, 0x70, 0x89, 0x7e}, info.AppHash) | ||
require.Equal(t, "test-chain", info.ChainID) | ||
|
||
} |
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ use ( | |
./orm | ||
./simapp | ||
./tests | ||
./server/v2/stf | ||
./store | ||
./store/v2 | ||
./tools/cosmovisor | ||
|
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.