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

feat!: bank precompile #2860

Merged
merged 43 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d06485f
feat: bank precompile
fbac Sep 10, 2024
969d2d2
feat: add deposit
fbac Sep 11, 2024
71aa8d5
feat: extend deposit
fbac Sep 11, 2024
322618b
PoC: spend amount on behalf of EOA
fbac Sep 11, 2024
7e85925
feat: expand deposit with transferFrom
fbac Sep 11, 2024
5fe30cf
use CallEVM instead on ZRC20 bindings
fbac Sep 11, 2024
f69c695
divide the contract into different files
fbac Sep 11, 2024
5863536
initialize e2e testing
fbac Sep 11, 2024
12a5138
remove duplicated funding
fbac Sep 11, 2024
a4be05e
add codecov
fbac Sep 11, 2024
75efde6
expand e2e
fbac Sep 11, 2024
6340abb
fix: wait for deposit tx to be mined
fbac Sep 11, 2024
0f347f2
apply first round of reviews
fbac Sep 12, 2024
e0fa24a
cover al error types test
fbac Sep 12, 2024
cf17671
fixes using time.Since
fbac Sep 12, 2024
02ddce3
Include CallContract interface
fbac Sep 12, 2024
c1836a3
fix eth events in deposit precompile method
skosito Sep 16, 2024
8503dc8
emit Deposit event
fbac Sep 16, 2024
6a19fb0
add withdraw function
fbac Sep 17, 2024
e7ddcb0
finalize withdraw
fbac Sep 17, 2024
f1e5b3a
pack event arguments generically
fbac Sep 17, 2024
05d0bfb
add high level event function
fbac Sep 17, 2024
0fa8d50
first round of review fixes
fbac Sep 17, 2024
b6b78a9
second round of reviews
fbac Sep 18, 2024
6271e7a
create bank account when instantiating bank
fbac Sep 18, 2024
1a4f553
e2e: add good and bad scenarios
fbac Sep 19, 2024
6caabef
Merge branch 'develop' into feat/bank-precompile
Sep 19, 2024
9ed6bfb
modify fmt
fbac Sep 19, 2024
b8094e2
chore: group input into eventData struct
fbac Sep 19, 2024
a7533eb
docs: document bank's methods
fbac Sep 19, 2024
67ad4fa
chore: generate files with suffix .gen.go
fbac Sep 20, 2024
82f5204
chore: assert errors with errorIs
fbac Sep 20, 2024
4d0a57b
chore: reset e2e test by resetting allowance
fbac Sep 20, 2024
c9bf427
test: add first batch of unit test
fbac Sep 21, 2024
84e7b9e
test: cover all cases
fbac Sep 23, 2024
dbec3ca
test: complete unit test cases
fbac Sep 23, 2024
af858ab
include review suggestions
fbac Sep 23, 2024
b18c50d
include e2e through contract
fbac Sep 24, 2024
35013e3
test: add e2e through contract complete
fbac Sep 25, 2024
de990fa
test: revert balance between tests
fbac Sep 25, 2024
f74194a
Merge branch 'develop' into feat/bank-precompile
Sep 25, 2024
b532de2
Update precompiles/bank/const.go
Sep 25, 2024
eeff21c
fix: changed coin denom
fbac Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes using time.Since
fbac committed Sep 16, 2024
commit cf17671f304a748d5e51d92505eb33cb77981a17
6 changes: 6 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -93,6 +93,7 @@ import (
"github.com/zeta-chain/node/docs/openapi"
zetamempool "github.com/zeta-chain/node/pkg/mempool"
"github.com/zeta-chain/node/precompiles"
bankprecompile "github.com/zeta-chain/node/precompiles/bank"
srvflags "github.com/zeta-chain/node/server/flags"
authoritymodule "github.com/zeta-chain/node/x/authority"
authoritykeeper "github.com/zeta-chain/node/x/authority/keeper"
@@ -1065,6 +1066,11 @@ func (app *App) BlockedAddrs() map[string]bool {
// Each enabled precompiled stateful contract should be added as a BlockedAddrs.
// That way it's marked as non payable by the bank keeper.
for addr, enabled := range precompiles.EnabledStatefulContracts {
// bank precompile has to be able to receive funds.
if addr == bankprecompile.ContractAddress {
continue
}

if enabled {
blockList[addr.String()] = enabled
}
4 changes: 2 additions & 2 deletions e2e/e2etests/test_rate_limiter.go
Original file line number Diff line number Diff line change
@@ -122,7 +122,7 @@ func createAndWaitWithdraws(r *runner.E2ERunner, withdrawType withdrawType, with
return err
}

duration := time.Now().Sub(startTime).Seconds()
duration := time.Since(startTime).Seconds()
block, err := r.ZEVMClient.BlockNumber(r.Ctx)
if err != nil {
return fmt.Errorf("error getting block number: %w", err)
@@ -155,7 +155,7 @@ func waitForWithdrawMined(
}

// record the time for completion
duration := time.Now().Sub(startTime).Seconds()
duration := time.Since(startTime).Seconds()
block, err := r.ZEVMClient.BlockNumber(ctx)
if err != nil {
return err
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_btc_deposit.go
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ func monitorBTCDeposit(r *runner.E2ERunner, hash *chainhash.Hash, index int, sta
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: deposit cctx success in %s", index, timeToComplete.String())

return nil
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_btc_withdraw.go
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ func monitorBTCWithdraw(r *runner.E2ERunner, tx *ethtypes.Transaction, index int
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: withdraw cctx success in %s", index, timeToComplete.String())

return nil
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_eth_deposit.go
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ func monitorEtherDeposit(r *runner.E2ERunner, hash ethcommon.Hash, index int, st
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: deposit cctx success in %s", index, timeToComplete.String())

return nil
2 changes: 1 addition & 1 deletion e2e/e2etests/test_stress_eth_withdraw.go
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ func monitorEtherWithdraw(r *runner.E2ERunner, tx *ethtypes.Transaction, index i
cctx.Index,
)
}
timeToComplete := time.Now().Sub(startTime)
timeToComplete := time.Since(startTime)
r.Logger.Print("index %d: withdraw cctx success in %s", index, timeToComplete.String())

return nil
4 changes: 2 additions & 2 deletions precompiles/types/errors_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import "testing"

func Test_ErrInvalidAddr(t *testing.T) {
e := ErrInvalidAddr{
Got: "foo",
Got: "foo",
Reason: "bar",
}
got := e.Error()
@@ -82,4 +82,4 @@ func Test_ErrUnexpected(t *testing.T) {
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
}
}