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

api: Improve logging and fix successful proxy execution check #1605

Merged
merged 12 commits into from
Dec 13, 2023
2 changes: 1 addition & 1 deletion build/centrifuge-chain
Submodule centrifuge-chain updated 617 files
14 changes: 8 additions & 6 deletions build/scripts/run_centrifuge_chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Multiple coroutines might execute this script concurrently, the following acts as a lock.
[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -e "$0" "$0" "$@"


CENT_CHAIN_DOCKER_START_TIMEOUT=${CENT_CHAIN_DOCKER_START_TIMEOUT:-600}
CENT_CHAIN_DOCKER_START_INTERVAL=${CENT_CHAIN_DOCKER_START_INTERVAL:-2}

Expand All @@ -20,10 +19,11 @@ fi
# Setup
PARENT_DIR=$(pwd)

mkdir -p /tmp/centrifuge-pod/deps/res
cp "${PARENT_DIR}"/build/centrifuge-chain/docker-compose-local-relay.yml /tmp/centrifuge-pod/deps/
cp "${PARENT_DIR}"/build/centrifuge-chain/docker-compose-local-chain.yml /tmp/centrifuge-pod/deps/
cp "${PARENT_DIR}"/build/centrifuge-chain/res/rococo-local.json /tmp/centrifuge-pod/deps/res/
mkdir -p /tmp/centrifuge-pod/res
mkdir -p /tmp/centrifuge-pod/deps
cp "${PARENT_DIR}"/build/centrifuge-chain/docker/docker-compose-local-relay.yml /tmp/centrifuge-pod/deps/
cp "${PARENT_DIR}"/build/centrifuge-chain/docker/docker-compose-local-chain.yml /tmp/centrifuge-pod/deps/
cp "${PARENT_DIR}"/build/centrifuge-chain/res/rococo-local.json /tmp/centrifuge-pod/res/
docker network inspect docker_default
if [ $? -ne 0 ]; then
docker network create docker_default
Expand Down Expand Up @@ -75,8 +75,10 @@ networks:
EOT
fi

# Temporary fix until https://github.com/centrifuge/centrifuge-chain/pull/1644 is done.
CC_DOCKER_TAG=main-ccbc3a1-23-12-07 \
PARA_CHAIN_SPEC=development-local \
docker-compose -f /tmp/centrifuge-pod/deps/docker-compose-local-chain.yml up -d
docker-compose -f /tmp/centrifuge-pod/deps/docker-compose-local-chain.yml up -d cc_alice

echo "Waiting for Centrifuge Chain to Start Up ..."
maxCount=$(( CENT_CHAIN_DOCKER_START_TIMEOUT / CENT_CHAIN_DOCKER_START_INTERVAL ))
Expand Down
13 changes: 9 additions & 4 deletions centchain/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,15 @@ func (a *api) SubmitAndWatch(

txHash, bn, sig, err := a.SubmitExtrinsic(ctx, meta, c, krp)
if err != nil {
log.Errorf("Extrinsic submission error - %s", err)

return info, ErrExtrinsicSubmission
}

s, err := getSignature(sig)
if err != nil {
log.Errorf("Signature retrieval error - %s", err)

return info, err
}

Expand All @@ -328,6 +332,8 @@ func (a *api) SubmitAndWatch(
job := gocelery.NewRunnerFuncJob("", task, nil, nil, time.Time{})
res, err := a.dispatcher.Dispatch(identity, job)
if err != nil {
log.Errorf("Dispatcher error - %s", err)

return info, fmt.Errorf("failed to dispatch job: %w", err)
}

Expand Down Expand Up @@ -518,9 +524,8 @@ func getErrorIDFromDispatchError(value any) (*registry.ErrorID, error) {
}

const (
ProxyExecutedEventName = "Proxy.ProxyExecuted"
ResultFieldName = "Result.result"
ProxyExecutedExpectedLookupIndex = 40
ProxyExecutedEventName = "Proxy.ProxyExecuted"
ResultFieldName = "Result.result"
)

func checkSuccessfulProxyExecution(meta *types.Metadata, events []*parser.Event, extrinsicIdx int) error {
Expand All @@ -538,7 +543,7 @@ func checkSuccessfulProxyExecution(meta *types.Metadata, events []*parser.Event,
return errors.New("result field has unexpected size")
}

if res[0].Value == nil && res[0].LookupIndex == ProxyExecutedExpectedLookupIndex {
if res[0].Value == nil {
// The DispatchResult is Ok(()).
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion centchain/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ func TestApi_checkExtrinsicEventSuccess_ExtrinsicSuccess_WithProxySuccess(t *tes
Value: registry.DecodedFields{
{
Value: nil,
LookupIndex: ProxyExecutedExpectedLookupIndex,
LookupIndex: 41,
cdamian marked this conversation as resolved.
Show resolved Hide resolved
},
},
LookupIndex: 0,
Expand Down
Loading
Loading