Skip to content

Commit

Permalink
Drop legacy ZkSync support
Browse files Browse the repository at this point in the history
  • Loading branch information
azdagron committed Aug 11, 2024
1 parent 9f5af28 commit f67a166
Show file tree
Hide file tree
Showing 19 changed files with 10 additions and 1,489 deletions.
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
.PHONY: all generate binary test lint

CGO_LDFLAGS="-L$(CURDIR) -lm"

all: binary

libzks-crypto.a:
rm -f libzks-crypto.so # remove the dynamic library if it exists
wget https://github.com/zksync-sdk/zksync-crypto-c/releases/download/v0.1.2/zks-crypto-x86_64-unknown-linux-gnu.a -O $(CURDIR)/libzks-crypto.a

generate:
go generate ./...

binary: libzks-crypto.a
CGO_LDFLAGS=$(CGO_LDFLAGS) go build ./cmd/crybapy
binary:
go build ./cmd/crybapy

test: libzks-crypto.a
CGO_LDFLAGS=$(CGO_LDFLAGS) go test -race ./...
test:
go test -race ./...

lint:
docker run --rm -v $(CURDIR):/app -v $(HOME)/.cache/golangci-lint/v1.59.1:/root/.cache -w /app golangci/golangci-lint:v1.59.1 golangci-lint run -v
23 changes: 0 additions & 23 deletions cmd/crybapy/factory_payer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"storj.io/crypto-batch-payment/pkg/eth"
"storj.io/crypto-batch-payment/pkg/payer"
"storj.io/crypto-batch-payment/pkg/storjtoken"
"storj.io/crypto-batch-payment/pkg/zksync"
"storj.io/crypto-batch-payment/pkg/zksyncera"
)

