Skip to content

Commit

Permalink
Merge pull request #5 from leonz789/develop-oracle-refactor2.0
Browse files Browse the repository at this point in the history
Develop oracle refactor2.0
  • Loading branch information
leonz789 authored Jan 14, 2025
2 parents 59241ba + 05dea8c commit 725fdea
Show file tree
Hide file tree
Showing 68 changed files with 4,170 additions and 2,351 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,21 @@ jobs:
run: |
make test-unit-cover
if: env.GIT_DIFF
test-unit-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
check-latest: true
- uses: actions/checkout@v4
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Test e2e cases
run: |
make test-unit-e2e
if: env.GIT_DIFF
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ all: build

build-all: tools build lint test vulncheck

.PHONY: distclean clean build-all
.PHONY: distclean clean build-all build

###############################################################################
### makTools & Dependencies ###
Expand Down Expand Up @@ -305,23 +305,27 @@ test-all: test-unit test-race
# we want to include all unit tests in the subfolders (tests/e2e/*)
# We also want to exclude the testutil folder because it contains only
# helper functions for the tests.
PACKAGES_UNIT=$(shell go list ./... | grep -v '/tests/e2e$$' | grep -v 'testutil')
PACKAGES_UNIT=$(shell go list ./... | grep -v '/tests/e2e' | grep -v 'testutil')
PACKAGES_UNIT_E2E=$(shell go list ./... | grep '/tests/e2e')
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-cover test-race
TEST_TARGETS := test-unit test-unit-cover test-race test-unit-e2e

# Test runs-specific rules. To add a new test target, just add
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
# append the new rule to the TEST_TARGETS list.
test-unit: ARGS=-timeout=15m -gcflags=all=-l
test-unit: ARGS=-timeout=15m -gcflags=all=-l --tags devmode
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)

test-race: ARGS=-race
test-race: TEST_PACKAGES=$(PACKAGES_NOSIMULATION)
$(TEST_TARGETS): run-tests

test-unit-cover: ARGS=-timeout=15m -coverprofile=cover.out -covermode=atomic -gcflags=all=-l
test-unit-cover: ARGS=-timeout=15m -coverprofile=cover.out -covermode=atomic -gcflags=all=-l --tags devmode
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)

test-unit-e2e: ARGS=-timeout=15m --tags devmode
test-unit-e2e: TEST_PACKAGES=$(PACKAGES_UNIT_E2E)

test-e2e:
@if [ -z "$(TARGET_VERSION)" ]; then \
echo "Building docker image from local codebase"; \
Expand Down Expand Up @@ -634,4 +638,4 @@ check-licenses:
@python3 scripts/check_licenses.py .

swagger-ui:
docker run -p 8080:8080 -e SWAGGER_JSON=/app/swagger.json -v $(pwd)/client/docs/swagger-ui:/app swaggerapi/swagger-ui
docker run -p 8080:8080 -e SWAGGER_JSON=/app/swagger.json -v $(pwd)/client/docs/swagger-ui:/app swaggerapi/swagger-ui
3 changes: 3 additions & 0 deletions app/ante/cosmos/sigverify.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ func (isd IncrementSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
msg := msg.(*oracletypes.MsgCreatePrice)
if accAddress, err := sdk.AccAddressFromBech32(msg.Creator); err != nil {
return ctx, errors.New("invalid address")
// #nosec G115 // safe conversion
// TODO: define msg.Nonce as uint32 to avoid conversion
} else if _, err := isd.oracleKeeper.CheckAndIncreaseNonce(ctx, sdk.ConsAddress(accAddress).String(), msg.FeederID, uint32(msg.Nonce)); err != nil {
return ctx, err
}
Expand Down Expand Up @@ -445,6 +447,7 @@ func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
sigCount := 0
for _, pk := range pubKeys {
sigCount += CountSubKeys(pk)
// #nosec G115
if uint64(sigCount) > params.TxSigLimit {
return ctx, sdkerrors.ErrTooManySignatures.Wrapf("signatures: %d, limit: %d", sigCount, params.TxSigLimit)
}
Expand Down
2 changes: 2 additions & 0 deletions app/ante/cosmos/txsize_gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim
}

// use stdsignature to mock the size of a full signature
// #nosec G115
simSig := legacytx.StdSignature{ // nolint:staticcheck // this will be removed when proto is ready
Signature: simSecp256k1Sig[:],
PubKey: pubkey,
}

sigBz := legacy.Cdc.MustMarshal(simSig)
// #nosec G115
cost := sdk.Gas(len(sigBz) + 6)

// If the pubkey is a multi-signature pubkey, then we estimate for the maximum
Expand Down
18 changes: 9 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,14 +915,15 @@ func NewExocoreApp(
app.mm.SetOrderBeginBlockers(
upgradetypes.ModuleName, // to upgrade the chain
capabilitytypes.ModuleName, // before any module with capabilities like IBC
epochstypes.ModuleName, // to update the epoch
feemarkettypes.ModuleName, // set EIP-1559 gas prices
evmtypes.ModuleName, // stores chain id in memory
slashingtypes.ModuleName, // TODO after reward
evidencetypes.ModuleName, // TODO after reward
stakingtypes.ModuleName, // track historical info
ibcexported.ModuleName, // handles upgrades of chain and hence client
authz.ModuleName, // clear expired approvals
oracleTypes.ModuleName,
epochstypes.ModuleName, // to update the epoch
feemarkettypes.ModuleName, // set EIP-1559 gas prices
evmtypes.ModuleName, // stores chain id in memory
slashingtypes.ModuleName, // TODO after reward
evidencetypes.ModuleName, // TODO after reward
stakingtypes.ModuleName, // track historical info
ibcexported.ModuleName, // handles upgrades of chain and hence client
authz.ModuleName, // clear expired approvals
// no-op modules
ibctransfertypes.ModuleName,
icatypes.ModuleName,
Expand All @@ -943,7 +944,6 @@ func NewExocoreApp(
rewardTypes.ModuleName,
exoslashTypes.ModuleName,
avsManagerTypes.ModuleName,
oracleTypes.ModuleName,
distrtypes.ModuleName,
)

Expand Down
2 changes: 2 additions & 0 deletions precompiles/avs/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ func (p Precompile) EmitTaskSubmittedByOperator(ctx sdk.Context, stateDB vm.Stat
}
// Prepare the event data:sender,TaskResponse, BlsSignature, Phase
arguments := abi.Arguments{event.Inputs[2], event.Inputs[3], event.Inputs[4], event.Inputs[5]}
// #nosec G115
// TODO: consider modify define of Phase to uint8
packed, err := arguments.Pack(params.CallerAddress.String(), params.TaskResponse, params.BlsSignature, uint8(params.Phase))
if err != nil {
return err
Expand Down
Loading

0 comments on commit 725fdea

Please sign in to comment.