Skip to content

Commit

Permalink
Merge pull request #8 from AnomalyFi/nmt
Browse files Browse the repository at this point in the history
NMT Merge
  • Loading branch information
mtgnoah authored May 6, 2024
2 parents 4463fa2 + d93efbc commit bf74e2d
Show file tree
Hide file tree
Showing 86 changed files with 4,885 additions and 718 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/seq-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/seq-static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
go-version: "1.21"
check-latest: true
- name: Run static analysis tests
shell: bash
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*.log
*~
.DS_Store

.token_cli/
awscpu

# Binaries for programs and plugins
Expand Down Expand Up @@ -67,4 +67,6 @@ osxcross/
/target/
target/
Cargo.lock
**/*.rs.bk
**/*.rs.bk

main.log
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ linters-settings:
- name: useless-break
disabled: false
staticcheck:
go: "1.20"
go: "1.21"
# https://staticcheck.io/docs/options#checks
checks:
- "all"
Expand Down
Binary file removed .token-cli/000372.sst
Binary file not shown.
Binary file removed .token-cli/000379.sst
Binary file not shown.
Binary file removed .token-cli/000380.log
Binary file not shown.
1 change: 0 additions & 1 deletion .token-cli/CURRENT

This file was deleted.

Binary file removed .token-cli/MANIFEST-000377
Binary file not shown.
Binary file removed .token-cli/MANIFEST-000381
Binary file not shown.
100 changes: 0 additions & 100 deletions .token-cli/OPTIONS-000382

This file was deleted.

9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ethereum/client-go:v1.13.4

RUN apk add --no-cache jq

COPY entrypoint-l1.sh /entrypoint.sh

VOLUME ["/db"]

ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
4 changes: 4 additions & 0 deletions actions/burn_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@ func (*BurnAsset) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*BurnAsset) NMTNamespace() []byte {
return DefaultNMTNamespace
}
2 changes: 2 additions & 0 deletions actions/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ const (
MaxMetadataSize = 256
MaxDecimals = 9
)

var DefaultNMTNamespace = make([]byte, 8)
4 changes: 4 additions & 0 deletions actions/create_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ func (*CreateAsset) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*CreateAsset) NMTNamespace() []byte {
return DefaultNMTNamespace
}
4 changes: 4 additions & 0 deletions actions/export_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,7 @@ func (*ExportAsset) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*ExportAsset) NMTNamespace() []byte {
return DefaultNMTNamespace
}
4 changes: 4 additions & 0 deletions actions/export_block_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ func (*ExportBlockMsg) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*ExportBlockMsg) NMTNamespace() []byte {
return DefaultNMTNamespace
}
4 changes: 4 additions & 0 deletions actions/import_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,7 @@ func (*ImportAsset) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*ImportAsset) NMTNamespace() []byte {
return DefaultNMTNamespace
}
4 changes: 4 additions & 0 deletions actions/import_block_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ func (*ImportBlockMsg) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*ImportBlockMsg) NMTNamespace() []byte {
return DefaultNMTNamespace
}
4 changes: 4 additions & 0 deletions actions/mint_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@ func (*MintAsset) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*MintAsset) NMTNamespace() []byte {
return DefaultNMTNamespace
}
4 changes: 4 additions & 0 deletions actions/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,7 @@ func (*SequencerMsg) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (t *SequencerMsg) NMTNamespace() []byte {
return t.ChainId
}
4 changes: 4 additions & 0 deletions actions/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ func (*Transfer) ValidRange(chain.Rules) (int64, int64) {
// Returning -1, -1 means that the action is always valid.
return -1, -1
}

func (*Transfer) NMTNamespace() []byte {
return DefaultNMTNamespace
}
Binary file not shown.
Binary file removed build/token-cli
Binary file not shown.
Binary file removed build/token-faucet
Binary file not shown.
Binary file removed build/token-feed
Binary file not shown.
77 changes: 76 additions & 1 deletion cmd/token-cli/cmd/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,36 @@ var chainInfoCmd = &cobra.Command{
var watchChainCmd = &cobra.Command{
Use: "watch",
RunE: func(_ *cobra.Command, args []string) error {
ctx := context.Background()
pastBlocks, err := handler.Root().PromptBool("streaming from past blocks?")
if err != nil {
return err
}
var startBlock uint64
if pastBlocks {
startBlock, err = handler.Root().PromptUint64("start block")
if err != nil {
return err
}
_, _, _, cli, _, bcli, err := handler.DefaultActor()
if err != nil {
return err
}
_, lastAccepted, _, err := cli.Accepted(ctx)
if err != nil {
return err
}
acceptedWindow, err := bcli.GetAcceptedBlockWindow(ctx)
if err != nil {
return err
}
if lastAccepted > uint64(acceptedWindow) && lastAccepted-uint64(acceptedWindow) > startBlock {
return fmt.Errorf("start block is too old")
}
}

var cli *trpc.JSONRPCClient
return handler.Root().WatchChain(hideTxs, func(uri string, networkID uint32, chainID ids.ID) (chain.Parser, error) {
return handler.Root().WatchChain(hideTxs, pastBlocks, startBlock, func(uri string, networkID uint32, chainID ids.ID) (chain.Parser, error) {
fmt.Println("Here is network Id: %d", networkID)
fmt.Println("Here is uri: %s", uri)

Expand All @@ -83,3 +111,50 @@ var watchChainCmd = &cobra.Command{
})
},
}

var testHeaderCmd = &cobra.Command{
Use: "test-header",
RunE: func(*cobra.Command, []string) error {
ctx := context.Background()
_, _, _, _, _, tcli, err := handler.DefaultActor()
if err != nil {
return err
}

// start, err := handler.Root().PromptTime("start")
// if err != nil {
// return err
// }

// //1698200132261
// end, err := handler.Root().PromptTime("end")
// if err != nil {
// return err
// }

// // start_time := time.Unix(start, 0)
// // end_time := time.Unix(end, 0)

// start := time.Now().Unix()

// end := time.Now().Unix() - 120

start := int64(1702502928)
end := int64(1702502930)

start_time := start * 1000

end_time := end * 1000

res, err := tcli.GetBlockHeadersByStart(ctx, start_time, end_time)
if err != nil {
return err
}

fmt.Println(res.From)
fmt.Println(res.Next)
fmt.Println(res.Prev)

return nil
},
}
2 changes: 2 additions & 0 deletions cmd/token-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func init() {
setChainCmd,
chainInfoCmd,
watchChainCmd,
testHeaderCmd,
)

// actions
Expand Down Expand Up @@ -188,6 +189,7 @@ func init() {
)
spamCmd.AddCommand(
runSpamCmd,
runSpamSequencerMsgCmd,
)

// prometheus
Expand Down
Loading

0 comments on commit bf74e2d

Please sign in to comment.