Expand Down Expand Up @@ -161,28 +160,6 @@ func CreatePayer(ctx context.Context, log *zap.Logger, config PayerConfig, nodeA
if err != nil {
return nil, errs.Wrap(err)
}
case payer.ZkSync:
paymentPayer, err = zksync.NewPayer(
ctx,
nodeAddress,
spenderKey,
int(chainID.Int64()),
false,
maxFee)
if err != nil {
return nil, errs.Wrap(err)
}
case payer.ZkWithdraw:
paymentPayer, err = zksync.NewPayer(
ctx,
nodeAddress,
spenderKey,
int(chainID.Int64()),
true,
maxFee)
if err != nil {
return nil, errs.Wrap(err)
}
case payer.ZkSyncEra:
var paymasterAddress *common.Address
var paymasterPayload []byte
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ require (
github.com/stretchr/testify v1.9.0
github.com/zeebo/errs v1.2.2
github.com/zeebo/errs/v2 v2.0.3
github.com/zksync-sdk/zksync-sdk-go v0.0.0-20211119083613-58613b4d3d77
github.com/zksync-sdk/zksync2-go v0.4.0
go.uber.org/zap v1.16.0
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g=
github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
github.com/zeebo/errs/v2 v2.0.3 h1:WwqAmopgot4ZC+CgIveP+H91Nf78NDEGWjtAXen45Hw=
github.com/zeebo/errs/v2 v2.0.3/go.mod h1:OKmvVZt4UqpyJrYFykDKm168ZquJ55pbbIVUICNmLN0=
github.com/zksync-sdk/zksync-sdk-go v0.0.0-20211119083613-58613b4d3d77 h1:qcdE1F/TnY4Kck5Uy9SO6avKVcQ53vgFZeuQ4G7jfGk=
github.com/zksync-sdk/zksync-sdk-go v0.0.0-20211119083613-58613b4d3d77/go.mod h1:ZUgHa5wGdUAYfBlO6iEL3UV/IVTiKNI4JuWlLnbBpWM=
github.com/zksync-sdk/zksync2-go v0.4.0 h1:gfV3EQWNXkcUkdRwzMqJ4Zh/RNHnOIXrD4qsipUV4OY=
github.com/zksync-sdk/zksync2-go v0.4.0/go.mod h1:V0lqO7C20wJDHz+r4o/NFoomCMD0lOjT26EZ4njjwmc=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down
17 changes: 0 additions & 17 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Config struct {
Pipeline Pipeline `toml:"pipeline"`
CoinMarketCap CoinMarketCap `toml:"coinmarketcap"`
Eth *Eth `toml:"eth"`
ZkSync *ZkSync `toml:"zksync"`
ZkSyncEra *ZkSyncEra `toml:"zksync-era"`
}

Expand All @@ -38,14 +37,6 @@ func (c *Config) NewPayers(ctx context.Context) (_ Payers, err error) {
payers.Add(payer.Eth, p)
}

if c.ZkSync != nil {
p, err := c.ZkSync.NewPayer(ctx)
if err != nil {
return nil, fmt.Errorf("failed to init zksync payer: %w", err)
}
payers.Add(payer.ZkSync, p)
}

if c.ZkSyncEra != nil {
p, err := c.ZkSyncEra.NewPayer(ctx)
if err != nil {
Expand Down Expand Up @@ -73,14 +64,6 @@ func (c *Config) NewAuditors(ctx context.Context) (_ Auditors, err error) {
auditors.Add(payer.Eth, p)
}

if c.ZkSync != nil {
p, err := c.ZkSync.NewAuditor(ctx)
if err != nil {
return nil, fmt.Errorf("failed to init zksync auditor: %w", err)
}
auditors.Add(payer.ZkSync, p)
}

if c.ZkSyncEra != nil {
p, err := c.ZkSyncEra.NewAuditor(ctx)
if err != nil {
Expand Down
12 changes: 0 additions & 12 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ func TestLoad_Defaults(t *testing.T) {
MaxGas: nil,
GasTipCap: nil,
},
ZkSync: &config.ZkSync{
NodeAddress: "https://api.zksync.io",
SpenderKeyPath: homePath("some.key"),
ChainID: 0,
MaxFee: nil,
},
ZkSyncEra: &config.ZkSyncEra{
NodeAddress: "https://mainnet.era.zksync.io",
SpenderKeyPath: homePath("some.key"),
Expand Down Expand Up @@ -85,12 +79,6 @@ func TestLoad_Overrides(t *testing.T) {
MaxGas: big.NewInt(80_000_000_000),
GasTipCap: big.NewInt(2_000_000_000),
},
ZkSync: &config.ZkSync{
NodeAddress: "https://override.test",
SpenderKeyPath: "override",
ChainID: 12345,
MaxFee: big.NewInt(1234),
},
ZkSyncEra: &config.ZkSyncEra{
NodeAddress: "https://override.test",
SpenderKeyPath: "override",
Expand Down
5 changes: 0 additions & 5 deletions pkg/config/testdata/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ erc20_contract_address = "0x1111111111111111111111111111111111111111"
# max_gas = "70_000_000_000"
# gas_tip_cap = "1_000_000_000"

[zksync]
node_address = "https://api.zksync.io"
spender_key_path = "~/some.key"
# max_fee = ""

[zksync-era]
node_address = "https://mainnet.era.zksync.io"
spender_key_path = "~/some.key"
Expand Down
6 changes: 0 additions & 6 deletions pkg/config/testdata/override.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ owner = "0xe66652d41EE7e81d3fcAe1dF7F9B9f9411ac835e"
max_gas = "80_000_000_000"
gas_tip_cap = "2_000_000_000"

[zksync]
node_address = "https://override.test"
spender_key_path = "override"
chain_id = 12345
max_fee = "1234"

[zksync-era]
node_address = "https://override.test"
spender_key_path = "override"
Expand Down
71 changes: 0 additions & 71 deletions pkg/config/zksync.go

This file was deleted.

14 changes: 4 additions & 10 deletions pkg/payer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import (
type Type string

const (
Eth Type = "eth"
Sim Type = "sim"
ZkSync Type = "zksync"
ZkSyncEra Type = "zksync-era"
ZkWithdraw Type = "zkwithdraw"
Polygon Type = "polygon"
Eth Type = "eth"
Sim Type = "sim"
ZkSyncEra Type = "zksync-era"
Polygon Type = "polygon"
)

func (pt Type) String() string {
Expand All @@ -29,12 +27,8 @@ func TypeFromString(t string) (Type, error) {
return Eth, nil
case "polygon":
return Polygon, nil
case "zksync":
return ZkSync, nil
case "zksync-era", "zksync2": // zksync2 for backcompat
return ZkSyncEra, nil
case "zkwithdraw":
return ZkWithdraw, nil
case "sim":
return Sim, nil
default:
Expand Down
9 changes: 0 additions & 9 deletions pkg/payouts/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"storj.io/crypto-batch-payment/pkg/payer"
"storj.io/crypto-batch-payment/pkg/pipelinedb"
"storj.io/crypto-batch-payment/pkg/receipts"
"storj.io/crypto-batch-payment/pkg/zksync"
"storj.io/crypto-batch-payment/pkg/zksyncera"

"storj.io/crypto-batch-payment/pkg/csv"
Expand Down Expand Up @@ -54,14 +53,6 @@ func Audit(ctx context.Context, dir string, csvPath string, payerType payer.Type
}
case payer.Sim:
auditor = payer.NewSimAuditor()
case payer.ZkSync, payer.ZkWithdraw:
var err error
auditor, err = zksync.NewAuditor(
nodeAddress,
chainID)
if err != nil {
return nil, err
}
case payer.ZkSyncEra:
var err error
auditor, err = zksyncera.NewAuditor(nodeAddress)
Expand Down
4 changes: 2 additions & 2 deletions pkg/receipts/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func TestBuffer(t *testing.T) {

var b receipts.Buffer
b.Emit(address1, decimal.NewFromInt(1), "hash1", payer.Eth)
b.Emit(address2, decimal.NewFromInt(2), "hash2", payer.ZkSync)
b.Emit(address2, decimal.NewFromInt(2), "hash2", payer.Eth)
b.Emit(address3, decimal.NewFromInt(3), "hash3", payer.ZkSyncEra)
receipts := b.Finalize()
require.Equal(t, `wallet,amount,txhash,mechanism
0x0101010101010101010101010101010101010101,1,hash1,eth
0x0202020202020202020202020202020202020202,2,hash2,zksync
0x0202020202020202020202020202020202020202,2,hash2,eth
0x0303030303030303030303030303030303030303,3,hash3,zksync-era
`, string(receipts))
}
47 changes: 0 additions & 47 deletions pkg/zksync/auditor.go

This file was deleted.

2 changes: 0 additions & 2 deletions pkg/zksync/doc.go

This file was deleted.

Loading

0 comments on commit f67a166

Please sign in to comment.