From 2021effc2140bc5c61d9299c142b1c07e995092a Mon Sep 17 00:00:00 2001 From: Yusuf Date: Mon, 10 Aug 2026 14:45:05 +0300 Subject: [PATCH 01/10] refactor: remove feepayer and add x coordinate and isodd to action type --- actions/action.pb.go | 102 ++++++++++++++++++++++++------------ apperrors/error.go | 4 +- database/helpers.go | 4 ++ fetchmina/db/queries.sql.go | 16 ++---- fetchmina/fetch.go | 52 +++++++++++++++--- fetchmina/sql/queries.sql | 9 +--- go.mod | 2 +- go.sum | 2 + proto/actions/action.proto | 7 +-- 9 files changed, 133 insertions(+), 65 deletions(-) diff --git a/actions/action.pb.go b/actions/action.pb.go index a59ee59..6717660 100644 --- a/actions/action.pb.go +++ b/actions/action.pb.go @@ -53,9 +53,10 @@ func (ActionType) EnumDescriptor() ([]byte, []int) { type Action struct { BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - FeePayer []byte `protobuf:"bytes,2,opt,name=fee_payer,json=feePayer,proto3" json:"fee_payer,omitempty"` - ActionType ActionType `protobuf:"varint,3,opt,name=action_type,json=actionType,proto3,enum=actions.ActionType" json:"action_type,omitempty"` - Amount int64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` + XCoordinate []byte `protobuf:"bytes,2,opt,name=x_coordinate,json=xCoordinate,proto3" json:"x_coordinate,omitempty"` + IsOdd bool `protobuf:"varint,3,opt,name=is_odd,json=isOdd,proto3" json:"is_odd,omitempty"` + ActionType ActionType `protobuf:"varint,4,opt,name=action_type,json=actionType,proto3,enum=actions.ActionType" json:"action_type,omitempty"` + Amount int64 `protobuf:"varint,5,opt,name=amount,proto3" json:"amount,omitempty"` } func (m *Action) Reset() { *m = Action{} } @@ -138,29 +139,31 @@ func init() { func init() { proto.RegisterFile("actions/action.proto", fileDescriptor_c96fdbc4d8811617) } var fileDescriptor_c96fdbc4d8811617 = []byte{ - // 349 bytes of a gzipped FileDescriptorProto + // 372 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x49, 0x4c, 0x2e, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x87, 0xd0, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0x51, - 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0x98, 0x3e, 0x88, 0x05, 0x91, 0x56, 0x9a, 0xc3, 0xc8, + 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0xb0, 0x98, 0x3e, 0x88, 0x05, 0x91, 0x56, 0xda, 0xc9, 0xc8, 0xc5, 0xe6, 0x08, 0x56, 0x21, 0xa4, 0xc8, 0xc5, 0x93, 0x94, 0x93, 0x9f, 0x9c, 0x1d, 0x9f, 0x91, 0x9a, 0x99, 0x9e, 0x51, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x1c, 0xc4, 0x0d, 0x16, 0xf3, 0x00, - 0x0b, 0x09, 0x49, 0x73, 0x71, 0xa6, 0xa5, 0xa6, 0xc6, 0x17, 0x24, 0x56, 0xa6, 0x16, 0x49, 0x30, - 0x29, 0x30, 0x6a, 0xf0, 0x04, 0x71, 0xa4, 0xa5, 0xa6, 0x06, 0x80, 0xf8, 0x42, 0x26, 0x5c, 0xdc, - 0x10, 0xbb, 0xe2, 0x4b, 0x2a, 0x0b, 0x52, 0x25, 0x98, 0x15, 0x18, 0x35, 0xf8, 0x8c, 0x84, 0xf5, - 0xa0, 0xf6, 0xeb, 0x41, 0x6c, 0x09, 0xa9, 0x2c, 0x48, 0x0d, 0xe2, 0x4a, 0x84, 0xb3, 0x85, 0xc4, - 0xb8, 0xd8, 0x12, 0x73, 0xf3, 0x4b, 0xf3, 0x4a, 0x24, 0x58, 0xc0, 0xf6, 0x41, 0x79, 0x56, 0x2c, - 0x1d, 0x0b, 0xe4, 0x19, 0x94, 0x7c, 0xb9, 0x38, 0x5c, 0x92, 0x82, 0x52, 0x93, 0xf3, 0x8b, 0x52, - 0x84, 0x04, 0xb8, 0x98, 0xb3, 0x53, 0x2b, 0xa1, 0xce, 0x02, 0x31, 0x85, 0x34, 0xb9, 0x60, 0xbe, - 0x93, 0x60, 0x52, 0x60, 0xd6, 0xe0, 0x36, 0xe2, 0x47, 0xb3, 0x2d, 0x08, 0x26, 0x0f, 0x31, 0x4e, - 0xcb, 0x82, 0x8b, 0x0b, 0xe1, 0x0c, 0x21, 0x7e, 0x2e, 0xee, 0x50, 0xbf, 0xe0, 0x00, 0x57, 0x67, - 0x4f, 0x37, 0x4f, 0x57, 0x17, 0x01, 0x06, 0x21, 0x6e, 0x2e, 0x76, 0x17, 0xd7, 0x00, 0xff, 0x60, - 0xcf, 0x10, 0x01, 0x46, 0x21, 0x1e, 0x2e, 0x8e, 0x70, 0xcf, 0x10, 0x0f, 0x97, 0x20, 0xc7, 0x70, - 0x01, 0x26, 0x27, 0xff, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, - 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4d, - 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcb, 0x4f, 0x49, 0x35, 0x34, - 0x30, 0xd4, 0xcd, 0xcc, 0xd7, 0x4f, 0x2c, 0x4a, 0xce, 0xc8, 0x2c, 0x4b, 0xd5, 0x2d, 0x2f, 0x4a, - 0x2c, 0x28, 0x48, 0x2d, 0x82, 0x46, 0x4a, 0xb1, 0x35, 0x94, 0x4e, 0x62, 0x03, 0x87, 0xbf, 0x31, - 0x20, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xdd, 0xdc, 0x84, 0xb6, 0x01, 0x00, 0x00, + 0x0b, 0x81, 0x94, 0x54, 0xc4, 0x27, 0xe7, 0xe7, 0x17, 0xa5, 0x64, 0xe6, 0x25, 0x96, 0xa4, 0x4a, + 0x30, 0x29, 0x30, 0x6a, 0xf0, 0x04, 0x71, 0x57, 0x38, 0xc3, 0x85, 0x84, 0x44, 0xb9, 0xd8, 0x32, + 0x8b, 0xe3, 0xf3, 0x53, 0x52, 0x24, 0x98, 0x15, 0x18, 0x35, 0x38, 0x82, 0x58, 0x33, 0x8b, 0xfd, + 0x53, 0x52, 0x84, 0x4c, 0xb8, 0xb8, 0x21, 0x0e, 0x89, 0x2f, 0xa9, 0x2c, 0x48, 0x95, 0x60, 0x51, + 0x60, 0xd4, 0xe0, 0x33, 0x12, 0xd6, 0x83, 0x3a, 0x4e, 0x0f, 0xe2, 0x84, 0x90, 0xca, 0x82, 0xd4, + 0x20, 0xae, 0x44, 0x38, 0x5b, 0x48, 0x8c, 0x8b, 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, + 0x15, 0xec, 0x18, 0x28, 0xcf, 0x8a, 0xa5, 0x63, 0x81, 0x3c, 0x83, 0x92, 0x2f, 0x17, 0x87, 0x4b, + 0x52, 0x50, 0x6a, 0x72, 0x7e, 0x51, 0x8a, 0x90, 0x00, 0x17, 0x73, 0x76, 0x6a, 0x25, 0xd4, 0xcd, + 0x20, 0xa6, 0x90, 0x26, 0x17, 0xcc, 0xeb, 0x12, 0x4c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0xfc, 0x68, + 0xb6, 0x05, 0xc1, 0xe4, 0x21, 0xc6, 0x69, 0x59, 0x70, 0x71, 0x21, 0x9c, 0x21, 0xc4, 0xcf, 0xc5, + 0x1d, 0xea, 0x17, 0x1c, 0xe0, 0xea, 0xec, 0xe9, 0xe6, 0xe9, 0xea, 0x22, 0xc0, 0x20, 0xc4, 0xcd, + 0xc5, 0xee, 0xe2, 0x1a, 0xe0, 0x1f, 0xec, 0x19, 0x22, 0xc0, 0x28, 0xc4, 0xc3, 0xc5, 0x11, 0xee, + 0x19, 0xe2, 0xe1, 0x12, 0xe4, 0x18, 0x2e, 0xc0, 0xe4, 0xe4, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, + 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, + 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xa6, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, + 0xfa, 0x79, 0xf9, 0x29, 0xa9, 0x86, 0x06, 0x86, 0xba, 0x99, 0xf9, 0xfa, 0x89, 0x45, 0xc9, 0x19, + 0x99, 0x65, 0xa9, 0xba, 0xe5, 0x45, 0x89, 0x05, 0x05, 0xa9, 0x45, 0xd0, 0x18, 0x2b, 0xb6, 0x86, + 0xd2, 0x49, 0x6c, 0xe0, 0xc8, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x74, 0xad, 0xd6, 0x8f, + 0xd3, 0x01, 0x00, 0x00, } func (m *Action) Marshal() (dAtA []byte, err error) { @@ -186,17 +189,27 @@ func (m *Action) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Amount != 0 { i = encodeVarintAction(dAtA, i, uint64(m.Amount)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if m.ActionType != 0 { i = encodeVarintAction(dAtA, i, uint64(m.ActionType)) i-- + dAtA[i] = 0x20 + } + if m.IsOdd { + i-- + if m.IsOdd { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- dAtA[i] = 0x18 } - if len(m.FeePayer) > 0 { - i -= len(m.FeePayer) - copy(dAtA[i:], m.FeePayer) - i = encodeVarintAction(dAtA, i, uint64(len(m.FeePayer))) + if len(m.XCoordinate) > 0 { + i -= len(m.XCoordinate) + copy(dAtA[i:], m.XCoordinate) + i = encodeVarintAction(dAtA, i, uint64(len(m.XCoordinate))) i-- dAtA[i] = 0x12 } @@ -270,10 +283,13 @@ func (m *Action) Size() (n int) { if m.BlockHeight != 0 { n += 1 + sovAction(uint64(m.BlockHeight)) } - l = len(m.FeePayer) + l = len(m.XCoordinate) if l > 0 { n += 1 + l + sovAction(uint64(l)) } + if m.IsOdd { + n += 2 + } if m.ActionType != 0 { n += 1 + sovAction(uint64(m.ActionType)) } @@ -357,7 +373,7 @@ func (m *Action) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FeePayer", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field XCoordinate", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -384,12 +400,32 @@ func (m *Action) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FeePayer = append(m.FeePayer[:0], dAtA[iNdEx:postIndex]...) - if m.FeePayer == nil { - m.FeePayer = []byte{} + m.XCoordinate = append(m.XCoordinate[:0], dAtA[iNdEx:postIndex]...) + if m.XCoordinate == nil { + m.XCoordinate = []byte{} } iNdEx = postIndex case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsOdd", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAction + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsOdd = bool(v != 0) + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field ActionType", wireType) } @@ -408,7 +444,7 @@ func (m *Action) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } diff --git a/apperrors/error.go b/apperrors/error.go index bbc7822..641fee6 100644 --- a/apperrors/error.go +++ b/apperrors/error.go @@ -57,8 +57,8 @@ var ( ErrInvalidAmount = errors.New("invalid action amount") // ErrInvalidActionData reports that an action payload is missing required fields. ErrInvalidActionData = errors.New("invalid action data") - // ErrMissingFeePayer reports that an action payload is missing the fee payer account. - ErrMissingFeePayer = errors.New("missing fee payer") + // ErrEmptyXCoordinate reports that an action payload is missing the x-coordinate of account's pubkey. + ErrEmptyXCoordinate = errors.New("empty x coordinate") ) var ( diff --git a/database/helpers.go b/database/helpers.go index 6fdb27d..30f32f9 100644 --- a/database/helpers.go +++ b/database/helpers.go @@ -45,6 +45,10 @@ func validateRecord(record actions.DbRecord) error { if act.Amount <= 0 { return cosmosErrors.Wrap(apperrors.ErrInvalidAmount, "non-positive amount") } + + if len(act.XCoordinate) == 0 { + return apperrors.ErrEmptyXCoordinate + } } return nil diff --git a/fetchmina/db/queries.sql.go b/fetchmina/db/queries.sql.go index bd222d4..5080396 100644 --- a/fetchmina/db/queries.sql.go +++ b/fetchmina/db/queries.sql.go @@ -83,7 +83,6 @@ WITH action_rows AS ( zau.id AS account_update_id, zc.id AS zkapp_command_id, zc.hash, - fee_pk.value AS fee_payer, COALESCE( array_agg(field.field ORDER BY action_field.field_index) FILTER (WHERE field.field IS NOT NULL), @@ -92,8 +91,6 @@ WITH action_rows AS ( FROM blocks b JOIN blocks_zkapp_commands bzc ON bzc.block_id = b.id JOIN zkapp_commands zc ON zc.id = bzc.zkapp_command_id - JOIN zkapp_fee_payer_body zfpb ON zfpb.id = zc.zkapp_fee_payer_body_id - JOIN public_keys fee_pk ON fee_pk.id = zfpb.public_key_id JOIN LATERAL unnest(zc.zkapp_account_updates_ids) WITH ORDINALITY AS command_update(account_update_id, account_update_index) ON true JOIN zkapp_account_update zau ON zau.id = command_update.account_update_id @@ -117,8 +114,7 @@ WITH action_rows AS ( action_array.action_index, zau.id, zc.id, - zc.hash, - fee_pk.value + zc.hash ), deduped_action_rows AS ( SELECT DISTINCT ON (zkapp_command_id, account_update_id, action_index) @@ -128,7 +124,6 @@ deduped_action_rows AS ( action_index, zkapp_command_id, account_update_id, - fee_payer, data FROM action_rows ORDER BY @@ -138,7 +133,7 @@ deduped_action_rows AS ( block_id DESC, sequence_no DESC ) -SELECT height, fee_payer, data +SELECT height, data FROM deduped_action_rows ORDER BY height, @@ -155,9 +150,8 @@ type ListActionRowsByBlockIDParams struct { } type ListActionRowsByBlockIDRow struct { - Height int64 - FeePayer string - Data []string + Height int64 + Data []string } func (q *Queries) ListActionRowsByBlockID(ctx context.Context, arg ListActionRowsByBlockIDParams) ([]ListActionRowsByBlockIDRow, error) { @@ -169,7 +163,7 @@ func (q *Queries) ListActionRowsByBlockID(ctx context.Context, arg ListActionRow items := []ListActionRowsByBlockIDRow{} for rows.Next() { var i ListActionRowsByBlockIDRow - if err := rows.Scan(&i.Height, &i.FeePayer, &i.Data); err != nil { + if err := rows.Scan(&i.Height, &i.Data); err != nil { return nil, err } items = append(items, i) diff --git a/fetchmina/fetch.go b/fetchmina/fetch.go index 8e74e70..a3c2b33 100644 --- a/fetchmina/fetch.go +++ b/fetchmina/fetch.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "log/slog" + "math/big" "strconv" "strings" "sync" @@ -16,12 +17,15 @@ import ( "github.com/node101-io/archive-wrapper/apperrors" sqlcdb "github.com/node101-io/archive-wrapper/fetchmina/db" "github.com/node101-io/mina-signer-go/address" + minafield "github.com/node101-io/mina-signer-go/field" ) const ( - actionTypeIndex = 0 - actionAmountIndex = 3 - minimumActionFields = actionAmountIndex + 1 + actionTypeIndex = 0 + actionXCoordinateIndex = 1 + actionIsOddIndex = 2 + actionAmountIndex = 3 + minimumActionFields = actionAmountIndex + 1 ) // MinaClient reads best-chain block data and zkApp actions from the archive database. @@ -114,7 +118,7 @@ func (c *MinaClient) FetchActions(ctx context.Context, blockHeight int64) ([]act continue } - action, err := actionFromRawData(row.Height, row.FeePayer, row.Data) + action, err := actionFromRawData(row.Height, row.Data) if err != nil { return nil, err } @@ -225,7 +229,7 @@ func (c *MinaClient) bestChainBlockIDForHeight(ctx context.Context, blockHeight return row.ID, nil } -func actionFromRawData(blockHeight int64, feePayer string, data []string) (*actions.Action, error) { +func actionFromRawData(blockHeight int64, data []string) (*actions.Action, error) { if len(data) == 0 { return nil, nil } @@ -240,7 +244,6 @@ func actionFromRawData(blockHeight int64, feePayer string, data []string) (*acti return nil, nil case actions.ActionType_DEPOSIT, actions.ActionType_WITHDRAW: default: - // Ignore action types we do not index yet. return nil, nil } @@ -252,19 +255,52 @@ func actionFromRawData(blockHeight int64, feePayer string, data []string) (*acti return nil, nil } - minaAddr, err := address.NewAddress(feePayer).Marshal() + xCoordinateBytes, err := fieldBytesFromDecimal(data[actionXCoordinateIndex]) + if err != nil { + return nil, err + } + + isOdd, err := parseIsOddField(data[actionIsOddIndex]) if err != nil { return nil, err } return &actions.Action{ BlockHeight: blockHeight, - FeePayer: minaAddr, + XCoordinate: xCoordinateBytes, + IsOdd: isOdd, ActionType: actionType, Amount: amount, }, nil } +func fieldBytesFromDecimal(s string) ([]byte, error) { + n, ok := new(big.Int).SetString(s, 10) + if !ok || n.Sign() < 0 { + return nil, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account x_coordinate") + } + + size := minafield.NewField().ElementSize() + b := n.FillBytes(make([]byte, size)) + + if _, err := minafield.NewFieldElement(b); err != nil { + return nil, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account x_cordinate") + } + + return b, nil +} + +func parseIsOddField(v string) (bool, error) { + switch v { + case "0": + return false, nil + case "1": + return true, nil + default: + return false, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account is_odd") + } +} + func wrapQueryError(operation string, err error) error { if err == nil { return nil diff --git a/fetchmina/sql/queries.sql b/fetchmina/sql/queries.sql index 7b92fda..059040d 100644 --- a/fetchmina/sql/queries.sql +++ b/fetchmina/sql/queries.sql @@ -88,7 +88,6 @@ WITH action_rows AS ( zau.id AS account_update_id, zc.id AS zkapp_command_id, zc.hash, - fee_pk.value AS fee_payer, COALESCE( array_agg(field.field ORDER BY action_field.field_index) FILTER (WHERE field.field IS NOT NULL), @@ -97,8 +96,6 @@ WITH action_rows AS ( FROM blocks b JOIN blocks_zkapp_commands bzc ON bzc.block_id = b.id JOIN zkapp_commands zc ON zc.id = bzc.zkapp_command_id - JOIN zkapp_fee_payer_body zfpb ON zfpb.id = zc.zkapp_fee_payer_body_id - JOIN public_keys fee_pk ON fee_pk.id = zfpb.public_key_id JOIN LATERAL unnest(zc.zkapp_account_updates_ids) WITH ORDINALITY AS command_update(account_update_id, account_update_index) ON true JOIN zkapp_account_update zau ON zau.id = command_update.account_update_id @@ -122,8 +119,7 @@ WITH action_rows AS ( action_array.action_index, zau.id, zc.id, - zc.hash, - fee_pk.value + zc.hash ), deduped_action_rows AS ( SELECT DISTINCT ON (zkapp_command_id, account_update_id, action_index) @@ -133,7 +129,6 @@ deduped_action_rows AS ( action_index, zkapp_command_id, account_update_id, - fee_payer, data FROM action_rows ORDER BY @@ -143,7 +138,7 @@ deduped_action_rows AS ( block_id DESC, sequence_no DESC ) -SELECT height, fee_payer, data +SELECT height, data FROM deduped_action_rows ORDER BY height, diff --git a/go.mod b/go.mod index 4f8f663..f1c4407 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/errors v1.1.0 github.com/cosmos/gogoproto v1.7.2 github.com/jackc/pgx/v5 v5.10.0 - github.com/node101-io/mina-signer-go v0.0.0-20260601165332-9dc4888e6819 + github.com/node101-io/mina-signer-go v0.0.0-20260810105351-862ef720d914 github.com/spf13/viper v1.21.0 github.com/stretchr/testify v1.11.1 github.com/syndtr/goleveldb v1.0.0 diff --git a/go.sum b/go.sum index d5747dd..0eaa5f6 100644 --- a/go.sum +++ b/go.sum @@ -51,6 +51,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/node101-io/mina-signer-go v0.0.0-20260601165332-9dc4888e6819 h1:PYnyy92xzQ8oNjsydAenjPURHvOcTu6lsPiJ0iFYCoI= github.com/node101-io/mina-signer-go v0.0.0-20260601165332-9dc4888e6819/go.mod h1:vGZaN+qwZwJzSm5WQ4hTs95ULhysLLhz7kV+SLj4Abc= +github.com/node101-io/mina-signer-go v0.0.0-20260810105351-862ef720d914 h1:gANeiWrgwdqxPzNnEx0i5Ew5NzyF897OmFRHQ7keQtk= +github.com/node101-io/mina-signer-go v0.0.0-20260810105351-862ef720d914/go.mod h1:vGZaN+qwZwJzSm5WQ4hTs95ULhysLLhz7kV+SLj4Abc= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/proto/actions/action.proto b/proto/actions/action.proto index 1003c4c..7a5a59e 100644 --- a/proto/actions/action.proto +++ b/proto/actions/action.proto @@ -16,9 +16,10 @@ message Action { option (gogoproto.goproto_getters) = false; int64 block_height = 1; - bytes fee_payer = 2; - ActionType action_type = 3; - int64 amount = 4; + bytes x_coordinate = 2; + bool is_odd = 3; + ActionType action_type = 4; + int64 amount = 5; } message DbRecord { From 0e17968fe9ae86be551cbd9c6b593b3d6d64047a Mon Sep 17 00:00:00 2001 From: Yusuf Date: Mon, 10 Aug 2026 15:00:35 +0300 Subject: [PATCH 02/10] test: update tests to match with the new action fields --- actions/action_test.go | 6 +++-- cmd/archive-wrapper/cli_test.go | 31 ++++++++++++++++++++++ cmd/archive-wrapper/control_socket_test.go | 20 +++++++++----- cmd/archive-wrapper/healthcheck_test.go | 8 ++++++ cmd/archive-wrapper/runtime_test.go | 2 +- database/db_test.go | 12 ++++++--- fetchmina/fetch_test.go | 10 +++---- indexer/indexer_test.go | 18 +++++++------ query/query_test.go | 12 ++++++--- tests/container/smoke_test.go | 18 +++++++------ 10 files changed, 99 insertions(+), 38 deletions(-) diff --git a/actions/action_test.go b/actions/action_test.go index a03ef7e..7d8c6f5 100644 --- a/actions/action_test.go +++ b/actions/action_test.go @@ -10,7 +10,8 @@ import ( func TestActionProtoRoundTrip(t *testing.T) { want := &Action{ BlockHeight: 42, - FeePayer: []byte("alice"), + XCoordinate: []byte("alice-x"), + IsOdd: true, ActionType: ActionType_DEPOSIT, Amount: 99, } @@ -29,7 +30,8 @@ func TestDbRecordProtoRoundTrip(t *testing.T) { Actions: []*Action{ { BlockHeight: 7, - FeePayer: []byte("alice"), + XCoordinate: []byte("alice-x"), + IsOdd: true, ActionType: ActionType_WITHDRAW, Amount: 11, }, diff --git a/cmd/archive-wrapper/cli_test.go b/cmd/archive-wrapper/cli_test.go index b4b9982..a4349fd 100644 --- a/cmd/archive-wrapper/cli_test.go +++ b/cmd/archive-wrapper/cli_test.go @@ -14,6 +14,7 @@ import ( ) func TestRunCommandRejectsMissingPostgresBeforeDatabaseCreation(t *testing.T) { + clearCommandEnvironment(t) root := t.TempDir() dbPath := filepath.Join(root, "wrapper-db") controlSocketPath := filepath.Join(root, "control.sock") @@ -39,6 +40,7 @@ func TestRunCommandRejectsMissingPostgresBeforeDatabaseCreation(t *testing.T) { } func TestRemovedLifecycleCommandsAreRejected(t *testing.T) { + clearCommandEnvironment(t) logger := slog.New(slog.NewTextHandler(io.Discard, nil)) for _, command := range []string{"start", "proceed"} { t.Run(command, func(t *testing.T) { @@ -49,6 +51,7 @@ func TestRemovedLifecycleCommandsAreRejected(t *testing.T) { } func TestCommandsRejectUnexpectedArguments(t *testing.T) { + clearCommandEnvironment(t) logger := slog.New(slog.NewTextHandler(io.Discard, nil)) tests := []struct { name string @@ -67,6 +70,7 @@ func TestCommandsRejectUnexpectedArguments(t *testing.T) { } func TestStopRejectsLegacySocketPathFlag(t *testing.T) { + clearCommandEnvironment(t) err := run( []string{"stop", "--socket-path", "/tmp/wrapper.sock"}, context.Background(), @@ -77,6 +81,7 @@ func TestStopRejectsLegacySocketPathFlag(t *testing.T) { } func TestResolveConfigPathPrecedence(t *testing.T) { + clearCommandEnvironment(t) tests := []struct { name string args []string @@ -114,6 +119,7 @@ func TestResolveConfigPathPrecedence(t *testing.T) { } func TestResolveStopSocketPathPrecedence(t *testing.T) { + clearCommandEnvironment(t) configPath := writeStopConfig(t, "/tmp/config.sock") t.Run("cli_over_environment_and_config", func(t *testing.T) { @@ -216,3 +222,28 @@ func unsetEnvironment(t *testing.T, key string) { func stringPointer(value string) *string { return &value } + +func clearCommandEnvironment(t *testing.T) { + t.Helper() + for _, key := range []string{ + "ARCHIVE_WRAPPER_CONFIG", + "ARCHIVE_WRAPPER_CHAIN_HOME", + "ARCHIVE_WRAPPER_DB_PATH", + "ARCHIVE_WRAPPER_GRPC_LISTEN_ADDRESS", + "ARCHIVE_WRAPPER_GRPC_TRANSPORT_MODE", + "ARCHIVE_WRAPPER_CONTROL_SOCKET_PATH", + "ARCHIVE_WRAPPER_HEALTHCHECK_ADDRESS", + "ARCHIVE_WRAPPER_LOG_PATH", + "POSTGRES_URI", + } { + oldValue, wasSet := os.LookupEnv(key) + require.NoError(t, os.Unsetenv(key)) + t.Cleanup(func() { + if wasSet { + require.NoError(t, os.Setenv(key, oldValue)) + return + } + require.NoError(t, os.Unsetenv(key)) + }) + } +} diff --git a/cmd/archive-wrapper/control_socket_test.go b/cmd/archive-wrapper/control_socket_test.go index d782de7..c22ce32 100644 --- a/cmd/archive-wrapper/control_socket_test.go +++ b/cmd/archive-wrapper/control_socket_test.go @@ -15,10 +15,7 @@ import ( func TestCloseControlSocketListenerPreservesReplacementSocket(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - socketPath := filepath.Join("/tmp", fmt.Sprintf("archive-wrapper-%d.sock", time.Now().UnixNano())) - t.Cleanup(func() { - _ = os.Remove(socketPath) - }) + socketPath := testSocketPath(t, "replacement") listener, err := net.Listen(network, socketPath) require.NoError(t, err) @@ -49,7 +46,7 @@ func TestCloseControlSocketListenerPreservesReplacementSocket(t *testing.T) { func TestControlServerCloseIsIdempotentAndRemovesSocket(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - socketPath := filepath.Join(t.TempDir(), "control.sock") + socketPath := testSocketPath(t, "close") server, err := listenControlSocket(socketPath, func() {}, logger) require.NoError(t, err) @@ -66,7 +63,7 @@ func TestControlServerCloseIsIdempotentAndRemovesSocket(t *testing.T) { func TestControlServerStopCommandCancelsRuntime(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - socketPath := filepath.Join(t.TempDir(), "control.sock") + socketPath := testSocketPath(t, "stop") canceled := make(chan struct{}) server, err := listenControlSocket(socketPath, func() { close(canceled) }, logger) require.NoError(t, err) @@ -103,3 +100,14 @@ func (l *replacementListener) Close() error { l.replacement = replacement return nil } + +func testSocketPath(t *testing.T, prefix string) string { + t.Helper() + + socketPath := filepath.Join("/tmp", fmt.Sprintf("archive-wrapper-%s-%d.sock", prefix, time.Now().UnixNano())) + t.Cleanup(func() { + _ = os.Remove(socketPath) + }) + + return socketPath +} diff --git a/cmd/archive-wrapper/healthcheck_test.go b/cmd/archive-wrapper/healthcheck_test.go index b7cdaba..9452199 100644 --- a/cmd/archive-wrapper/healthcheck_test.go +++ b/cmd/archive-wrapper/healthcheck_test.go @@ -17,6 +17,7 @@ import ( ) func TestHealthDialAddress(t *testing.T) { + clearCommandEnvironment(t) tests := []struct { name string address string @@ -46,6 +47,7 @@ func TestHealthDialAddress(t *testing.T) { } func TestResolveHealthcheckAddressPrecedence(t *testing.T) { + clearCommandEnvironment(t) configPath := writeHealthcheckConfig(t, "127.0.0.1:9001") lookup := mapLookup(map[string]string{ "ARCHIVE_WRAPPER_CONFIG": configPath, @@ -66,6 +68,7 @@ func TestResolveHealthcheckAddressPrecedence(t *testing.T) { } func TestResolveHealthcheckAddressUsesRuntimeEnvironment(t *testing.T) { + clearCommandEnvironment(t) configPath := writeHealthcheckConfig(t, "127.0.0.1:9001") t.Setenv("ARCHIVE_WRAPPER_GRPC_LISTEN_ADDRESS", "0.0.0.0:9004") t.Setenv("ARCHIVE_WRAPPER_GRPC_TRANSPORT_MODE", "trusted-network") @@ -76,6 +79,7 @@ func TestResolveHealthcheckAddressUsesRuntimeEnvironment(t *testing.T) { } func TestResolveHealthcheckAddressRejectsEmptyExplicitValues(t *testing.T) { + clearCommandEnvironment(t) _, err := resolveHealthcheckAddress("", true, "unused", true, mapLookup(nil)) require.ErrorIs(t, err, apperrors.ErrGRPCAddressRequired) @@ -89,6 +93,7 @@ func TestResolveHealthcheckAddressRejectsEmptyExplicitValues(t *testing.T) { } func TestCheckQueryHealth(t *testing.T) { + clearCommandEnvironment(t) tests := []struct { name string status grpcHealthV1.HealthCheckResponse_ServingStatus @@ -116,12 +121,14 @@ func TestCheckQueryHealth(t *testing.T) { } func TestCheckQueryHealthFailsForUnavailableTarget(t *testing.T) { + clearCommandEnvironment(t) ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond) defer cancel() require.Error(t, checkQueryHealth(ctx, "127.0.0.1:1")) } func TestRunMainHealthcheckDoesNotInitializeRuntimeLogger(t *testing.T) { + clearCommandEnvironment(t) logPath := filepath.Join(t.TempDir(), "healthcheck.log") t.Setenv("ARCHIVE_WRAPPER_LOG_PATH", logPath) var stderr bytes.Buffer @@ -137,6 +144,7 @@ func TestRunMainHealthcheckDoesNotInitializeRuntimeLogger(t *testing.T) { } func TestRunHealthcheckRejectsNonPositiveTimeout(t *testing.T) { + clearCommandEnvironment(t) err := runHealthcheckCommand([]string{"--address", "127.0.0.1:9095", "--timeout", "0s"}, mapLookup(nil)) require.ErrorContains(t, err, "greater than zero") } diff --git a/cmd/archive-wrapper/runtime_test.go b/cmd/archive-wrapper/runtime_test.go index fc6ed44..f702ef9 100644 --- a/cmd/archive-wrapper/runtime_test.go +++ b/cmd/archive-wrapper/runtime_test.go @@ -164,7 +164,7 @@ func TestRunRuntimeStopsCleanlyOnExternalCancellation(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) root := t.TempDir() dbPath := filepath.Join(root, "db") - controlSocketPath := filepath.Join(root, "control.sock") + controlSocketPath := testSocketPath(t, "runtime") inputs := testRuntimeInputs(dbPath, controlSocketPath) inputs.Config.GRPCListenAddress = reserveLoopbackAddress(t) inputs.BridgeParams.ContractAddress = testBridgeContractAddress diff --git a/database/db_test.go b/database/db_test.go index d4daa82..1ebde1a 100644 --- a/database/db_test.go +++ b/database/db_test.go @@ -37,7 +37,8 @@ func TestDbManager_InsertThenGet(t *testing.T) { Actions: []*actions.Action{ { BlockHeight: 7, - FeePayer: []byte("alice"), + XCoordinate: []byte("alice-x"), + IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 42, }, @@ -56,7 +57,8 @@ func TestDbManager_InsertThenGet(t *testing.T) { // Ensure they have the same values require.Equal(t, got.Actions[0].BlockHeight, want.Actions[0].BlockHeight) - require.Equal(t, got.Actions[0].FeePayer, want.Actions[0].FeePayer) + require.Equal(t, got.Actions[0].XCoordinate, want.Actions[0].XCoordinate) + require.Equal(t, got.Actions[0].IsOdd, want.Actions[0].IsOdd) require.Equal(t, got.Actions[0].ActionType, want.Actions[0].ActionType) require.Equal(t, got.Actions[0].Amount, want.Actions[0].Amount) @@ -438,7 +440,8 @@ func TestDbManagerGetRejectsCorruptPersistedRecord(t *testing.T) { Key: 11, Actions: []*actions.Action{{ BlockHeight: 11, - FeePayer: []byte("alice"), + XCoordinate: []byte("alice-x"), + IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 1, }}, @@ -451,7 +454,8 @@ func TestDbManagerGetRejectsCorruptPersistedRecord(t *testing.T) { Key: 10, Actions: []*actions.Action{{ BlockHeight: 10, - FeePayer: []byte("alice"), + XCoordinate: []byte("alice-x"), + IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 0, }}, diff --git a/fetchmina/fetch_test.go b/fetchmina/fetch_test.go index a7ef099..4b2f1af 100644 --- a/fetchmina/fetch_test.go +++ b/fetchmina/fetch_test.go @@ -41,14 +41,15 @@ func TestNewMinaClientRejectsInvalidContractAddress(t *testing.T) { } func TestActionFromRawDataBuildsAction(t *testing.T) { - action, err := actionFromRawData(99, validAddress, []string{"1", "ignored", "ignored", "42"}) + action, err := actionFromRawData(99, []string{"1", "7", "1", "42"}) require.NoError(t, err) require.NotNil(t, action) require.Equal(t, int64(99), action.BlockHeight) require.Equal(t, actions.ActionType_DEPOSIT, action.ActionType) require.Equal(t, int64(42), action.Amount) - require.NotEmpty(t, action.FeePayer) + require.Equal(t, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7}, action.XCoordinate) + require.True(t, action.IsOdd) } func TestGetMinaBlockHeightWrapsRetryableQueryErrors(t *testing.T) { @@ -310,8 +311,7 @@ func validActionQueryRow(height int64) sqlcdb.ListActionRowsByBlockIDRow { func actionQueryRow(height int64, actionType string, amount string) sqlcdb.ListActionRowsByBlockIDRow { return sqlcdb.ListActionRowsByBlockIDRow{ - Height: height, - FeePayer: validAddress, - Data: []string{actionType, "ignored", "ignored", amount}, + Height: height, + Data: []string{actionType, "7", "1", amount}, } } diff --git a/indexer/indexer_test.go b/indexer/indexer_test.go index 4ad4bf2..70a1988 100644 --- a/indexer/indexer_test.go +++ b/indexer/indexer_test.go @@ -40,8 +40,8 @@ func TestNewIndexerRejectsNilConnection(t *testing.T) { func TestIndexActionsBuildsRecord(t *testing.T) { items := []actions.Action{ - {BlockHeight: 7, FeePayer: []byte("alice"), ActionType: actions.ActionType_DEPOSIT, Amount: 5}, - {BlockHeight: 7, FeePayer: []byte("bob"), ActionType: actions.ActionType_WITHDRAW, Amount: 3}, + {BlockHeight: 7, XCoordinate: []byte("alice-x"), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 5}, + {BlockHeight: 7, XCoordinate: []byte("bob-x"), IsOdd: false, ActionType: actions.ActionType_WITHDRAW, Amount: 3}, } record, err := IndexActions(items, 7) @@ -49,8 +49,10 @@ func TestIndexActionsBuildsRecord(t *testing.T) { require.Equal(t, int64(7), record.Key) require.Len(t, record.Actions, 2) - require.Equal(t, []byte("alice"), record.Actions[0].FeePayer) - require.Equal(t, []byte("bob"), record.Actions[1].FeePayer) + require.Equal(t, []byte("alice-x"), record.Actions[0].XCoordinate) + require.True(t, record.Actions[0].IsOdd) + require.Equal(t, []byte("bob-x"), record.Actions[1].XCoordinate) + require.False(t, record.Actions[1].IsOdd) } func TestWithRetryReturnsContextErrorWhenCanceled(t *testing.T) { @@ -105,7 +107,8 @@ func TestRunReconcilesAuthoritativeTipForDuplicateAndOutOfOrderNotificationPaylo Key: 68, Actions: []*actions.Action{{ BlockHeight: 68, - FeePayer: []byte(testContractAddress), + XCoordinate: []byte("persisted-x"), + IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 42, }}, @@ -669,8 +672,7 @@ func notification(payload string) *pgconn.Notification { func validActionRow(height int64) sqlcdb.ListActionRowsByBlockIDRow { return sqlcdb.ListActionRowsByBlockIDRow{ - Height: height, - FeePayer: testContractAddress, - Data: []string{"1", "ignored", "ignored", "42"}, + Height: height, + Data: []string{"1", "7", "1", "42"}, } } diff --git a/query/query_test.go b/query/query_test.go index 7dbe151..1d7468a 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -34,7 +34,8 @@ func TestQuery(t *testing.T) { Actions: []*actions.Action{ { BlockHeight: 7, - FeePayer: []byte("alice"), + XCoordinate: []byte("alice-x"), + IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 42, }, @@ -45,7 +46,8 @@ func TestQuery(t *testing.T) { Actions: []*actions.Action{ { BlockHeight: 9, - FeePayer: []byte("bob"), + XCoordinate: []byte("bob-x"), + IsOdd: false, ActionType: actions.ActionType_WITHDRAW, Amount: 7, }, @@ -72,12 +74,14 @@ func TestQuery(t *testing.T) { require.Len(t, got.Actions, 2) require.Equal(t, want.Actions[0].BlockHeight, got.Actions[0].BlockHeight) - require.Equal(t, want.Actions[0].FeePayer, got.Actions[0].FeePayer) + require.Equal(t, want.Actions[0].XCoordinate, got.Actions[0].XCoordinate) + require.Equal(t, want.Actions[0].IsOdd, got.Actions[0].IsOdd) require.Equal(t, want.Actions[0].ActionType, got.Actions[0].ActionType) require.Equal(t, want.Actions[0].Amount, got.Actions[0].Amount) require.Equal(t, second.Actions[0].BlockHeight, got.Actions[1].BlockHeight) - require.Equal(t, second.Actions[0].FeePayer, got.Actions[1].FeePayer) + require.Equal(t, second.Actions[0].XCoordinate, got.Actions[1].XCoordinate) + require.Equal(t, second.Actions[0].IsOdd, got.Actions[1].IsOdd) require.Equal(t, second.Actions[0].ActionType, got.Actions[1].ActionType) require.Equal(t, second.Actions[0].Amount, got.Actions[1].Amount) } diff --git a/tests/container/smoke_test.go b/tests/container/smoke_test.go index 8f7e048..046652b 100644 --- a/tests/container/smoke_test.go +++ b/tests/container/smoke_test.go @@ -25,9 +25,10 @@ import ( const queryServiceName = "query.Query" type wrapperResult struct { - height int64 - amount int64 - feePayer string + height int64 + amount int64 + xCoordinate string + isOdd bool } func TestUnavailableQueryIsRejected(t *testing.T) { @@ -109,7 +110,7 @@ func TestConcurrentClients(t *testing.T) { for got := range results { require.Equal(t, int64(12), got.height) require.Equal(t, int64(42), got.amount) - require.NotEmpty(t, got.feePayer) + require.NotEmpty(t, got.xCoordinate) resultCount++ } require.Equal(t, 3, resultCount) @@ -165,14 +166,15 @@ func queryWrapper(ctx context.Context, connection *grpc.ClientConn) (wrapperResu return wrapperResult{}, fmt.Errorf("unexpected action count: %d", len(actionsResponse.Actions)) } action := actionsResponse.Actions[0] - if action.BlockHeight != 11 || action.ActionType != actions.ActionType_DEPOSIT || len(action.FeePayer) == 0 { + if action.BlockHeight != 11 || action.ActionType != actions.ActionType_DEPOSIT || len(action.XCoordinate) == 0 { return wrapperResult{}, errors.New("unexpected action payload") } return wrapperResult{ - height: heightResponse.BlockHeight, - amount: action.Amount, - feePayer: string(action.FeePayer), + height: heightResponse.BlockHeight, + amount: action.Amount, + xCoordinate: string(action.XCoordinate), + isOdd: action.IsOdd, }, nil } From de35204c01f84d179b4c4793a44e020325def065 Mon Sep 17 00:00:00 2001 From: Yusuf Date: Mon, 10 Aug 2026 15:10:40 +0300 Subject: [PATCH 03/10] chore: tidy go modules --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 0eaa5f6..10b11a5 100644 --- a/go.sum +++ b/go.sum @@ -49,8 +49,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/node101-io/mina-signer-go v0.0.0-20260601165332-9dc4888e6819 h1:PYnyy92xzQ8oNjsydAenjPURHvOcTu6lsPiJ0iFYCoI= -github.com/node101-io/mina-signer-go v0.0.0-20260601165332-9dc4888e6819/go.mod h1:vGZaN+qwZwJzSm5WQ4hTs95ULhysLLhz7kV+SLj4Abc= github.com/node101-io/mina-signer-go v0.0.0-20260810105351-862ef720d914 h1:gANeiWrgwdqxPzNnEx0i5Ew5NzyF897OmFRHQ7keQtk= github.com/node101-io/mina-signer-go v0.0.0-20260810105351-862ef720d914/go.mod h1:vGZaN+qwZwJzSm5WQ4hTs95ULhysLLhz7kV+SLj4Abc= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= From 7af6a36fb11a03227a071b08efdac21526271067 Mon Sep 17 00:00:00 2001 From: Yusuf Date: Mon, 10 Aug 2026 15:51:20 +0300 Subject: [PATCH 04/10] fix: update testdata --- testdata/container/seed.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testdata/container/seed.sql b/testdata/container/seed.sql index 84a5ea2..0dbfdbb 100644 --- a/testdata/container/seed.sql +++ b/testdata/container/seed.sql @@ -12,8 +12,8 @@ INSERT INTO zkapp_fee_payer_body (id, public_key_id) VALUES (1, 2); INSERT INTO account_identifiers (id, public_key_id) VALUES (1, 1); INSERT INTO zkapp_field (id, field) VALUES (1, '1'), - (2, 'ignored'), - (3, 'ignored'), + (2, '7'), + (3, '1'), (4, '42'); INSERT INTO zkapp_field_array (id, element_ids) VALUES (1, ARRAY[1, 2, 3, 4]::bigint[]); INSERT INTO zkapp_events (id, element_ids) VALUES (1, ARRAY[1]::bigint[]); From 80ed0da643d50ff27d4a187e99bad65df804a1bf Mon Sep 17 00:00:00 2001 From: Yusuf Date: Mon, 10 Aug 2026 16:58:06 +0300 Subject: [PATCH 05/10] fix: add a size check to fieldBytesFromDecimal --- fetchmina/fetch.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fetchmina/fetch.go b/fetchmina/fetch.go index a3c2b33..b8c387f 100644 --- a/fetchmina/fetch.go +++ b/fetchmina/fetch.go @@ -281,10 +281,16 @@ func fieldBytesFromDecimal(s string) ([]byte, error) { } size := minafield.NewField().ElementSize() - b := n.FillBytes(make([]byte, size)) + raw := n.Bytes() + if len(raw) > size { + return nil, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account x_coordinate") + } + + b := make([]byte, size) + copy(b[size-len(raw):], raw) if _, err := minafield.NewFieldElement(b); err != nil { - return nil, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account x_cordinate") + return nil, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account x_coordinate") } return b, nil From 84fe4b829f49e5a7f6a12b3232f795530474a9ed Mon Sep 17 00:00:00 2001 From: korayakpinar Date: Mon, 10 Aug 2026 21:37:30 +0300 Subject: [PATCH 06/10] fix(database): validate persisted action coordinates --- actions/action_test.go | 4 +-- database/db_test.go | 68 +++++++++++++++++++++++++++++++++++++++-- database/helpers.go | 7 +++++ indexer/indexer_test.go | 10 +++--- query/query_test.go | 4 +-- 5 files changed, 81 insertions(+), 12 deletions(-) diff --git a/actions/action_test.go b/actions/action_test.go index 7d8c6f5..b022074 100644 --- a/actions/action_test.go +++ b/actions/action_test.go @@ -10,7 +10,7 @@ import ( func TestActionProtoRoundTrip(t *testing.T) { want := &Action{ BlockHeight: 42, - XCoordinate: []byte("alice-x"), + XCoordinate: append(make([]byte, 31), 1), IsOdd: true, ActionType: ActionType_DEPOSIT, Amount: 99, @@ -30,7 +30,7 @@ func TestDbRecordProtoRoundTrip(t *testing.T) { Actions: []*Action{ { BlockHeight: 7, - XCoordinate: []byte("alice-x"), + XCoordinate: append(make([]byte, 31), 1), IsOdd: true, ActionType: ActionType_WITHDRAW, Amount: 11, diff --git a/database/db_test.go b/database/db_test.go index 1ebde1a..17bde56 100644 --- a/database/db_test.go +++ b/database/db_test.go @@ -1,6 +1,7 @@ package database import ( + "bytes" "encoding/json" "errors" "io" @@ -11,6 +12,7 @@ import ( "github.com/node101-io/archive-wrapper/actions" "github.com/node101-io/archive-wrapper/apperrors" + minafield "github.com/node101-io/mina-signer-go/field" proto "github.com/cosmos/gogoproto/proto" "github.com/stretchr/testify/require" @@ -37,7 +39,7 @@ func TestDbManager_InsertThenGet(t *testing.T) { Actions: []*actions.Action{ { BlockHeight: 7, - XCoordinate: []byte("alice-x"), + XCoordinate: canonicalXCoordinate(), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 42, @@ -64,6 +66,31 @@ func TestDbManager_InsertThenGet(t *testing.T) { } +func TestDbManagerInsertRejectsInvalidXCoordinate(t *testing.T) { + tests := []struct { + name string + x []byte + wantErr error + }{ + {name: "empty", x: nil, wantErr: apperrors.ErrEmptyXCoordinate}, + {name: "short", x: []byte{1}, wantErr: apperrors.ErrInvalidActionData}, + {name: "long", x: make([]byte, minafield.NewField().ElementSize()+1), wantErr: apperrors.ErrInvalidActionData}, + {name: "non-canonical", x: bytes.Repeat([]byte{0xff}, minafield.NewField().ElementSize()), wantErr: apperrors.ErrInvalidActionData}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + logger := slog.New(slog.NewTextHandler(io.Discard, nil)) + manager, err := NewDbManager(t.TempDir(), blockHeightDatabaseKey, logger) + require.NoError(t, err) + defer func() { require.NoError(t, manager.Close()) }() + + err = manager.Insert(testRecordWithX(10, tt.x)) + require.ErrorIs(t, err, tt.wantErr) + }) + } +} + func TestDbManagerInsertBlockHeight(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) @@ -440,7 +467,7 @@ func TestDbManagerGetRejectsCorruptPersistedRecord(t *testing.T) { Key: 11, Actions: []*actions.Action{{ BlockHeight: 11, - XCoordinate: []byte("alice-x"), + XCoordinate: canonicalXCoordinate(), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 1, @@ -454,13 +481,31 @@ func TestDbManagerGetRejectsCorruptPersistedRecord(t *testing.T) { Key: 10, Actions: []*actions.Action{{ BlockHeight: 10, - XCoordinate: []byte("alice-x"), + XCoordinate: canonicalXCoordinate(), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 0, }}, }), }, + { + name: "short x coordinate", + height: 10, + persisted: marshalRecord(t, testRecordWithX(10, []byte{1})), + }, + { + name: "long x coordinate", + height: 10, + persisted: marshalRecord(t, testRecordWithX(10, make([]byte, minafield.NewField().ElementSize()+1))), + }, + { + name: "non-canonical x coordinate", + height: 10, + persisted: marshalRecord(t, testRecordWithX( + 10, + bytes.Repeat([]byte{0xff}, minafield.NewField().ElementSize()), + )), + }, } for _, tt := range tests { @@ -491,6 +536,23 @@ func marshalRecord(t *testing.T, record actions.DbRecord) []byte { return encoded } +func canonicalXCoordinate() []byte { + return minafield.NewField().FromUint64(7).Bytes() +} + +func testRecordWithX(height int64, x []byte) actions.DbRecord { + return actions.DbRecord{ + Key: height, + Actions: []*actions.Action{{ + BlockHeight: height, + XCoordinate: x, + IsOdd: true, + ActionType: actions.ActionType_DEPOSIT, + Amount: 1, + }}, + } +} + func testDeploymentMetadata() DeploymentMetadata { return DeploymentMetadata{ SchemaVersion: 1, diff --git a/database/helpers.go b/database/helpers.go index 30f32f9..802762b 100644 --- a/database/helpers.go +++ b/database/helpers.go @@ -1,11 +1,13 @@ package database import ( + "bytes" "encoding/binary" cosmosErrors "cosmossdk.io/errors" actions "github.com/node101-io/archive-wrapper/actions" "github.com/node101-io/archive-wrapper/apperrors" + minafield "github.com/node101-io/mina-signer-go/field" ) func encodeBlockHeight(height int64) []byte { @@ -49,6 +51,11 @@ func validateRecord(record actions.DbRecord) error { if len(act.XCoordinate) == 0 { return apperrors.ErrEmptyXCoordinate } + + fieldElement, err := minafield.NewFieldElement(act.XCoordinate) + if err != nil || !bytes.Equal(fieldElement.Bytes(), act.XCoordinate) { + return cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid x coordinate") + } } return nil diff --git a/indexer/indexer_test.go b/indexer/indexer_test.go index 70a1988..b0aa901 100644 --- a/indexer/indexer_test.go +++ b/indexer/indexer_test.go @@ -40,8 +40,8 @@ func TestNewIndexerRejectsNilConnection(t *testing.T) { func TestIndexActionsBuildsRecord(t *testing.T) { items := []actions.Action{ - {BlockHeight: 7, XCoordinate: []byte("alice-x"), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 5}, - {BlockHeight: 7, XCoordinate: []byte("bob-x"), IsOdd: false, ActionType: actions.ActionType_WITHDRAW, Amount: 3}, + {BlockHeight: 7, XCoordinate: append(make([]byte, 31), 1), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 5}, + {BlockHeight: 7, XCoordinate: append(make([]byte, 31), 1), IsOdd: false, ActionType: actions.ActionType_WITHDRAW, Amount: 3}, } record, err := IndexActions(items, 7) @@ -49,9 +49,9 @@ func TestIndexActionsBuildsRecord(t *testing.T) { require.Equal(t, int64(7), record.Key) require.Len(t, record.Actions, 2) - require.Equal(t, []byte("alice-x"), record.Actions[0].XCoordinate) + require.Equal(t, append(make([]byte, 31), 1), record.Actions[0].XCoordinate) require.True(t, record.Actions[0].IsOdd) - require.Equal(t, []byte("bob-x"), record.Actions[1].XCoordinate) + require.Equal(t, append(make([]byte, 31), 1), record.Actions[1].XCoordinate) require.False(t, record.Actions[1].IsOdd) } @@ -107,7 +107,7 @@ func TestRunReconcilesAuthoritativeTipForDuplicateAndOutOfOrderNotificationPaylo Key: 68, Actions: []*actions.Action{{ BlockHeight: 68, - XCoordinate: []byte("persisted-x"), + XCoordinate: append(make([]byte, 31), 1), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 42, diff --git a/query/query_test.go b/query/query_test.go index 1d7468a..634d7f5 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -34,7 +34,7 @@ func TestQuery(t *testing.T) { Actions: []*actions.Action{ { BlockHeight: 7, - XCoordinate: []byte("alice-x"), + XCoordinate: append(make([]byte, 31), 1), IsOdd: true, ActionType: actions.ActionType_DEPOSIT, Amount: 42, @@ -46,7 +46,7 @@ func TestQuery(t *testing.T) { Actions: []*actions.Action{ { BlockHeight: 9, - XCoordinate: []byte("bob-x"), + XCoordinate: append(make([]byte, 31), 1), IsOdd: false, ActionType: actions.ActionType_WITHDRAW, Amount: 7, From a4950d961e8f890fb1689e466b4abc1cd007a105 Mon Sep 17 00:00:00 2001 From: korayakpinar Date: Mon, 10 Aug 2026 21:39:19 +0300 Subject: [PATCH 07/10] fix(fetchmina): validate action field parsing --- fetchmina/fetch.go | 4 +- fetchmina/fetch_test.go | 138 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 133 insertions(+), 9 deletions(-) diff --git a/fetchmina/fetch.go b/fetchmina/fetch.go index b8c387f..46d015c 100644 --- a/fetchmina/fetch.go +++ b/fetchmina/fetch.go @@ -1,6 +1,7 @@ package fetchmina import ( + "bytes" "context" "errors" "fmt" @@ -289,7 +290,8 @@ func fieldBytesFromDecimal(s string) ([]byte, error) { b := make([]byte, size) copy(b[size-len(raw):], raw) - if _, err := minafield.NewFieldElement(b); err != nil { + fieldElement, err := minafield.NewFieldElement(b) + if err != nil || !bytes.Equal(fieldElement.Bytes(), b) { return nil, cosmosErrors.Wrap(apperrors.ErrInvalidActionData, "invalid account x_coordinate") } diff --git a/fetchmina/fetch_test.go b/fetchmina/fetch_test.go index 4b2f1af..104e5e5 100644 --- a/fetchmina/fetch_test.go +++ b/fetchmina/fetch_test.go @@ -18,6 +18,12 @@ import ( const validAddress = "B62qjTpSX2R4fyqJrC9pzvm5PSZb5GMaYBXh8di3TBn6pPC9XXYFC9k" +const ( + pallasBaseFieldModulus = "28948022309329048855892746252171976963363056481941560715954676764349967630337" + pallasBaseFieldModulusMinusOne = "28948022309329048855892746252171976963363056481941560715954676764349967630336" + integerAboveFieldByteSize = "115792089237316195423570985008687907853269984665640564039457584007913129639936" +) + func TestNewMinaClientRejectsNilQueries(t *testing.T) { logger := slog.New(slog.NewTextHandler(io.Discard, nil)) @@ -41,15 +47,131 @@ func TestNewMinaClientRejectsInvalidContractAddress(t *testing.T) { } func TestActionFromRawDataBuildsAction(t *testing.T) { - action, err := actionFromRawData(99, []string{"1", "7", "1", "42"}) - require.NoError(t, err) - require.NotNil(t, action) + tests := []struct { + name string + data []string + actionType actions.ActionType + isOdd bool + }{ + {name: "deposit", data: []string{"1", "7", "1", "42"}, actionType: actions.ActionType_DEPOSIT, isOdd: true}, + {name: "withdraw", data: []string{"2", "7", "0", "42"}, actionType: actions.ActionType_WITHDRAW, isOdd: false}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + action, err := actionFromRawData(99, tt.data) + require.NoError(t, err) + require.NotNil(t, action) + + require.Equal(t, int64(99), action.BlockHeight) + require.Equal(t, tt.actionType, action.ActionType) + require.Equal(t, int64(42), action.Amount) + require.Equal(t, append(make([]byte, 31), 7), action.XCoordinate) + require.Equal(t, tt.isOdd, action.IsOdd) + }) + } +} + +func TestFieldBytesFromDecimal(t *testing.T) { + tests := []struct { + name string + value string + }{ + {name: "zero", value: "0"}, + {name: "small value", value: "7"}, + {name: "largest canonical value", value: pallasBaseFieldModulusMinusOne}, + } - require.Equal(t, int64(99), action.BlockHeight) - require.Equal(t, actions.ActionType_DEPOSIT, action.ActionType) - require.Equal(t, int64(42), action.Amount) - require.Equal(t, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7}, action.XCoordinate) - require.True(t, action.IsOdd) + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := fieldBytesFromDecimal(tt.value) + require.NoError(t, err) + require.Len(t, got, 32) + }) + } +} + +func TestFieldBytesFromDecimalRejectsInvalidValues(t *testing.T) { + tests := []struct { + name string + value string + }{ + {name: "empty", value: ""}, + {name: "malformed", value: "not-a-number"}, + {name: "negative", value: "-1"}, + {name: "field modulus", value: pallasBaseFieldModulus}, + {name: "above field byte size", value: integerAboveFieldByteSize}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := fieldBytesFromDecimal(tt.value) + + require.Nil(t, got) + require.ErrorIs(t, err, apperrors.ErrInvalidActionData) + }) + } +} + +func TestParseIsOddField(t *testing.T) { + tests := []struct { + name string + value string + want bool + }{ + {name: "even", value: "0", want: false}, + {name: "odd", value: "1", want: true}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := parseIsOddField(tt.value) + require.NoError(t, err) + require.Equal(t, tt.want, got) + }) + } +} + +func TestParseIsOddFieldRejectsInvalidValues(t *testing.T) { + tests := []struct { + name string + value string + }{ + {name: "empty", value: ""}, + {name: "negative", value: "-1"}, + {name: "greater than one", value: "2"}, + {name: "boolean text", value: "true"}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := parseIsOddField(tt.value) + + require.False(t, got) + require.ErrorIs(t, err, apperrors.ErrInvalidActionData) + }) + } +} + +func TestActionFromRawDataRejectsInvalidFields(t *testing.T) { + tests := []struct { + name string + data []string + wantErr error + }{ + {name: "missing fields", data: []string{"1", "7"}, wantErr: apperrors.ErrInvalidActionData}, + {name: "invalid x coordinate", data: []string{"1", pallasBaseFieldModulus, "1", "42"}, wantErr: apperrors.ErrInvalidActionData}, + {name: "invalid parity", data: []string{"1", "7", "2", "42"}, wantErr: apperrors.ErrInvalidActionData}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + action, err := actionFromRawData(99, tt.data) + + require.Nil(t, action) + require.ErrorIs(t, err, tt.wantErr) + }) + } } func TestGetMinaBlockHeightWrapsRetryableQueryErrors(t *testing.T) { From 163a2530a9f1354e23c152f8d14c19524369ab38 Mon Sep 17 00:00:00 2001 From: korayakpinar Date: Mon, 10 Aug 2026 21:40:21 +0300 Subject: [PATCH 08/10] docs(actions): document coordinate encoding --- actions/action.pb.go | 13 ++++++++----- proto/actions/action.proto | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/actions/action.pb.go b/actions/action.pb.go index 6717660..d664490 100644 --- a/actions/action.pb.go +++ b/actions/action.pb.go @@ -52,11 +52,14 @@ func (ActionType) EnumDescriptor() ([]byte, []int) { } type Action struct { - BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` - XCoordinate []byte `protobuf:"bytes,2,opt,name=x_coordinate,json=xCoordinate,proto3" json:"x_coordinate,omitempty"` - IsOdd bool `protobuf:"varint,3,opt,name=is_odd,json=isOdd,proto3" json:"is_odd,omitempty"` - ActionType ActionType `protobuf:"varint,4,opt,name=action_type,json=actionType,proto3,enum=actions.ActionType" json:"action_type,omitempty"` - Amount int64 `protobuf:"varint,5,opt,name=amount,proto3" json:"amount,omitempty"` + BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + // x_coordinate is the account's affine Pallas x-coordinate encoded as a + // 32-byte canonical big-endian field element. + XCoordinate []byte `protobuf:"bytes,2,opt,name=x_coordinate,json=xCoordinate,proto3" json:"x_coordinate,omitempty"` + // is_odd selects the affine y-coordinate with odd parity. + IsOdd bool `protobuf:"varint,3,opt,name=is_odd,json=isOdd,proto3" json:"is_odd,omitempty"` + ActionType ActionType `protobuf:"varint,4,opt,name=action_type,json=actionType,proto3,enum=actions.ActionType" json:"action_type,omitempty"` + Amount int64 `protobuf:"varint,5,opt,name=amount,proto3" json:"amount,omitempty"` } func (m *Action) Reset() { *m = Action{} } diff --git a/proto/actions/action.proto b/proto/actions/action.proto index 7a5a59e..0b0e085 100644 --- a/proto/actions/action.proto +++ b/proto/actions/action.proto @@ -16,7 +16,10 @@ message Action { option (gogoproto.goproto_getters) = false; int64 block_height = 1; + // x_coordinate is the account's affine Pallas x-coordinate encoded as a + // 32-byte canonical big-endian field element. bytes x_coordinate = 2; + // is_odd selects the affine y-coordinate with odd parity. bool is_odd = 3; ActionType action_type = 4; int64 amount = 5; From 20919ed693107641871274c35f48bd1b47b4a87c Mon Sep 17 00:00:00 2001 From: Yusuf Date: Wed, 12 Aug 2026 20:29:16 +0300 Subject: [PATCH 09/10] fix: add purego tag to test-container --- scripts/test-container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-container.sh b/scripts/test-container.sh index 2831408..6333687 100755 --- a/scripts/test-container.sh +++ b/scripts/test-container.sh @@ -125,7 +125,7 @@ wait_for_probe_failure wrapper1 wrapper_address=$(published_address wrapper1) ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestUnavailableQueryIsRejected$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestUnavailableQueryIsRejected$' -count=1 "${compose[@]}" up --detach postgres wait_for_healthy postgres From fe5c741a1f1b08ef4ca00d5df2cd4166d1818faf Mon Sep 17 00:00:00 2001 From: Yusuf Date: Wed, 12 Aug 2026 20:42:44 +0300 Subject: [PATCH 10/10] fix: add purego tag to container smoe tests --- scripts/test-container.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/test-container.sh b/scripts/test-container.sh index 6333687..ee96e7b 100755 --- a/scripts/test-container.sh +++ b/scripts/test-container.sh @@ -134,7 +134,7 @@ wait_for_healthy wrapper1 wrapper_address=$(published_address wrapper1) ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestConcurrentClients$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestConcurrentClients$' -count=1 # A PostgreSQL outage withdraws readiness, and recovery does not require a wrapper restart. "${compose[@]}" stop postgres @@ -142,7 +142,7 @@ wait_for_probe_failure wrapper1 wrapper_address=$(published_address wrapper1) ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestUnavailableQueryIsRejected$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestUnavailableQueryIsRejected$' -count=1 "${compose[@]}" start postgres wait_for_healthy postgres wait_for_healthy wrapper1 @@ -156,7 +156,7 @@ wait_for_healthy wrapper1 wrapper_address=$(published_address wrapper1) ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestConcurrentClients$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestConcurrentClients$' -count=1 # A second owner of the same LevelDB volume must fail instead of serving stale state. "${compose[@]}" --profile lock up --detach --no-deps wrapper-lock @@ -190,20 +190,20 @@ wrapper2_address=$(published_address wrapper2) wrapper3_address=$(published_address wrapper3) ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper1_address,$wrapper2_address,$wrapper3_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestWrapperIsolation$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestWrapperIsolation$' -count=1 "${compose[@]}" stop --timeout 15 wrapper2 wrapper2_exit_code=$(docker inspect --format '{{.State.ExitCode}}' "$("${compose[@]}" ps --all --quiet wrapper2)") [[ $wrapper2_exit_code -eq 0 ]] ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper1_address,$wrapper3_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestWrapperIsolation$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestWrapperIsolation$' -count=1 "${compose[@]}" start wrapper2 wait_for_healthy wrapper2 wrapper2_address=$(published_address wrapper2) ARCHIVE_WRAPPER_TEST_ADDRESSES="$wrapper1_address,$wrapper2_address,$wrapper3_address" \ GOCACHE="${GOCACHE:-/tmp/go-build-cache}" \ - go test -tags=container ./tests/container -run '^TestWrapperIsolation$' -count=1 + go test -tags=container,purego ./tests/container -run '^TestWrapperIsolation$' -count=1 echo "container lifecycle, shared-client, and wrapper-isolation smoke tests passed"